From 2a6210282c78d119ccdc584fecf54e9bd0f4f125 Mon Sep 17 00:00:00 2001 From: PanGan21 Date: Tue, 21 Mar 2023 22:05:24 +0100 Subject: [PATCH 1/2] add default solomachine client id for testing --- modules/core/02-client/keeper/keeper_test.go | 2 +- modules/core/02-client/migrations/v7/genesis_test.go | 2 +- modules/core/02-client/migrations/v7/store_test.go | 4 ++-- modules/core/02-client/types/genesis_test.go | 11 +++++------ modules/core/migrations/v7/genesis_test.go | 2 +- .../light-clients/06-solomachine/solomachine_test.go | 3 +-- .../07-tendermint/migrations/migrations_test.go | 2 +- testing/solomachine.go | 3 +++ 8 files changed, 15 insertions(+), 14 deletions(-) diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index ac9d9269322..c81e9d0fcff 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -386,7 +386,7 @@ func (suite KeeperTestSuite) TestIterateClientStates() { //nolint:govet // this } solomachines := []*ibctesting.Solomachine{ - ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1), + ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1), ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4), } diff --git a/modules/core/02-client/migrations/v7/genesis_test.go b/modules/core/02-client/migrations/v7/genesis_test.go index 79e285ba58a..711d3fce94d 100644 --- a/modules/core/02-client/migrations/v7/genesis_test.go +++ b/modules/core/02-client/migrations/v7/genesis_test.go @@ -30,7 +30,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { } // create multiple legacy solo machine clients - solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1) + solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1) solomachineMulti := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4) clientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) diff --git a/modules/core/02-client/migrations/v7/store_test.go b/modules/core/02-client/migrations/v7/store_test.go index a098530af50..cb8be6e0f6d 100644 --- a/modules/core/02-client/migrations/v7/store_test.go +++ b/modules/core/02-client/migrations/v7/store_test.go @@ -53,7 +53,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateStore() { } solomachines := []*ibctesting.Solomachine{ - ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1), + ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1), ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4), } @@ -69,7 +69,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateStore() { func (suite *MigrationsV7TestSuite) TestMigrateStoreNoTendermintClients() { solomachines := []*ibctesting.Solomachine{ - ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1), + ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1), ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4), } diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index 41254d148e3..70ca89a5463 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -16,11 +16,10 @@ import ( ) const ( - tmClientID0 = "07-tendermint-0" - tmClientID1 = "07-tendermint-1" - invalidClientID = "myclient-0" - soloMachineClientID = "06-solomachine-0" - clientID = tmClientID0 + tmClientID0 = "07-tendermint-0" + tmClientID1 = "07-tendermint-1" + invalidClientID = "myclient-0" + clientID = tmClientID0 height = 10 ) @@ -112,7 +111,7 @@ func (suite *TypesTestSuite) TestValidateGenesis() { genState: types.NewGenesisState( []types.IdentifiedClientState{ types.NewIdentifiedClientState( - soloMachineClientID, ibctm.NewClientState(suite.chainA.ChainID, ibctm.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), + ibctesting.DefaultSolomachineClientID, ibctm.NewClientState(suite.chainA.ChainID, ibctm.DefaultTrustLevel, ibctesting.TrustingPeriod, ibctesting.UnbondingPeriod, ibctesting.MaxClockDrift, clientHeight, commitmenttypes.GetSDKSpecs(), ibctesting.UpgradePath), ), types.NewIdentifiedClientState(tmClientID0, solomachine.NewClientState(0, &solomachine.ConsensusState{PublicKey: suite.solomachine.ConsensusState().PublicKey, Diversifier: suite.solomachine.Diversifier, Timestamp: suite.solomachine.Time})), }, diff --git a/modules/core/migrations/v7/genesis_test.go b/modules/core/migrations/v7/genesis_test.go index 1a040534ff8..943a9d9593f 100644 --- a/modules/core/migrations/v7/genesis_test.go +++ b/modules/core/migrations/v7/genesis_test.go @@ -57,7 +57,7 @@ func (suite *MigrationsV7TestSuite) TestMigrateGenesisSolomachine() { } // create multiple legacy solo machine clients - solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1) + solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1) solomachineMulti := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-1", "testing", 4) clientGenState := ibcclient.ExportGenesis(suite.chainA.GetContext(), suite.chainA.App.GetIBCKeeper().ClientKeeper) diff --git a/modules/light-clients/06-solomachine/solomachine_test.go b/modules/light-clients/06-solomachine/solomachine_test.go index 15c4461edbd..30767d80945 100644 --- a/modules/light-clients/06-solomachine/solomachine_test.go +++ b/modules/light-clients/06-solomachine/solomachine_test.go @@ -24,7 +24,6 @@ import ( var ( channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side - clientIDSolomachine = "06-solomachine-0" ) type SoloMachineTestSuite struct { @@ -123,7 +122,7 @@ func (suite *SoloMachineTestSuite) TestTimeout() { // simulate solomachine time increment suite.solomachine.Time++ - suite.solomachine.UpdateClient(suite.chainA, clientIDSolomachine) + suite.solomachine.UpdateClient(suite.chainA, ibctesting.DefaultSolomachineClientID) suite.solomachine.TimeoutPacket(suite.chainA, packet) diff --git a/modules/light-clients/07-tendermint/migrations/migrations_test.go b/modules/light-clients/07-tendermint/migrations/migrations_test.go index 0bfc1031725..7a261caaf8c 100644 --- a/modules/light-clients/07-tendermint/migrations/migrations_test.go +++ b/modules/light-clients/07-tendermint/migrations/migrations_test.go @@ -50,7 +50,7 @@ func (suite *MigrationsTestSuite) TestPruneExpiredConsensusStates() { paths[i] = path } - solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "06-solomachine-0", "testing", 1) + solomachine := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, ibctesting.DefaultSolomachineClientID, "testing", 1) smClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), solomachine.ClientID) // set client state diff --git a/testing/solomachine.go b/testing/solomachine.go index e63b04ab51b..a98d73c08bf 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -31,6 +31,9 @@ var ( channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side ) +// DefaultSolomachineClientID is the default solo machine client id used for testing +var DefaultSolomachineClientID = "06-solomachine-0" + // Solomachine is a testing helper used to simulate a counterparty // solo machine client. type Solomachine struct { From 47dab235f1d1dc2f2cdd5b88f8746b82428f7f0a Mon Sep 17 00:00:00 2001 From: PanGan21 Date: Wed, 22 Mar 2023 14:44:47 +0100 Subject: [PATCH 2/2] lint files --- modules/light-clients/06-solomachine/solomachine_test.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/light-clients/06-solomachine/solomachine_test.go b/modules/light-clients/06-solomachine/solomachine_test.go index 30767d80945..824872df26e 100644 --- a/modules/light-clients/06-solomachine/solomachine_test.go +++ b/modules/light-clients/06-solomachine/solomachine_test.go @@ -22,9 +22,7 @@ import ( "github.com/cosmos/ibc-go/v7/testing/mock" ) -var ( - channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side -) +var channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side type SoloMachineTestSuite struct { suite.Suite