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

fix: incorrect test case #4014

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Changes from all commits
Commits
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
15 changes: 9 additions & 6 deletions modules/core/02-client/keeper/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,34 @@ func (suite *KeeperTestSuite) TestUpdateClientTendermint() {
updateHeader = createPastUpdateFn(fillHeight, trustedHeight)
}, true, false},
{"valid duplicate update", func() {
clientID := path.EndpointA.ClientID

height1 := clienttypes.NewHeight(1, 1)

// store previous consensus state
prevConsState := &ibctm.ConsensusState{
Timestamp: suite.past,
NextValidatorsHash: suite.chainB.Vals.Hash(),
}
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height1, prevConsState)
path.EndpointA.SetConsensusState(prevConsState, height1)

height5 := clienttypes.NewHeight(1, 5)
// store next consensus state to check that trustedHeight does not need to be hightest consensus state before header height
// store next consensus state to check that trustedHeight does not need to be highest consensus state before header height
nextConsState := &ibctm.ConsensusState{
Timestamp: suite.past.Add(time.Minute),
NextValidatorsHash: suite.chainB.Vals.Hash(),
}
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, height5, nextConsState)
path.EndpointA.SetConsensusState(nextConsState, height5)

// update client state latest height
clientState := path.EndpointA.GetClientState()
clientState.(*ibctm.ClientState).LatestHeight = height5
path.EndpointA.SetClientState(clientState)
Comment on lines +169 to +172
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the main fix


height3 := clienttypes.NewHeight(1, 3)
// updateHeader will fill in consensus state between prevConsState and suite.consState
// clientState should not be updated
updateHeader = createPastUpdateFn(height3, height1)
// set updateHeader's consensus state in store to create duplicate UpdateClient scenario
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), clientID, updateHeader.GetHeight(), updateHeader.ConsensusState())
path.EndpointA.SetConsensusState(updateHeader.ConsensusState(), updateHeader.GetHeight())
}, true, false},
{"misbehaviour detection: conflicting header", func() {
clientID := path.EndpointA.ClientID
Expand Down
Loading