-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: 03-connection e2e test param change #2139
Merged
crodriguezvega
merged 23 commits into
main
from
sean/issue#2121-03-connection-param-e2e
Oct 27, 2022
Merged
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
758ec75
test: adding initial test boilerplate
seantking c3be6f3
fix: test
seantking 84f0606
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
6e7275f
extend test to add token transfer
5ac0db1
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
09028ef
change to send from B to A and add test matrix
2c1d601
add test matrices
a6d7586
fix imports
baac64e
fix some more imports
0b83140
review comments
472e69d
compare uint64 instead of string
2844004
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
09199b6
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
67769c1
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
crodriguezvega bb1de4a
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
3793f09
review comments
crodriguezvega a0e4f2d
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
34055f0
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
a0da722
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
068f80d
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
43ea2f4
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
25a6b76
fix test
efcf84a
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
.github/compatibility-test-matrices/release-v5.0.x/connection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [ | ||
"TestMaxExpectedTimePerBlockParam" | ||
], | ||
"chain-binary": ["simd"], | ||
"chain-image": ["ghcr.io/cosmos/ibc-go-simd"] | ||
} |
10 changes: 10 additions & 0 deletions
10
.github/compatibility-test-matrices/release-v6.0.x/connection.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [ | ||
"TestMaxExpectedTimePerBlockParam" | ||
], | ||
"chain-binary": ["simd"], | ||
"chain-image": ["ghcr.io/cosmos/ibc-go-simd"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package connection | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
"testing" | ||
"time" | ||
|
||
paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal" | ||
"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" | ||
"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" | ||
) | ||
|
||
func TestConnectionTestSuite(t *testing.T) { | ||
suite.Run(t, new(ConnectionTestSuite)) | ||
} | ||
|
||
type ConnectionTestSuite struct { | ||
testsuite.E2ETestSuite | ||
} | ||
|
||
// 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{ | ||
Subspace: host.ModuleName, | ||
Key: string(connectiontypes.KeyMaxExpectedTimePerBlock), | ||
}) | ||
s.Require().NoError(err) | ||
|
||
// 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) | ||
|
||
return time | ||
} | ||
|
||
// TestMaxExpectedTimePerBlockParam tests changing the MaxExpectedTimePerBlock param using a governance proposal | ||
func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlockParam() { | ||
t := s.T() | ||
ctx := context.TODO() | ||
|
||
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) | ||
chainA, chainB := s.GetChains() | ||
|
||
chainBDenom := chainB.Config().Denom | ||
chainAIBCToken := testsuite.GetIBCToken(chainBDenom, channelA.PortID, channelA.ChannelID) | ||
|
||
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") | ||
|
||
t.Run("ensure delay is set to the default of 30 seconds", func(t *testing.T) { | ||
expectedDelay := uint64(30 * time.Second) | ||
delay := 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"`, 1*time.Minute) | ||
changes := []paramsproposaltypes.ParamChange{ | ||
paramsproposaltypes.NewParamChange(host.ModuleName, string(connectiontypes.KeyMaxExpectedTimePerBlock), delay), | ||
} | ||
|
||
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) { | ||
expectedDelay := uint64(1 * time.Minute) | ||
delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA) | ||
s.Require().Equal(expectedDelay, delay) | ||
}) | ||
|
||
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.GetChainBNativeBalance(ctx, chainBWallet) | ||
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) | ||
}) | ||
|
||
t.Run("packets are relayed", func(t *testing.T) { | ||
s.AssertPacketRelayed(ctx, chainA, channelA.Counterparty.PortID, channelA.Counterparty.ChannelID, 1) | ||
|
||
actualBalance, err := chainA.GetBalance(ctx, chainAAddress, chainAIBCToken.IBCDenom()) | ||
s.Require().NoError(err) | ||
|
||
expected := testvalues.IBCTransferAmount | ||
s.Require().Equal(expected, actualBalance) | ||
}) | ||
|
||
t.Run("stop relayer", func(t *testing.T) { | ||
s.StopRelayer(ctx, relayer) | ||
}) | ||
}) | ||
} | ||
|
||
// 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 | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't exactly sure why the Value is double wrapped in quotes but based on an error I received when I don't add them it is something to do with the legacy amino implementation.
cc: @colin-axner
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. I'm not sure either (didn't realized this was the case). I guess we can fix this during param migrations