Skip to content
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
merged 23 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
758ec75
test: adding initial test boilerplate
seantking Aug 29, 2022
c3be6f3
fix: test
seantking Aug 29, 2022
84f0606
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 5, 2022
6e7275f
extend test to add token transfer
Oct 6, 2022
5ac0db1
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 6, 2022
09028ef
change to send from B to A and add test matrix
Oct 6, 2022
2c1d601
add test matrices
Oct 6, 2022
a6d7586
fix imports
Oct 6, 2022
baac64e
fix some more imports
Oct 6, 2022
0b83140
review comments
Oct 6, 2022
472e69d
compare uint64 instead of string
Oct 6, 2022
2844004
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 7, 2022
09199b6
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 10, 2022
67769c1
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
crodriguezvega Oct 13, 2022
bb1de4a
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 14, 2022
3793f09
review comments
crodriguezvega Oct 14, 2022
a0e4f2d
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 14, 2022
34055f0
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 25, 2022
a0da722
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 25, 2022
068f80d
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 26, 2022
43ea2f4
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 26, 2022
25a6b76
fix test
Oct 26, 2022
efcf84a
Merge branch 'main' into sean/issue#2121-03-connection-param-e2e
Oct 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/e2e-manual-simd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
options:
- TestTransferTestSuite
- TestIncentivizedTransferTestSuite
- TestConnectionTestSuite
chain-image:
description: 'The image to use for chain A'
required: true
Expand Down
89 changes: 89 additions & 0 deletions e2e/tests/core/03-connection/connection_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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 03-connection
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
func (s *ConnectionTestSuite) QueryMaxExpectedTimePerBlockParam(ctx context.Context, chain ibc.Chain) uint64 {
queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient
res, err := queryClient.Params(ctx, &paramsproposaltypes.QueryParamsRequest{
Subspace: "ibc",
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
Key: string(connectiontypes.KeyMaxExpectedTimePerBlock),
})
s.Require().NoError(err)

// removing additional strings that are used for amino
delay := strings.ReplaceAll(res.Param.Value, "\"", "")
Copy link
Contributor Author

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

Copy link
Contributor

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

time, err := strconv.ParseUint(delay, 10, 64)
s.Require().NoError(err)

return time
}

// TestMaxExpectedTimePerBlock tests changing the MaxExpectedTimePerBlock param using a governance proposal
func (s *ConnectionTestSuite) TestMaxExpectedTimePerBlock() {
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
t := s.T()
ctx := context.TODO()

_, _ = s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions())
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
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 set to the default of 30 seconds", func(t *testing.T) {
expectedDelay := fmt.Sprintf("\"%d\"", 30*time.Second)
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
delay := fmt.Sprintf("\"%d\"", s.QueryMaxExpectedTimePerBlockParam(ctx, chainA))
s.Require().Equal(expectedDelay, delay)
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
})

t.Run("change the delay to 60 seconds", func(t *testing.T) {
delay := fmt.Sprintf("\"%d\"", 60*time.Second)
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange("ibc", string(connectiontypes.KeyMaxExpectedTimePerBlock), delay),
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
}

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 := fmt.Sprintf("\"%d\"", 60*time.Second)
delay := s.QueryMaxExpectedTimePerBlockParam(ctx, chainA)
s.Require().Equal(expectedDelay, fmt.Sprintf("\"%d\"", delay))
})
}
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved

// 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
}
}