Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -1042,13 +1042,13 @@ func (suite *SoloMachineTestSuite) TestUpdateState() {
nil,
},
{
"failure: invalid type misbehaviour",
"invalid type misbehaviour no-ops",
func() {
clientState = sm.ClientState()
clientMsg = sm.CreateMisbehaviour()
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), clientID, clientState)
},
fmt.Errorf("unsupported ClientMessage: %T", sm.CreateMisbehaviour()),
nil,
},
{
"failure: cannot find client state",
Expand Down Expand Up @@ -1092,6 +1092,11 @@ func (suite *SoloMachineTestSuite) TestUpdateState() {

newClientState := clienttypes.MustUnmarshalClientState(suite.chainA.Codec, clientStateBz)

if len(consensusHeights) == 0 {
suite.Require().Equal(clientState, newClientState)
return
}

suite.Require().Len(consensusHeights, 1)
suite.Require().Equal(uint64(0), consensusHeights[0].GetRevisionNumber())
suite.Require().Equal(newClientState.(*solomachine.ClientState).Sequence, consensusHeights[0].GetRevisionHeight())
Expand Down
6 changes: 3 additions & 3 deletions modules/light-clients/06-solomachine/update.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package solomachine

import (
"fmt"

errorsmod "cosmossdk.io/errors"
storetypes "cosmossdk.io/store/types"

Expand Down Expand Up @@ -79,10 +77,12 @@ func (cs ClientState) verifyHeader(cdc codec.BinaryCodec, header *Header) error

// UpdateState updates the consensus state to the new public key and an incremented sequence.
// A list containing the updated consensus height is returned.
// If the provided clientMsg is not of type Header, the handler will no-op and return an empty slice.
func (cs ClientState) UpdateState(ctx sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, clientMsg exported.ClientMessage) []exported.Height {
smHeader, ok := clientMsg.(*Header)
if !ok {
panic(fmt.Errorf("unsupported ClientMessage: %T", clientMsg))
// clientMsg is invalid Misbehaviour, no update necessary
return []exported.Height{}
}

// create new solomachine ConsensusState
Expand Down