Skip to content

Commit

Permalink
Merge pull request #6802 from filecoin-project/fix/6786-rest
Browse files Browse the repository at this point in the history
fix: always check if StateSearchMessage returns nil
  • Loading branch information
magik6k authored Jul 21, 2021
2 parents c29f375 + 2c5a867 commit 0236f2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cli/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ var StateExecTraceCmd = &cli.Command{
if err != nil {
return err
}
if lookup == nil {
return fmt.Errorf("failed to find message: %s", mcid)
}

ts, err := capi.ChainGetTipSet(ctx, lookup.TipSet)
if err != nil {
Expand Down Expand Up @@ -1491,6 +1494,10 @@ var StateSearchMsgCmd = &cli.Command{
return err
}

if mw == nil {
return fmt.Errorf("failed to find message: %s", msg)
}

m, err := api.ChainGetMessage(ctx, msg)
if err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions cmd/tvx/extract_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to locate message: %w", err)
}
if msgInfo == nil {
return nil, nil, nil, fmt.Errorf("failed to locate message: not found")
}

log.Printf("located message at tipset %s (height: %d) with exit code: %s", msgInfo.TipSet, msgInfo.Height, msgInfo.Receipt.ExitCode)

Expand Down
1 change: 1 addition & 0 deletions itests/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (ts *apiSuite) testSearchMsg(t *testing.T) {

searchRes, err := full.StateSearchMsg(ctx, types.EmptyTSK, sm.Cid(), lapi.LookbackNoLimit, true)
require.NoError(t, err)
require.NotNil(t, searchRes)

require.Equalf(t, res.TipSet, searchRes.TipSet, "search ts: %s, different from wait ts: %s", searchRes.TipSet, res.TipSet)
}
Expand Down

0 comments on commit 0236f2e

Please sign in to comment.