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

refactor(api)!: use cometbft's MockPV. #5709

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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()},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems this was initially done since a ed25519.PrivKey type exists in both sdk and comet and had to initialize by directly grabbing the 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
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.

Loading