From 758ec7580507bd5ff83320373cc66f61107baf0a Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 29 Aug 2022 14:45:48 +0200 Subject: [PATCH 01/11] test: adding initial test boilerplate --- .github/workflows/e2e-manual-simd.yaml | 1 + .../core/03-connection/connection_test.go | 88 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 e2e/tests/core/03-connection/connection_test.go diff --git a/.github/workflows/e2e-manual-simd.yaml b/.github/workflows/e2e-manual-simd.yaml index 6ff0fc358d1..530dec2432a 100644 --- a/.github/workflows/e2e-manual-simd.yaml +++ b/.github/workflows/e2e-manual-simd.yaml @@ -12,6 +12,7 @@ on: options: - TestTransferTestSuite - TestIncentivizedTransferTestSuite + - TestConnectionTestSuite chain-image: description: 'The image to use for chain A' required: true diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go new file mode 100644 index 00000000000..0033e2e1dbb --- /dev/null +++ b/e2e/tests/core/03-connection/connection_test.go @@ -0,0 +1,88 @@ +package connection + +import ( + "context" + "fmt" + "strconv" + "strings" + "testing" + "time" + + paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" + "github.com/strangelove-ventures/ibctest/ibc" + "github.com/strangelove-ventures/ibctest/test" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/ibc-go/e2e/testsuite" + "github.com/cosmos/ibc-go/e2e/testvalues" + transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" + connectiontypes "github.com/cosmos/ibc-go/v5/modules/core/03-connection/types" + ibctesting "github.com/cosmos/ibc-go/v5/testing" +) + +func TestConnectionTestSuite(t *testing.T) { + suite.Run(t, new(ConnectionTestSuite)) +} + +type ConnectionTestSuite struct { + testsuite.E2ETestSuite +} + +// QueryConnectionEnabledParam queries the on-chain connection enabled param for the connection module +func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 { + queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient + res, err := queryClient.Params(ctx, ¶msproposaltypes.QueryParamsRequest{ + Subspace: "ibc", + Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), + }) + s.Require().NoError(err) + + // TODO: investigate why Value is double wrapped in qoutes + delay := strings.ReplaceAll(res.Param.Value, "\"", "") + time, err := strconv.ParseUint(delay, 10, 64) + s.Require().NoError(err) + + return time +} + +// TestMaxExpectedTimePerBlock tests changing the MaxExpectedTimePerBlock param +func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { + t := s.T() + ctx := context.TODO() + + _, _ = s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) + chainA, chainB := s.GetChains() + + chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + + s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") + + t.Run("ensure delay is currenly not set to 0", func(t *testing.T) { + delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) + s.Require().NotZero(delay) + }) + + t.Run("change the delay to 60 seconds", func(t *testing.T) { + changes := []paramsproposaltypes.ParamChange{ + paramsproposaltypes.NewParamChange(connectiontypes.StoreKey, string(connectiontypes.KeyMaxExpectedTimePerBlock), fmt.Sprint(60*time.Second)), + } + + proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes) + s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal) + }) + + t.Run("validate the param was successfully changed", func(t *testing.T) { + delay := s.QueryTransferSendEnabledParam(ctx, chainA) + s.Require().Equal(fmt.Sprint(60*time.Second), delay) + }) +} + +// TODO: remove +// transferChannelOptions configures both of the chains to have non-incentivized transfer channels. +func transferChannelOptions() func(options *ibc.CreateChannelOptions) { + return func(opts *ibc.CreateChannelOptions) { + opts.Version = transfertypes.Version + opts.SourcePortName = transfertypes.PortID + opts.DestPortName = transfertypes.PortID + } +} From c3be6f3103cb7bfae3b72780452b0243f2ca8efe Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 29 Aug 2022 18:21:15 +0200 Subject: [PATCH 02/11] fix: test --- .../core/03-connection/connection_test.go | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 0033e2e1dbb..7b6a3238011 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -28,7 +28,7 @@ type ConnectionTestSuite struct { testsuite.E2ETestSuite } -// QueryConnectionEnabledParam queries the on-chain connection enabled param for the connection module +// QueryConnectionEnabledParam queries the on-chain connection enabled param for 03-connection func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 { queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient res, err := queryClient.Params(ctx, ¶msproposaltypes.QueryParamsRequest{ @@ -37,7 +37,7 @@ func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Cont }) s.Require().NoError(err) - // TODO: investigate why Value is double wrapped in qoutes + // removing additional strings that are used for amino delay := strings.ReplaceAll(res.Param.Value, "\"", "") time, err := strconv.ParseUint(delay, 10, 64) s.Require().NoError(err) @@ -45,26 +45,27 @@ func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Cont return time } -// TestMaxExpectedTimePerBlock tests changing the MaxExpectedTimePerBlock param +// TestMaxExpectedTimePerBlock tests changing the MaxExpectedTimePerBlock param using a governance proposal func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { t := s.T() ctx := context.TODO() _, _ = s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) chainA, chainB := s.GetChains() - chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") - t.Run("ensure delay is currenly not set to 0", func(t *testing.T) { - delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) - s.Require().NotZero(delay) + t.Run("ensure delay is set to the default of 30 seconds", func(t *testing.T) { + expectedDelay := fmt.Sprintf("\"%d\"", 30*time.Second) + delay := fmt.Sprintf("\"%d\"", s.QueryMaxExpectedTimePerBlockParam(ctx, chainA)) + s.Require().Equal(expectedDelay, delay) }) t.Run("change the delay to 60 seconds", func(t *testing.T) { + delay := fmt.Sprintf("\"%d\"", 60*time.Second) changes := []paramsproposaltypes.ParamChange{ - paramsproposaltypes.NewParamChange(connectiontypes.StoreKey, string(connectiontypes.KeyMaxExpectedTimePerBlock), fmt.Sprint(60*time.Second)), + paramsproposaltypes.NewParamChange("ibc", string(connectiontypes.KeyMaxExpectedTimePerBlock), delay), } proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes) @@ -72,12 +73,12 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { }) t.Run("validate the param was successfully changed", func(t *testing.T) { - delay := s.QueryTransferSendEnabledParam(ctx, chainA) - s.Require().Equal(fmt.Sprint(60*time.Second), delay) + expectedDelay := fmt.Sprintf("\"%d\"", 60*time.Second) + delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) + s.Require().Equal(expectedDelay, fmt.Sprintf("\"%d\"", delay)) }) } -// TODO: remove // transferChannelOptions configures both of the chains to have non-incentivized transfer channels. func transferChannelOptions() func(options *ibc.CreateChannelOptions) { return func(opts *ibc.CreateChannelOptions) { From 6e7275ff984abac74d8760f548f57a9556513d9f Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 16:27:50 +0200 Subject: [PATCH 03/11] extend test to add token transfer --- .../core/03-connection/connection_test.go | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 7b6a3238011..147c9e0e1c3 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -50,9 +50,16 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { t := s.T() ctx := context.TODO() - _, _ = s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) + relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) chainA, chainB := s.GetChains() + + chainADenom := chainA.Config().Denom + chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) + chainAAddress := chainAWallet.Bech32Address(chainA.Config().Bech32Prefix) + + chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount) + chainBAddress := chainBWallet.Bech32Address(chainB.Config().Bech32Prefix) s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") @@ -77,6 +84,36 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) s.Require().Equal(expectedDelay, fmt.Sprintf("\"%d\"", delay)) }) + + t.Run("native IBC token transfer from chainA to chainB, sender is source of tokens", func(t *testing.T) { + transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0) + s.Require().NoError(err) + s.AssertValidTxResponse(transferTxResp) + }) + + t.Run("tokens are escrowed", func(t *testing.T) { + actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) + s.Require().NoError(err) + + expected := testvalues.StartingTokenAmount - testvalues.IBCTransferAmount + s.Require().Equal(expected, actualBalance) + }) + + t.Run("start relayer", func(t *testing.T) { + s.StartRelayer(relayer) + }) + + chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) + + t.Run("packets are relayed", func(t *testing.T) { + s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) + + actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom()) + s.Require().NoError(err) + + expected := testvalues.IBCTransferAmount + s.Require().Equal(expected, actualBalance) + }) } // transferChannelOptions configures both of the chains to have non-incentivized transfer channels. From 09028efc3bf854ee6b23cc6720c8a3f7c89788a7 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 21:16:17 +0200 Subject: [PATCH 04/11] change to send from B to A and add test matrix --- .../test-matricies/main/test-matrix.json | 54 +++++++++++++++++++ .../core/03-connection/connection_test.go | 49 +++++++++-------- 2 files changed, 81 insertions(+), 22 deletions(-) diff --git a/e2e/scripts/test-matricies/main/test-matrix.json b/e2e/scripts/test-matricies/main/test-matrix.json index c1c8bb441dd..72f287193de 100644 --- a/e2e/scripts/test-matricies/main/test-matrix.json +++ b/e2e/scripts/test-matricies/main/test-matrix.json @@ -170,5 +170,59 @@ "chain-b-tag": "v0.2.3" } ] + }, + { + "test-entry-point": "TestConnectionTestSuite", + "chain-binary": "simd", + "tests": [ + { + "chain-a-tag": "main", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v5.0.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v4.1.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v3.3.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v3.2.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v3.1.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v3.0.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v2.4.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v2.3.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v2.2.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v2.1.0", + "chain-b-tag": "main" + }, + { + "chain-a-tag": "v2.0.0", + "chain-b-tag": "main" + } + ] } ] diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 147c9e0e1c3..37cac81b997 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -53,7 +53,8 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) chainA, chainB := s.GetChains() - chainADenom := chainA.Config().Denom + chainBDenom = chainB.Config().Denom + chainAIBCToken = testsuite.GetIBCToken(chainBDenom, channelA.PortID, channelA.ChannelID) // IBC token sent to chainA chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) chainAAddress := chainAWallet.Bech32Address(chainA.Config().Bech32Prefix) @@ -85,34 +86,38 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { s.Require().Equal(expectedDelay, fmt.Sprintf("\"%d\"", delay)) }) - t.Run("native IBC token transfer from chainA to chainB, sender is source of tokens", func(t *testing.T) { - transferTxResp, err := s.Transfer(ctx, chainA, chainAWallet, channelA.PortID, channelA.ChannelID, testvalues.DefaultTransferAmount(chainADenom), chainAAddress, chainBAddress, s.GetTimeoutHeight(ctx, chainB), 0) - s.Require().NoError(err) - s.AssertValidTxResponse(transferTxResp) - }) + t.Run("ensure packets can be received, send from chainB to chainA", func(t *testing.T) { + t.Run("send tokens from chainB to chainA", func(t *testing.T) { + transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0) + s.Require().NoError(err) + s.AssertValidTxResponse(transferTxResp) + }) - t.Run("tokens are escrowed", func(t *testing.T) { - actualBalance, err := s.GetChainANativeBalance(ctx, chainAWallet) - s.Require().NoError(err) + t.Run("tokens are escrowed", func(t *testing.T) { + actualBalance, err := s.GetChainBNativeBalance(ctx, chainBWallet) + s.Require().NoError(err) - expected := testvalues.StartingTokenAmount - testvalues.IBCTransferAmount - s.Require().Equal(expected, actualBalance) - }) + expected := testvalues.StartingTokenAmount - testvalues.IBCTransferAmount + s.Require().Equal(expected, actualBalance) + }) - t.Run("start relayer", func(t *testing.T) { - s.StartRelayer(relayer) - }) + t.Run("start relayer", func(t *testing.T) { + s.StartRelayer(relayer) + }) - chainBIBCToken := testsuite.GetIBCToken(chainADenom, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID) + t.Run("packets are relayed", func(t *testing.T) { + s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) - t.Run("packets are relayed", func(t *testing.T) { - s.AssertPacketRelayed(ctx, chainA, channelA.PortID, channelA.ChannelID, 1) + actualBalance, err := chainA.GetBalance(ctx, chainAAddress, chainAIBCToken.IBCDenom()) + s.Require().NoError(err) - actualBalance, err := chainB.GetBalance(ctx, chainBAddress, chainBIBCToken.IBCDenom()) - s.Require().NoError(err) + expected := testvalues.IBCTransferAmount + s.Require().Equal(expected, actualBalance) + }) - expected := testvalues.IBCTransferAmount - s.Require().Equal(expected, actualBalance) + t.Run("stop relayer", func(t *testing.T) { + s.StopRelayer(ctx, relayer) + }) }) } From 2c1d601aadec3ea4cc6a379bb32b07f7faf43ea5 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 21:16:30 +0200 Subject: [PATCH 05/11] add test matrices --- .../release-v5.0.x/connection.json | 10 ++++++++++ .../release-v6.0.x/connection.json | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 .github/compatibility-test-matrices/release-v5.0.x/connection.json create mode 100644 .github/compatibility-test-matrices/release-v6.0.x/connection.json diff --git a/.github/compatibility-test-matrices/release-v5.0.x/connection.json b/.github/compatibility-test-matrices/release-v5.0.x/connection.json new file mode 100644 index 00000000000..b0c10740026 --- /dev/null +++ b/.github/compatibility-test-matrices/release-v5.0.x/connection.json @@ -0,0 +1,10 @@ +{ + "chain-a": ["release-v5.0.x", "v4.1.0", "v3.3.0", "v2.4.0"], + "chain-b": ["release-v5.0.x", "v4.1.0", "v3.3.0", "v2.4.0"], + "entrypoint": ["TestConnectionTestSuite"], + "test": [ + "TestMaxExpectedTimePerBlock" + ], + "chain-binary": ["simd"], + "chain-image": ["ghcr.io/cosmos/ibc-go-simd"] +} diff --git a/.github/compatibility-test-matrices/release-v6.0.x/connection.json b/.github/compatibility-test-matrices/release-v6.0.x/connection.json new file mode 100644 index 00000000000..02d32579d5f --- /dev/null +++ b/.github/compatibility-test-matrices/release-v6.0.x/connection.json @@ -0,0 +1,10 @@ +{ + "chain-a": ["release-v6.0.x", "v5.0.0", "v4.1.0", "v3.3.0", "v2.4.0"], + "chain-b": ["release-v6.0.x", "v5.0.0", "v4.1.0", "v3.3.0", "v2.4.0"], + "entrypoint": ["TestConnectionTestSuite"], + "test": [ + "TestMaxExpectedTimePerBlock" + ], + "chain-binary": ["simd"], + "chain-image": ["ghcr.io/cosmos/ibc-go-simd"] +} From a6d7586c0dc047427b0c7be5f4ba375ca7d99249 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 21:24:39 +0200 Subject: [PATCH 06/11] fix imports --- e2e/tests/core/03-connection/connection_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 37cac81b997..449a92187ad 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -15,9 +15,9 @@ import ( "github.com/cosmos/ibc-go/e2e/testsuite" "github.com/cosmos/ibc-go/e2e/testvalues" - transfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types" - connectiontypes "github.com/cosmos/ibc-go/v5/modules/core/03-connection/types" - ibctesting "github.com/cosmos/ibc-go/v5/testing" + transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" + connectiontypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types" + ibctesting "github.com/cosmos/ibc-go/v6/testing" ) func TestConnectionTestSuite(t *testing.T) { From baac64e06faf2be29b92acb94b4aaca9e6fd1cf9 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 21:33:35 +0200 Subject: [PATCH 07/11] fix some more imports --- e2e/tests/core/03-connection/connection_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 449a92187ad..774f304f951 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -9,8 +9,8 @@ import ( "time" paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - "github.com/strangelove-ventures/ibctest/ibc" - "github.com/strangelove-ventures/ibctest/test" + "github.com/strangelove-ventures/ibctest/v6/ibc" + "github.com/strangelove-ventures/ibctest/v6/test" "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/e2e/testsuite" From 0b831406e4afd3241436d713bde2d175a703c62a Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 21:51:07 +0200 Subject: [PATCH 08/11] review comments --- e2e/tests/core/03-connection/connection_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 774f304f951..137fdba1316 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -28,7 +28,7 @@ type ConnectionTestSuite struct { testsuite.E2ETestSuite } -// QueryConnectionEnabledParam queries the on-chain connection enabled param for 03-connection +// QueryMaxExpectedTimePerBlockParam queries the on-chain max expected time per block param for 03-connection func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 { queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient res, err := queryClient.Params(ctx, ¶msproposaltypes.QueryParamsRequest{ @@ -53,8 +53,8 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) chainA, chainB := s.GetChains() - chainBDenom = chainB.Config().Denom - chainAIBCToken = testsuite.GetIBCToken(chainBDenom, channelA.PortID, channelA.ChannelID) // IBC token sent to chainA + chainBDenom := chainB.Config().Denom + chainAIBCToken := testsuite.GetIBCToken(chainBDenom, channelA.PortID, channelA.ChannelID) chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) chainAAddress := chainAWallet.Bech32Address(chainA.Config().Bech32Prefix) @@ -65,13 +65,13 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") t.Run("ensure delay is set to the default of 30 seconds", func(t *testing.T) { - expectedDelay := fmt.Sprintf("\"%d\"", 30*time.Second) - delay := fmt.Sprintf("\"%d\"", s.QueryMaxExpectedTimePerBlockParam(ctx, chainA)) + expectedDelay := fmt.Sprintf(`"%d"`, 30*time.Second) + delay := fmt.Sprintf(`"%d"`, s.QueryMaxExpectedTimePerBlockParam(ctx, chainA)) s.Require().Equal(expectedDelay, delay) }) t.Run("change the delay to 60 seconds", func(t *testing.T) { - delay := fmt.Sprintf("\"%d\"", 60*time.Second) + delay := fmt.Sprintf(`"%d"`, 1*time.Minute) changes := []paramsproposaltypes.ParamChange{ paramsproposaltypes.NewParamChange("ibc", string(connectiontypes.KeyMaxExpectedTimePerBlock), delay), } From 472e69ddc96e93adca6bea1c5dadcaa3355fc829 Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Thu, 6 Oct 2022 22:17:23 +0200 Subject: [PATCH 09/11] compare uint64 instead of string --- e2e/tests/core/03-connection/connection_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index 137fdba1316..ee20c41a55f 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -65,8 +65,8 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") t.Run("ensure delay is set to the default of 30 seconds", func(t *testing.T) { - expectedDelay := fmt.Sprintf(`"%d"`, 30*time.Second) - delay := fmt.Sprintf(`"%d"`, s.QueryMaxExpectedTimePerBlockParam(ctx, chainA)) + expectedDelay := uint64(30 * time.Second) + delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) s.Require().Equal(expectedDelay, delay) }) @@ -81,9 +81,9 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { }) t.Run("validate the param was successfully changed", func(t *testing.T) { - expectedDelay := fmt.Sprintf("\"%d\"", 60*time.Second) + expectedDelay := uint64(1 * time.Minute) delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) - s.Require().Equal(expectedDelay, fmt.Sprintf("\"%d\"", delay)) + s.Require().Equal(expectedDelay, delay) }) t.Run("ensure packets can be received, send from chainB to chainA", func(t *testing.T) { From 3793f09a6ad4e3e8e4043849a0864edb631c6957 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Fri, 14 Oct 2022 11:07:29 +0200 Subject: [PATCH 10/11] review comments --- .../release-v5.0.x/connection.json | 2 +- .../release-v6.0.x/connection.json | 2 +- e2e/tests/core/03-connection/connection_test.go | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/compatibility-test-matrices/release-v5.0.x/connection.json b/.github/compatibility-test-matrices/release-v5.0.x/connection.json index b0c10740026..4d71fc4119a 100644 --- a/.github/compatibility-test-matrices/release-v5.0.x/connection.json +++ b/.github/compatibility-test-matrices/release-v5.0.x/connection.json @@ -3,7 +3,7 @@ "chain-b": ["release-v5.0.x", "v4.1.0", "v3.3.0", "v2.4.0"], "entrypoint": ["TestConnectionTestSuite"], "test": [ - "TestMaxExpectedTimePerBlock" + "TestMaxExpectedTimePerBlockParam" ], "chain-binary": ["simd"], "chain-image": ["ghcr.io/cosmos/ibc-go-simd"] diff --git a/.github/compatibility-test-matrices/release-v6.0.x/connection.json b/.github/compatibility-test-matrices/release-v6.0.x/connection.json index 02d32579d5f..7e3624a5f50 100644 --- a/.github/compatibility-test-matrices/release-v6.0.x/connection.json +++ b/.github/compatibility-test-matrices/release-v6.0.x/connection.json @@ -3,7 +3,7 @@ "chain-b": ["release-v6.0.x", "v5.0.0", "v4.1.0", "v3.3.0", "v2.4.0"], "entrypoint": ["TestConnectionTestSuite"], "test": [ - "TestMaxExpectedTimePerBlock" + "TestMaxExpectedTimePerBlockParam" ], "chain-binary": ["simd"], "chain-image": ["ghcr.io/cosmos/ibc-go-simd"] diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index ee20c41a55f..b4f855b9221 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/ibc-go/e2e/testvalues" transfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types" connectiontypes "github.com/cosmos/ibc-go/v6/modules/core/03-connection/types" + host "github.com/cosmos/ibc-go/v6/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v6/testing" ) @@ -32,7 +33,7 @@ type ConnectionTestSuite struct { func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 { queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient res, err := queryClient.Params(ctx, ¶msproposaltypes.QueryParamsRequest{ - Subspace: "ibc", + Subspace: host.ModuleName, Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), }) s.Require().NoError(err) @@ -45,8 +46,8 @@ func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Cont return time } -// TestMaxExpectedTimePerBlock tests changing the MaxExpectedTimePerBlock param using a governance proposal -func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { +// TestMaxExpectedTimePerBlockParam tests changing the MaxExpectedTimePerBlock param using a governance proposal +func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { t := s.T() ctx := context.TODO() @@ -73,7 +74,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() { t.Run("change the delay to 60 seconds", func(t *testing.T) { delay := fmt.Sprintf(`"%d"`, 1*time.Minute) changes := []paramsproposaltypes.ParamChange{ - paramsproposaltypes.NewParamChange("ibc", string(connectiontypes.KeyMaxExpectedTimePerBlock), delay), + paramsproposaltypes.NewParamChange(host.ModuleName, string(connectiontypes.KeyMaxExpectedTimePerBlock), delay), } proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes) From 25a6b763741c2c7306d9451ef0a9a19d39a6206c Mon Sep 17 00:00:00 2001 From: crodriguezvega Date: Wed, 26 Oct 2022 23:01:11 +0200 Subject: [PATCH 11/11] fix test --- e2e/tests/core/03-connection/connection_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/core/03-connection/connection_test.go b/e2e/tests/core/03-connection/connection_test.go index b4f855b9221..3e962e37e09 100644 --- a/e2e/tests/core/03-connection/connection_test.go +++ b/e2e/tests/core/03-connection/connection_test.go @@ -89,7 +89,7 @@ func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { t.Run("ensure packets can be received, send from chainB to chainA", func(t *testing.T) { t.Run("send tokens from chainB to chainA", func(t *testing.T) { - transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0) + transferTxResp, err := s.Transfer(ctx, chainB, chainBWallet, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, testvalues.DefaultTransferAmount(chainBDenom), chainBAddress, chainAAddress, s.GetTimeoutHeight(ctx, chainA), 0, "") s.Require().NoError(err) s.AssertValidTxResponse(transferTxResp) })