Skip to content

Commit

Permalink
refactor(api)!: use cometbft's MockPV. (cosmos#5709)
Browse files Browse the repository at this point in the history
* Use cometbft's MockPV.

* update migration docs

---------

Co-authored-by: Carlos Rodriguez <[email protected]>
  • Loading branch information
DimitrisJim and crodriguezvega authored Jan 25, 2024
1 parent bd27f58 commit e475064
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 133 deletions.
4 changes: 4 additions & 0 deletions docs/docs/05-migrations/13-v8-to-v9.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ The `exported.ChannelI` interface has been removed. Please use the concrete type
The testing package functions `coordinator.Setup`, `coordinator.SetupClients`, `coordinator.SetupConnections`, `coordinator.CreateConnections`, and `coordinator.CreateChannels` have been deprecated and will be removed in v10.
Please use the new functions `path.Setup`, `path.SetupClients`, `path.SetupConnections`, `path.CreateConnections`, `path.CreateChannels`.

### IBC testing package

- The `mock.PV` type has been removed in favour of [`cmttypes.MockPV`](https://github.com/cometbft/cometbft/blob/v0.38.5/types/priv_validator.go#L50) ([#5709](https://github.com/cosmos/ibc-go/pull/5709)).

## Relayers

- Renaming of event attribute keys in [#5603](https://github.com/cosmos/ibc-go/pull/5603).
Expand Down
8 changes: 3 additions & 5 deletions e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
upgradetypes "cosmossdk.io/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/client/grpc/cmtservice"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"

Expand All @@ -37,7 +36,6 @@ import (
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibcmock "github.com/cosmos/ibc-go/v8/testing/mock"
)

const (
Expand Down Expand Up @@ -520,9 +518,9 @@ func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain ibc
})

for _, filePV := range filePvs {
pvs = append(pvs, &ibcmock.PV{
PrivKey: &ed25519.PrivKey{Key: filePV.PrivKey.Bytes()},
})
pvs = append(pvs, cmttypes.NewMockPVWithParams(
filePV.PrivKey, false, false,
))
}

return pvs
Expand Down
5 changes: 2 additions & 3 deletions modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
localhost "github.com/cosmos/ibc-go/v8/modules/light-clients/09-localhost"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibctestingmock "github.com/cosmos/ibc-go/v8/testing/mock"
"github.com/cosmos/ibc-go/v8/testing/simapp"
)

Expand Down Expand Up @@ -85,7 +84,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.cdc = app.AppCodec()
suite.ctx = app.BaseApp.NewContext(isCheckTx)
suite.keeper = &app.IBCKeeper.ClientKeeper
suite.privVal = ibctestingmock.NewPV()
suite.privVal = cmttypes.NewMockPV()
pubKey, err := suite.privVal.GetPubKey()
suite.Require().NoError(err)

Expand All @@ -100,7 +99,7 @@ func (suite *KeeperTestSuite) SetupTest() {

var validators stakingtypes.Validators
for i := 1; i < 11; i++ {
privVal := ibctestingmock.NewPV()
privVal := cmttypes.NewMockPV()
tmPk, err := privVal.GetPubKey()
suite.Require().NoError(err)
pk, err := cryptocodec.FromCmtPubKeyInterface(tmPk)
Expand Down
3 changes: 1 addition & 2 deletions modules/core/02-client/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibctestingmock "github.com/cosmos/ibc-go/v8/testing/mock"
)

const (
Expand Down Expand Up @@ -45,7 +44,7 @@ func (suite *TypesTestSuite) TestMarshalGenesisState() {
}

func (suite *TypesTestSuite) TestValidateGenesis() {
privVal := ibctestingmock.NewPV()
privVal := cmttypes.NewMockPV()
pubKey, err := privVal.GetPubKey()
suite.Require().NoError(err)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import (
solomachine "github.com/cosmos/ibc-go/v8/modules/light-clients/06-solomachine"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibctestingmock "github.com/cosmos/ibc-go/v8/testing/mock"
)

func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
// Setup different validators and signers for testing different types of updates
altPrivVal := ibctestingmock.NewPV()
altPrivVal := cmttypes.NewMockPV()
altPubKey, err := altPrivVal.GetPubKey()
suite.Require().NoError(err)

Expand Down Expand Up @@ -365,7 +364,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
ibctesting.ChainIDSuffix = ""

// Setup different validators and signers for testing different types of updates
altPrivVal := ibctestingmock.NewPV()
altPrivVal := cmttypes.NewMockPV()
altPubKey, err := altPrivVal.GetPubKey()
suite.Require().NoError(err)

Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/07-tendermint/misbehaviour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/ibc-go/v8/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibctestingmock "github.com/cosmos/ibc-go/v8/testing/mock"
)

func (suite *TendermintTestSuite) TestMisbehaviour() {
Expand All @@ -27,7 +26,7 @@ func (suite *TendermintTestSuite) TestMisbehaviour() {
}

func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() {
altPrivVal := ibctestingmock.NewPV()
altPrivVal := cmttypes.NewMockPV()
altPubKey, err := altPrivVal.GetPubKey()
suite.Require().NoError(err)

Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/07-tendermint/tendermint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibctestingmock "github.com/cosmos/ibc-go/v8/testing/mock"
"github.com/cosmos/ibc-go/v8/testing/simapp"
)

Expand Down Expand Up @@ -78,7 +77,7 @@ func (suite *TendermintTestSuite) SetupTest() {
// Header time is intended to be time for any new header used for updates
suite.headerTime = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC)

suite.privVal = ibctestingmock.NewPV()
suite.privVal = cmttypes.NewMockPV()

pubKey, err := suite.privVal.GetPubKey()
suite.Require().NoError(err)
Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/07-tendermint/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/ibc-go/v8/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctesting "github.com/cosmos/ibc-go/v8/testing"
ibctestingmock "github.com/cosmos/ibc-go/v8/testing/mock"
)

func (suite *TendermintTestSuite) TestVerifyHeader() {
Expand All @@ -23,7 +22,7 @@ func (suite *TendermintTestSuite) TestVerifyHeader() {
)

// Setup different validators and signers for testing different types of updates
altPrivVal := ibctestingmock.NewPV()
altPrivVal := cmttypes.NewMockPV()
altPubKey, err := altPrivVal.GetPubKey()
suite.Require().NoError(err)

Expand Down
3 changes: 1 addition & 2 deletions modules/light-clients/08-wasm/testing/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
cmttypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm"
"github.com/cosmos/ibc-go/v8/testing/mock"
)

func setup(tb testing.TB, chainID string, withGenesis bool, invCheckPeriod uint, mockVM ibcwasm.WasmEngine) (*SimApp, GenesisState) {
Expand Down Expand Up @@ -91,7 +90,7 @@ func SetupWithGenesisValSetSnapshotter(t *testing.T, mockVM ibcwasm.WasmEngine,
func SetupWithSnapshotter(t *testing.T, mockVM ibcwasm.WasmEngine) *SimApp {
t.Helper()

privVal := mock.NewPV()
privVal := cmttypes.NewMockPV()
pubKey, err := privVal.GetPubKey()
require.NoError(t, err)

Expand Down
65 changes: 0 additions & 65 deletions testing/mock/privval.go

This file was deleted.

47 changes: 0 additions & 47 deletions testing/mock/privval_test.go

This file was deleted.

0 comments on commit e475064

Please sign in to comment.