diff --git a/chain/cosmos/broadcaster.go b/chain/cosmos/broadcaster.go index cc3eb9383..79c816305 100644 --- a/chain/cosmos/broadcaster.go +++ b/chain/cosmos/broadcaster.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/strangelove-ventures/interchaintest/v8/internal/dockerutil" "github.com/strangelove-ventures/interchaintest/v8/testutil" @@ -224,16 +224,22 @@ func BroadcastTx(ctx context.Context, broadcaster *Broadcaster, broadcastingUser return sdk.TxResponse{}, err } - resp, err := authTx.QueryTx(cc, respWithTxHash.TxHash) - if err != nil { - // if we fail to query the tx, it means an error occurred with the original message broadcast. - // we should return this instead. - originalResp, err := broadcaster.UnmarshalTxResponseBytes(ctx, txBytes) + return getFullyPopulatedResponse(cc, respWithTxHash.TxHash) +} + +// getFullyPopulatedResponse returns a fully populated sdk.TxResponse. +// the QueryTx function is periodically called until a tx with the given hash +// has been included in a block. +func getFullyPopulatedResponse(cc client.Context, txHash string) (sdk.TxResponse, error) { + var resp sdk.TxResponse + err := testutil.WaitForCondition(time.Second*60, time.Second*5, func() (bool, error) { + fullyPopulatedTxResp, err := authtx.QueryTx(cc, txHash) if err != nil { - return sdk.TxResponse{}, err + return false, nil } - return originalResp, nil - } - return *resp, nil + resp = *fullyPopulatedTxResp + return true, nil + }) + return resp, err }