Skip to content

Commit

Permalink
Merge branch 'main' into nhan/new_register_erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 committed Dec 16, 2024
2 parents 849143f + 673219e commit 522e1af
Show file tree
Hide file tree
Showing 36 changed files with 3,925 additions and 1,675 deletions.
104 changes: 104 additions & 0 deletions tests/admc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -304,6 +317,19 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -572,6 +598,19 @@ func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -846,6 +885,19 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -1036,6 +1088,19 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -1301,6 +1366,19 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -1600,6 +1678,19 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -1820,6 +1911,19 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down
123 changes: 120 additions & 3 deletions tests/automated_denommetadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,32 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet1, found := r1.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

wallet2, found := r2.GetWallet(rollapp2.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir()
require.NoError(t, err)
keyPath2 := keyDir2 + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()})
require.NoError(t, err)

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

_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath)
CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath)
Expand Down Expand Up @@ -477,6 +503,19 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet1, found := r1.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath)

Expand Down Expand Up @@ -788,6 +827,32 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet1, found := r1.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

wallet2, found := r2.GetWallet(rollapp2.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir()
require.NoError(t, err)
keyPath2 := keyDir2 + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()})
require.NoError(t, err)

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

_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath)
CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath)
Expand Down Expand Up @@ -1127,6 +1192,32 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet1, found := r1.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

wallet2, found := r2.GetWallet(rollapp2.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir()
require.NoError(t, err)
keyPath2 := keyDir2 + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()})
require.NoError(t, err)

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

_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, ibcPath)
CreateChannel(ctx, t, r3, eRep, dymension.CosmosChain, gaia, ibcPath)
Expand Down Expand Up @@ -1396,6 +1487,19 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -1609,6 +1713,19 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)

// Create some user accounts on both chains
Expand Down Expand Up @@ -1696,7 +1813,7 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) {
require.NoError(t, err)

// Assert balance was updated on the hub
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, zeroBal)
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, math.NewInt(9999999999).MulRaw(1000000000000))

err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1)
require.NoError(t, err)
Expand All @@ -1705,8 +1822,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) {
dymensionTokenDenom := transfertypes.GetPrefixedDenom(channel.Counterparty.PortID, channel.Counterparty.ChannelID, dymension.Config().Denom)
dymensionIBCDenom := transfertypes.ParseDenomTrace(dymensionTokenDenom).IBCDenom()

testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, zeroBal)
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, walletAmount)
testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, math.NewInt(9999999999).MulRaw(1000000000000))
testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, math.NewInt(1000000000000))

// Rollapp record on the hub updated with new token metadata (”adym”)
_, err = dymension.Validators[0].QueryDenomMetadata(ctx, "adym")
Expand Down
26 changes: 26 additions & 0 deletions tests/bridging_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,32 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) {
}, nil, "", nil, false, 1179360, true)
require.NoError(t, err)

wallet1, found := r1.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

wallet2, found := r2.GetWallet(rollapp2.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

keyDir2 := dymension.GetRollApps()[1].GetSequencerKeyDir()
require.NoError(t, err)
keyPath2 := keyDir2 + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet1.FormattedAddress()})
require.NoError(t, err)

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

_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath2, []string{wallet2.FormattedAddress()})
require.NoError(t, err)

CreateChannel(ctx, t, r1, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, rollapp2.CosmosChain, anotherIbcPath)

Expand Down
13 changes: 13 additions & 0 deletions tests/canonical_light_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,19 @@ func TestIBCTransferRA_3rdSameChainID_EVM(t *testing.T) {
_ = ic.Close()
})

wallet, found := r.GetWallet(rollapp1.Config().ChainID)
require.True(t, found)

keyDir := dymension.GetRollApps()[0].GetSequencerKeyDir()
keyPath := keyDir + "/sequencer_keys"

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

//Update white listed relayers
_, err = dymension.GetNode().UpdateWhitelistedRelayers(ctx, "sequencer", keyPath, []string{wallet.FormattedAddress()})
require.NoError(t, err)

// create ibc path between dymension and gaia, and between dymension and rollapp1
CreateChannel(ctx, t, r, eRep, dymension.CosmosChain, rollapp1.CosmosChain, ibcPath)
CreateChannel(ctx, t, r2, eRep, dymension.CosmosChain, gaia, anotherIbcPath)
Expand Down
Loading

0 comments on commit 522e1af

Please sign in to comment.