Skip to content

Commit

Permalink
extended block wait time
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Oct 6, 2023
1 parent 04b8d2d commit f5a7a74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
17 changes: 9 additions & 8 deletions middleware/packet-forward-middleware/e2e/packet_forward_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
rep = testreporter.NewNopReporter()
eRep = rep.RelayerExecReporter(t)
chainIdA, chainIdB, chainIdC, chainIdD = "chain-a", "chain-b", "chain-c", "chain-d"
waitBlocks = 3
)

vals := 1
Expand Down Expand Up @@ -214,7 +215,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+30, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

chainABalance, err := chainA.GetBalance(ctx, userA.FormattedAddress(), chainA.Config().Denom)
Expand Down Expand Up @@ -288,7 +289,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainD, chainDHeight, chainDHeight+30, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

// assert balances for user controlled wallets
Expand Down Expand Up @@ -351,7 +352,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+25, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

// assert balances for user controlled wallets
Expand Down Expand Up @@ -408,7 +409,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+25, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

// assert balances for user controlled wallets
Expand Down Expand Up @@ -477,7 +478,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+30, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

// assert balances for user controlled wallets
Expand Down Expand Up @@ -543,7 +544,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainB, chainBHeight, chainBHeight+10, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainB)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainB)
require.NoError(t, err)

// assert balance for user controlled wallet
Expand Down Expand Up @@ -597,7 +598,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+30, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

// assert balances for user controlled wallets
Expand Down Expand Up @@ -665,7 +666,7 @@ func TestPacketForwardMiddleware(t *testing.T) {
require.NoError(t, err)
_, err = testutil.PollForAck(ctx, chainA, chainAHeight, chainAHeight+30, transferTx.Packet)
require.NoError(t, err)
err = testutil.WaitForBlocks(ctx, 1, chainA)
err = testutil.WaitForBlocks(ctx, waitBlocks, chainA)
require.NoError(t, err)

chainABalance, err := chainA.GetBalance(ctx, userA.FormattedAddress(), chainA.Config().Denom)
Expand Down
15 changes: 6 additions & 9 deletions middleware/packet-forward-middleware/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ func NewSimApp(

// Transfer Keeper
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec,
app.keys[ibctransfertypes.StoreKey],
appCodec, app.keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
// The ICS4Wrapper is replaced by the PacketForwardKeeper instead of the channel so that sending can be overridden by the middleware
app.PFMKeeper,
Expand All @@ -478,20 +477,18 @@ func NewSimApp(
pfmkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

// Create IBC Router
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferStack)

// Mock Module Stack

// Mock Module setup for testing IBC and also acts as the interchain accounts authentication module
// NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
// not replicate if you do not need to test core IBC or light clients.
mockModule := ibcmock.NewAppModule(&app.IBCKeeper.PortKeeper)

// The mock module is used for testing IBC
mockIBCModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewIBCApp(ibcmock.ModuleName, scopedIBCMockKeeper))
ibcRouter.AddRoute(ibcmock.ModuleName, mockIBCModule)

// Create IBC Router
ibcRouter := porttypes.NewRouter().
AddRoute(ibctransfertypes.ModuleName, transferStack).
AddRoute(ibcmock.ModuleName, mockIBCModule)

// Seal the IBC Router
app.IBCKeeper.SetRouter(ibcRouter)
Expand Down

0 comments on commit f5a7a74

Please sign in to comment.