-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Allow localhost to be created #7148
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import ( | |
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" | ||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types" | ||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" | ||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types" | ||
|
@@ -110,19 +111,20 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { | |
{ | ||
"success", | ||
func() { | ||
clientState := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, 0, commitmenttypes.GetSDKSpecs()) | ||
clientState2 := ibctmtypes.NewClientState(testChainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, 0, commitmenttypes.GetSDKSpecs()) | ||
suite.keeper.SetClientState(suite.ctx, testClientID, clientState) | ||
suite.keeper.SetClientState(suite.ctx, testClientID2, clientState2) | ||
clientA1, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, exported.Tendermint) | ||
clientA2, _ := suite.coordinator.CreateClient(suite.chainA, suite.chainB, exported.Tendermint) | ||
|
||
idcs := types.NewIdentifiedClientState(testClientID, clientState) | ||
idcs2 := types.NewIdentifiedClientState(testClientID2, clientState2) | ||
clientStateA1 := suite.chainA.GetClientState(clientA1) | ||
clientStateA2 := suite.chainA.GetClientState(clientA2) | ||
|
||
// order is swapped because the res is sorted by client id | ||
expClientStates = []*types.IdentifiedClientState{&idcs2, &idcs} | ||
idcs := types.NewIdentifiedClientState(clientA1, clientStateA1) | ||
idcs2 := types.NewIdentifiedClientState(clientA2, clientStateA2) | ||
|
||
// order is sorted by client id, localhost is last | ||
expClientStates = []*types.IdentifiedClientState{&idcs, &idcs2} | ||
req = &types.QueryClientStatesRequest{ | ||
Pagination: &query.PageRequest{ | ||
Limit: 3, | ||
Limit: 7, | ||
CountTotal: true, | ||
}, | ||
} | ||
|
@@ -134,11 +136,18 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { | |
for _, tc := range testCases { | ||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { | ||
suite.SetupTest() // reset | ||
expClientStates = nil | ||
|
||
tc.malleate() | ||
ctx := sdk.WrapSDKContext(suite.ctx) | ||
|
||
res, err := suite.queryClient.ClientStates(ctx, req) | ||
// always add localhost which is created by default in init genesis | ||
localhostClientState := suite.chainA.GetClientState(exported.Localhost.String()) | ||
identifiedLocalhost := types.NewIdentifiedClientState(exported.Localhost.String(), localhostClientState) | ||
expClientStates = append(expClientStates, &identifiedLocalhost) | ||
|
||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) | ||
|
||
res, err := suite.chainA.QueryServer.ClientStates(ctx, req) | ||
|
||
if tc.expPass { | ||
suite.Require().NoError(err) | ||
|
@@ -147,7 +156,6 @@ func (suite *KeeperTestSuite) TestQueryClientStates() { | |
for i := range expClientStates { | ||
suite.Require().Equal(expClientStates[i].ClientId, res.ClientStates[i].ClientId) | ||
suite.Require().NotNil(res.ClientStates[i].ClientState) | ||
expClientStates[i].ClientState.ClearCachedValue() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to do this bc the Equal statement would fail if the expected response had the value cached. Using Proto equal would work too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It passes now when using the testing package. Going to leave as is but we can add back if necessary |
||
suite.Require().Equal(expClientStates[i].ClientState, res.ClientStates[i].ClientState) | ||
} | ||
} else { | ||
|
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.
Why is this test-case removed?
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.
localhost is already created in genesis. This test would fail, changing it to false would just make it a duplication of the later test case
"client already exists",