Skip to content

Commit

Permalink
chore: add default solomachine client id for testing (#3316)
Browse files Browse the repository at this point in the history
* add default solomachine client id for testing

* lint files

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
Co-authored-by: Jim Fasarakis-Hilliard <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
4 people authored Apr 11, 2023
1 parent ee762a3 commit a18f96a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/migrations/v7/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/02-client/migrations/v7/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand All @@ -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),
}

Expand Down
11 changes: 5 additions & 6 deletions modules/core/02-client/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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})),
},
Expand Down
2 changes: 1 addition & 1 deletion modules/core/migrations/v7/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions modules/light-clients/06-solomachine/solomachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import (
"github.com/cosmos/ibc-go/v7/testing/mock"
)

var (
channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side
clientIDSolomachine = "06-solomachine-0"
)
var channelIDSolomachine = "channel-on-solomachine" // channelID generated on solo machine side

type SoloMachineTestSuite struct {
suite.Suite
Expand Down Expand Up @@ -123,7 +120,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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions testing/solomachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a18f96a

Please sign in to comment.