Skip to content

Commit

Permalink
chore: renaming nits for SetConsensusHost (#6128)
Browse files Browse the repository at this point in the history
  • Loading branch information
damiannolan authored Apr 10, 2024
1 parent cc6170e commit 7590808
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ func (k Keeper) UpdateLocalhostClient(ctx sdk.Context, clientState exported.Clie
return clientModule.UpdateState(ctx, exported.LocalhostClientID, nil)
}

// SetSelfConsensusHost sets a custom ConsensusHost for self client state and consensus state validation.
func (k *Keeper) SetSelfConsensusHost(consensusHost types.ConsensusHost) {
// SetConsensusHost sets a custom ConsensusHost for self client state and consensus state validation.
func (k *Keeper) SetConsensusHost(consensusHost types.ConsensusHost) {
if consensusHost == nil {
panic(fmt.Errorf("cannot set a nil self consensus host"))
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/03-connection/keeper/handshake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() {
},
}

suite.chainB.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(&mockValidator)
suite.chainB.App.GetIBCKeeper().SetConsensusHost(&mockValidator)
}, false},
}

Expand Down
10 changes: 10 additions & 0 deletions modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"errors"
"fmt"
"reflect"
"strings"

Expand Down Expand Up @@ -80,6 +81,15 @@ func (k Keeper) Codec() codec.BinaryCodec {
return k.cdc
}

// SetConsensusHost sets a custom ConsensusHost for self client state and consensus state validation.
func (k *Keeper) SetConsensusHost(consensusHost clienttypes.ConsensusHost) {
if consensusHost == nil {
panic(fmt.Errorf("cannot set a nil self consensus host"))
}

k.ClientKeeper.SetConsensusHost(consensusHost)
}

// SetRouter sets the Router in IBC Keeper and seals it. The method panics if
// there is an existing router that's already sealed.
func (k *Keeper) SetRouter(rtr *porttypes.Router) {
Expand Down
6 changes: 3 additions & 3 deletions modules/light-clients/07-tendermint/consensus_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (suite *TendermintTestSuite) TestGetSelfConsensusState() {
return nil, mock.MockApplicationCallbackError
},
}
suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(consensusHost)
suite.chainA.GetSimApp().GetIBCKeeper().SetConsensusHost(consensusHost)
},
expError: mock.MockApplicationCallbackError,
},
Expand All @@ -63,7 +63,7 @@ func (suite *TendermintTestSuite) TestGetSelfConsensusState() {
return &solomachine.ConsensusState{}, nil
},
}
suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(consensusHost)
suite.chainA.GetSimApp().GetIBCKeeper().SetConsensusHost(consensusHost)
},
expError: nil,
},
Expand Down Expand Up @@ -153,7 +153,7 @@ func (suite *TendermintTestSuite) TestValidateSelfClient() {
}

// add mock validation logic
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(smConsensusHost)
suite.chainA.App.GetIBCKeeper().SetConsensusHost(smConsensusHost)
},
expError: nil,
},
Expand Down
8 changes: 2 additions & 6 deletions modules/light-clients/08-wasm/types/consensus_host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ func (suite *TypesTestSuite) TestGetSelfConsensusState() {
consensusHost, err = types.NewWasmConsensusHost(suite.chainA.Codec, consensusHost)
suite.Require().NoError(err)

suite.chainA.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(
consensusHost,
)
suite.chainA.App.GetIBCKeeper().SetConsensusHost(consensusHost)

cs, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetSelfConsensusState(suite.chainA.GetContext(), height)

Expand Down Expand Up @@ -134,9 +132,7 @@ func (suite *TypesTestSuite) TestValidateSelfClient() {
consensusHost, err = types.NewWasmConsensusHost(suite.chainA.Codec, consensusHost)
suite.Require().NoError(err)

suite.chainA.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(
consensusHost,
)
suite.chainA.App.GetIBCKeeper().ClientKeeper.SetConsensusHost(consensusHost)

err = suite.chainA.App.GetIBCKeeper().ClientKeeper.ValidateSelfClient(suite.chainA.GetContext(), clientState)

Expand Down

0 comments on commit 7590808

Please sign in to comment.