Skip to content

Commit

Permalink
Automatic retry for TX lookup in feegrant test case
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMoser committed Jul 12, 2023
1 parent 2bdc5ae commit 3febd1b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion interchaintest/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"testing"
"time"

"github.com/avast/retry-go/v4"
rpcclient "github.com/cometbft/cometbft/rpc/client"
ctypes "github.com/cometbft/cometbft/rpc/core/types"
"github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/go-bip39"
Expand Down Expand Up @@ -378,7 +381,7 @@ func TestScenarioFeegrantBasic(t *testing.T) {

hash, err := hex.DecodeString(curr.Response.TxHash)
require.Nil(t, err)
txResp, err := cProv.RPCClient.Tx(ctx, hash, true)
txResp, err := TxWithRetry(ctx, cProv.RPCClient, hash)
require.Nil(t, err)

require.Nil(t, err)
Expand Down Expand Up @@ -514,3 +517,16 @@ func TestScenarioFeegrantBasic(t *testing.T) {
require.Less(t, gaiaGranterIBCBalance, fundAmount)
r.StopRelayer(ctx, eRep)
}

func TxWithRetry(ctx context.Context, client rpcclient.Client, hash []byte) (*ctypes.ResultTx, error) {
var err error
var res *ctypes.ResultTx
if err = retry.Do(func() error {
res, err = client.Tx(ctx, hash, true)
return err
}, retry.Context(ctx), relayer.RtyAtt, relayer.RtyDel, relayer.RtyErr); err != nil {
return res, err
}

return res, err
}

0 comments on commit 3febd1b

Please sign in to comment.