-
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
e2e: add client recovery proposal test #2130
Merged
Merged
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2f7a71e
add scaffolding
colin-axner 0aca07e
continue scaffolding
colin-axner 14678db
Merge branch 'main' of github.com:cosmos/ibc-go into colin/1965-e2e-c…
colin-axner 35a8a78
add client recovery proposal test
colin-axner 70fcd8a
generate a new path when creating clients
colin-axner c81598f
Merge branch 'main' of github.com:cosmos/ibc-go into colin/1965-e2e-c…
colin-axner 000b56d
apply e2e restructure
colin-axner 69fa664
Update e2e/testsuite/testsuite.go
colin-axner d8b426d
bump relayer version to v2.0.0
colin-axner 4604820
Merge branch 'main' into colin/1965-e2e-client-updateproposal
colin-axner f7df074
Merge branch 'main' into colin/1965-e2e-client-updateproposal
colin-axner 7a81543
Merge branch 'main' into colin/1965-e2e-client-updateproposal
colin-axner c5e103a
Merge branch 'main' into colin/1965-e2e-client-updateproposal
colin-axner 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
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,110 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"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" | ||
clienttypes "github.com/cosmos/ibc-go/v5/modules/core/02-client/types" | ||
ibcexported "github.com/cosmos/ibc-go/v5/modules/core/exported" | ||
ibctesting "github.com/cosmos/ibc-go/v5/testing" | ||
) | ||
|
||
func TestClientTestSuite(t *testing.T) { | ||
suite.Run(t, new(ClientTestSuite)) | ||
} | ||
|
||
type ClientTestSuite struct { | ||
testsuite.E2ETestSuite | ||
} | ||
|
||
// Status queries the current status of the client | ||
func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID string) (string, error) { | ||
queryClient := s.GetChainGRCPClients(chain).ClientQueryClient | ||
res, err := queryClient.ClientStatus(ctx, &clienttypes.QueryClientStatusRequest{ | ||
ClientId: clientID, | ||
}) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return res.Status, nil | ||
} | ||
|
||
func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() { | ||
t := s.T() | ||
ctx := context.TODO() | ||
|
||
var ( | ||
relayer ibc.Relayer | ||
subjectClientID string | ||
substituteClientID string | ||
badTrustingPeriod = time.Duration(time.Second) | ||
) | ||
|
||
t.Run("create substitute client with correct trusting period", func(t *testing.T) { | ||
relayer, _ = s.SetupChainsRelayerAndChannel(ctx, transferChannelOptions()) | ||
|
||
// TODO: update when client identifier created is accessible | ||
// currently assumes first client is 07-tendermint-0 | ||
substituteClientID = clienttypes.FormatClientIdentifier(ibcexported.Tendermint, 0) | ||
}) | ||
|
||
chainA, chainB := s.GetChains() | ||
chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount) | ||
|
||
t.Run("create subject client with bad trusting period", func(t *testing.T) { | ||
createClientOptions := ibc.CreateClientOptions{ | ||
TrustingPeriod: badTrustingPeriod.String(), | ||
} | ||
|
||
s.SetupClients(ctx, relayer, createClientOptions) | ||
|
||
// TODO: update when client identifier created is accessible | ||
// currently assumes second client is 07-tendermint-1 | ||
subjectClientID = clienttypes.FormatClientIdentifier(ibcexported.Tendermint, 1) | ||
}) | ||
|
||
time.Sleep(badTrustingPeriod) | ||
|
||
s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks") | ||
|
||
t.Run("check status of each client", func(t *testing.T) { | ||
t.Run("substitute should be active", func(t *testing.T) { | ||
status, err := s.Status(ctx, chainA, substituteClientID) | ||
s.Require().NoError(err) | ||
s.Require().Equal(ibcexported.Active.String(), status) | ||
}) | ||
|
||
t.Run("subject should be expired", func(t *testing.T) { | ||
status, err := s.Status(ctx, chainA, subjectClientID) | ||
s.Require().NoError(err) | ||
s.Require().Equal(ibcexported.Expired.String(), status) | ||
}) | ||
}) | ||
|
||
t.Run("pass client update proposal", func(t *testing.T) { | ||
proposal := clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, subjectClientID, substituteClientID) | ||
s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal) | ||
}) | ||
|
||
t.Run("check status of each client", func(t *testing.T) { | ||
t.Run("substitute should be active", func(t *testing.T) { | ||
status, err := s.Status(ctx, chainA, substituteClientID) | ||
s.Require().NoError(err) | ||
s.Require().Equal(ibcexported.Active.String(), status) | ||
}) | ||
|
||
t.Run("subject should be active", func(t *testing.T) { | ||
status, err := s.Status(ctx, chainA, subjectClientID) | ||
s.Require().NoError(err) | ||
s.Require().Equal(ibcexported.Active.String(), status) | ||
}) | ||
}) | ||
} |
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
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
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 think this is currently not working. My guess is it is no-oping because a client already exists for the given path name. I think we need to generate/add a path for every client/connection/channel (aka endpoint) stack. My vote would be to add the endpoint type and when you call NewEndpoint, it adds the ibctest path name
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.
Soo looks like you're right, that new client is not being created.
The easy solution here is to wire up the
--override
flag in ibctest for the relayersrly tx clients --override <path>
command.The client is not begin created b/c in the relayer config, the client already exists so it does not create a new client.
This is what the
--override
flag is used for; to create a new client even though the config is showing a client-id already exists. But, it is currently not working. Issue here: cosmos/relayer#952In the meantime, one dirty solution that I think will work is to create another relayer instances with a different home folder path. Then create the new "substituteClient" with the bad trusting period that way.
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.
Generating a new path (with a new path name) worked