* remove client type struct Remove the client type struct, remove ClientType interface function from Header and Misbehaviour. ClientState and ConsensusState return the ClientType as a string. All uses of client type in testing are now pointing at the testing package so changing the location of the client type const will be painless. * update godoc and add back client type interface func Add godoc to client type constant for solo machine, tendermint, and localhost as per @fedekunze review suggestion. Add back the ClientType interface function for misbehaviour and header for solo machine and tendermint and add back the one liner unit tests as per @AdityaSripal suggestion. * remove client state from return remove client state from the return of CreateClient, UpdateClient, and CheckMisbehaviourAndUpdateState as well as update tests to reflect this change. * fix build error introduced by latest merge Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
76 lines
2.2 KiB
Go
76 lines
2.2 KiB
Go
package client_test
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
|
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
|
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
|
|
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
|
)
|
|
|
|
func (suite *ClientTestSuite) TestNewClientUpdateProposalHandler() {
|
|
var (
|
|
content govtypes.Content
|
|
err error
|
|
)
|
|
|
|
testCases := []struct {
|
|
name string
|
|
malleate func()
|
|
expPass bool
|
|
}{
|
|
{
|
|
"valid update client proposal", func() {
|
|
clientA, _ := suite.coordinator.SetupClients(suite.chainA, suite.chainB, ibctesting.Tendermint)
|
|
clientState := suite.chainA.GetClientState(clientA)
|
|
|
|
tmClientState, ok := clientState.(*ibctmtypes.ClientState)
|
|
suite.Require().True(ok)
|
|
tmClientState.AllowUpdateAfterMisbehaviour = true
|
|
tmClientState.FrozenHeight = tmClientState.LatestHeight
|
|
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), clientA, tmClientState)
|
|
|
|
// use next header for chainB to update the client on chainA
|
|
header, err := suite.chainA.ConstructUpdateTMClientHeader(suite.chainB, clientA)
|
|
suite.Require().NoError(err)
|
|
|
|
content, err = clienttypes.NewClientUpdateProposal(ibctesting.Title, ibctesting.Description, clientA, header)
|
|
suite.Require().NoError(err)
|
|
}, true,
|
|
},
|
|
{
|
|
"nil proposal", func() {
|
|
content = nil
|
|
}, false,
|
|
},
|
|
{
|
|
"unsupported proposal type", func() {
|
|
content = distributiontypes.NewCommunityPoolSpendProposal(ibctesting.Title, ibctesting.Description, suite.chainA.SenderAccount.GetAddress(), sdk.NewCoins(sdk.NewCoin("communityfunds", sdk.NewInt(10))))
|
|
}, false,
|
|
},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
tc := tc
|
|
|
|
suite.Run(tc.name, func() {
|
|
suite.SetupTest() // reset
|
|
|
|
tc.malleate()
|
|
|
|
proposalHandler := client.NewClientUpdateProposalHandler(suite.chainA.App.IBCKeeper.ClientKeeper)
|
|
|
|
err = proposalHandler(suite.chainA.GetContext(), content)
|
|
|
|
if tc.expPass {
|
|
suite.Require().NoError(err)
|
|
} else {
|
|
suite.Require().Error(err)
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|