Skip to content

Commit

Permalink
fix: Errors in cosmos Broadcaster are sometimes not propagated to cal…
Browse files Browse the repository at this point in the history
…ler (#938)

(cherry picked from commit 1ac6f84)

# Conflicts:
#	go.work.sum
  • Loading branch information
Reecepbcups authored and mergify[bot] committed Feb 2, 2024
1 parent 3c6f628 commit 1a4898e
Show file tree
Hide file tree
Showing 3 changed files with 1,095 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chain/cosmos/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,15 @@ func (b *Broadcaster) UnmarshalTxResponseBytes(ctx context.Context, bytes []byte
if err := b.chain.cfg.EncodingConfig.Codec.UnmarshalJSON(bytes, &resp); err != nil {
return sdk.TxResponse{}, err
}

// persist nested errors such as ValidateBasic checks.
code := resp.Code
rawLog := resp.RawLog

if code != 0 {
return resp, fmt.Errorf("error in transaction (code: %d): raw_log: %s", code, rawLog)
}

return resp, nil
}

Expand Down
11 changes: 11 additions & 0 deletions examples/cosmos/chain_miscellaneous_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,17 @@ func testBroadcaster(ctx context.Context, t *testing.T, chain *cosmos.CosmosChai
updatedBal2, err := chain.GetBalance(ctx, addr2, chain.Config().Denom)
require.NoError(t, err)
require.Equal(t, math.NewInt(2), updatedBal2)

txResp, err = cosmos.BroadcastTx(
ctx,
b,
users[0],
banktypes.NewMsgMultiSend(banktypes.Input{

Check failure on line 323 in examples/cosmos/chain_miscellaneous_test.go

View workflow job for this annotation

GitHub Actions / test-cosmos-examples

cannot use banktypes.Input{…} (value of type "github.com/cosmos/cosmos-sdk/x/bank/types".Input) as type []"github.com/cosmos/cosmos-sdk/x/bank/types".Input in argument to banktypes.NewMsgMultiSend
Address: addr1,
Coins: c1.Add(c2[0]),
}, out),
)
require.Error(t, err)
}

func testQueryCmd(ctx context.Context, t *testing.T, chain *cosmos.CosmosChain) {
Expand Down
Loading

0 comments on commit 1a4898e

Please sign in to comment.