Skip to content

Commit

Permalink
fix(02-client): incorrect test case (#4014)
Browse files Browse the repository at this point in the history
* fix. bug in client test

* Update modules/core/02-client/keeper/client_test.go

Co-authored-by: Damian Nolan <damiannolan@gmail.com>

---------

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
  • Loading branch information
colin-axner and damiannolan committed Jul 5, 2023
1 parent d50e09a commit dbfb293
Showing 1 changed file with 9 additions and 6 deletions.
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)

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

0 comments on commit dbfb293

Please sign in to comment.