Skip to content

Commit

Permalink
feat(delayedack): added query pending packets and removed FinalizePac… (
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 authored Nov 7, 2024
1 parent 7d9dd3a commit 2dd125b
Show file tree
Hide file tree
Showing 40 changed files with 2,331 additions and 580 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ replace (

require (
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869
github.com/decentrio/rollup-e2e-testing v0.0.0-20241107030935-0ab2fee3053f
github.com/dymensionxyz/dymension/v3 v3.1.0-rc03.0.20241016085626-2b8c8898058b
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241015102238-a827c3784461
github.com/decentrio/rollup-e2e-testing v0.0.0-20241101042254-a87404cf9897
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,8 @@ github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR
github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U=
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869 h1:qWpUYGOsrSC+1Vmd2TjhbsSpntvvx9PsX3AoeMunFxc=
github.com/decentrio/e2e-testing-live v0.0.0-20240718080249-ee255229c869/go.mod h1:HZNYnPwmSxkwTPjSD5yolauc1Vx1ZzKL4FFMxTq4H5Y=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241101042254-a87404cf9897 h1:kpYvC4h6tzWz4Q2XQ11/E53DIpur9zvnVmRDoExhWgw=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241101042254-a87404cf9897/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241107030935-0ab2fee3053f h1:5/3Zqa7aBRMMdVL9XuNf8eyumxxK6P67aiDezjYcvlM=
github.com/decentrio/rollup-e2e-testing v0.0.0-20241107030935-0ab2fee3053f/go.mod h1:QmBrZgZplhtgHRWC0Z7LC7TDsKuC8sDyQvZyXXaqw/c=
github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsPppp4=
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
Expand Down
136 changes: 109 additions & 27 deletions tests/admc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -156,10 +156,16 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -289,7 +295,7 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -339,10 +345,16 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -426,10 +438,16 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -535,7 +553,7 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -585,10 +603,16 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -681,10 +705,16 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -787,7 +817,7 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -833,10 +863,16 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -966,7 +1002,7 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -1016,10 +1052,16 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

txhash, err := dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

fmt.Println(txhash)
for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand Down Expand Up @@ -1100,9 +1142,17 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

_, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

Expand Down Expand Up @@ -1207,7 +1257,7 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -1257,9 +1307,17 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

_, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

Expand Down Expand Up @@ -1346,9 +1404,17 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

_, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err = dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

Expand Down Expand Up @@ -1480,7 +1546,7 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -1526,9 +1592,17 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

_, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

Expand Down Expand Up @@ -1687,7 +1761,7 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) {

// This can be used to write to the block database which will index all block data e.g. txs, msgs, events, etc.
// BlockDatabaseFile: test.DefaultBlockDatabaseFilepath(),
}, nil, "", nil, false, 780)
}, nil, "", nil, false, 1179360)
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
Expand Down Expand Up @@ -1733,9 +1807,17 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) {
require.NoError(t, err)
require.True(t, isFinalized)

_, err = dymension.GetNode().FinalizePacketsUntilHeight(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(rollappHeight))
res, err := dymension.GetNode().QueryPendingPacketsByAddress(ctx, dymensionUserAddr)
fmt.Println(res)
require.NoError(t, err)

for _, packet := range res.RollappPackets {
txhash, err := dymension.GetNode().FinalizePacket(ctx, dymensionUserAddr, rollapp1.GetChainID(), fmt.Sprint(packet.ProofHeight), fmt.Sprint(packet.Type), packet.Packet.SourceChannel, fmt.Sprint(packet.Packet.Sequence))
require.NoError(t, err)

fmt.Println(txhash)
}

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)

Expand Down
Loading

0 comments on commit 2dd125b

Please sign in to comment.