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

chore: address linter findings in 07-tendermint #6136

Merged
merged 19 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
26 changes: 18 additions & 8 deletions modules/light-clients/07-tendermint/client_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func (suite *TendermintTestSuite) TestStatus() {
path.EndpointA.SetClientState(clientState)
}, exported.Frozen},
{"client status without consensus state", func() {
clientState.LatestHeight = clientState.LatestHeight.Increment().(clienttypes.Height)
var ok bool
clientState.LatestHeight, ok = clientState.LatestHeight.Increment().(clienttypes.Height)
suite.Require().True(ok)
path.EndpointA.SetClientState(clientState)
}, exported.Expired},
{"client status is expired", func() {
Expand All @@ -60,7 +62,9 @@ func (suite *TendermintTestSuite) TestStatus() {
path.SetupClients()

clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID)
clientState = path.EndpointA.GetClientState().(*ibctm.ClientState)
var ok bool
clientState, ok = path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)

tc.malleate()

Expand Down Expand Up @@ -91,7 +95,8 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() {
{
"failure: consensus state not found for height",
func() {
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
height = clientState.LatestHeight.Increment()
},
clienttypes.ErrConsensusStateNotFound,
Expand All @@ -106,7 +111,8 @@ func (suite *TendermintTestSuite) TestGetTimestampAtHeight() {
path = ibctesting.NewPath(suite.chainA, suite.chainB)
path.SetupClients()

clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
height = clientState.LatestHeight

store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID)
Expand Down Expand Up @@ -332,7 +338,8 @@ func (suite *TendermintTestSuite) TestVerifyMembership() {

proof, proofHeight = suite.chainB.QueryProof(key)

consensusState := testingpath.EndpointB.GetConsensusState(latestHeight).(*ibctm.ConsensusState)
consensusState, ok := testingpath.EndpointB.GetConsensusState(latestHeight).(*ibctm.ConsensusState)
suite.Require().True(ok)
value, err = suite.chainB.Codec.MarshalInterface(consensusState)
suite.Require().NoError(err)
},
Expand Down Expand Up @@ -528,13 +535,15 @@ func (suite *TendermintTestSuite) TestVerifyMembership() {

proof, proofHeight = suite.chainB.QueryProof(key)

clientState := testingpath.EndpointB.GetClientState().(*ibctm.ClientState)
clientState, ok := testingpath.EndpointB.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
value, err = suite.chainB.Codec.MarshalInterface(clientState)
suite.Require().NoError(err)

tc.malleate() // make changes as necessary

clientState = testingpath.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok = testingpath.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)

ctx := suite.chainA.GetContext()
store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, testingpath.EndpointA.ClientID)
Expand Down Expand Up @@ -747,7 +756,8 @@ func (suite *TendermintTestSuite) TestVerifyNonMembership() {

tc.malleate() // make changes as necessary

clientState := testingpath.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := testingpath.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)

ctx := suite.chainA.GetContext()
store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, testingpath.EndpointA.ClientID)
Expand Down
4 changes: 3 additions & 1 deletion modules/light-clients/07-tendermint/header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() {
header.SignedHeader.Commit = nil
}, false},
{"trusted height is equal to header height", func() {
header.TrustedHeight = header.GetHeight().(clienttypes.Height)
var ok bool
header.TrustedHeight, ok = header.GetHeight().(clienttypes.Height)
suite.Require().True(ok)
}, false},
{"validator set nil", func() {
header.ValidatorSet = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func (suite *TendermintTestSuite) TestRecoverClient() {

// assert that status of subject client is now Active
clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, subjectClientID)
tmClientState := subjectPath.EndpointA.GetClientState().(*ibctm.ClientState)
tmClientState, ok := subjectPath.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
suite.Require().Equal(exported.Active, tmClientState.Status(ctx, clientStore, suite.chainA.App.AppCodec()))
} else {
suite.Require().Error(err)
Expand Down Expand Up @@ -196,12 +197,14 @@ func (suite *TendermintTestSuite) TestVerifyUpgradeAndUpdateState() {
suite.Require().NoError(err)

// change upgraded client state height to be lower than current client state height
tmClient := upgradedClientState.(*ibctm.ClientState)
tmClient, ok := upgradedClientState.(*ibctm.ClientState)
suite.Require().True(ok)

newLatestheight, ok := path.EndpointA.GetClientLatestHeight().Decrement()
suite.Require().True(ok)

tmClient.LatestHeight = newLatestheight.(clienttypes.Height)
tmClient.LatestHeight, ok = newLatestheight.(clienttypes.Height)
suite.Require().True(ok)
upgradedClientStateAny, err = codectypes.NewAnyWithValue(tmClient)
suite.Require().NoError(err)

Expand All @@ -225,7 +228,8 @@ func (suite *TendermintTestSuite) TestVerifyUpgradeAndUpdateState() {
path.SetupClients()

clientID = path.EndpointA.ClientID
clientState := path.EndpointA.GetClientState().(*ibctm.ClientState)
clientState, ok := path.EndpointA.GetClientState().(*ibctm.ClientState)
suite.Require().True(ok)
revisionNumber := clienttypes.ParseChainID(clientState.ChainId)

newUnbondindPeriod := ubdPeriod + trustingPeriod
Expand Down
Loading
Loading