Skip to content

Commit

Permalink
chore: set up IBCTestStakingKeeper interface (#2028) (#2080)
Browse files Browse the repository at this point in the history
* initial interface definition

* update simapp

* update godocs

(cherry picked from commit 4d4dbcf)

Co-authored-by: Charly <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
3 people authored Aug 24, 2022
1 parent d256570 commit 640bc28
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking

* (testing)[\#2028](https://github.com/cosmos/ibc-go/pull/2028) New interface `ibctestingtypes.StakingKeeper` added and set for the testing app `StakingKeeper` setup.
* (core/04-channel) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `NewPacketId` has been renamed to `NewPacketID` to comply with go linting rules.
* (core/ante) [\#1418](https://github.com/cosmos/ibc-go/pull/1418) `AnteDecorator` has been renamed to `RedundancyDecorator` to comply with go linting rules and to give more clarity to the purpose of the Decorator.
* (core/ante) [\#1820](https://github.com/cosmos/ibc-go/pull/1418) `RedundancyDecorator` has been renamed to `RedundantRelayDecorator` to make the name for explicit.
Expand Down
2 changes: 1 addition & 1 deletion testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type TestingApp interface {

// ibc-go additions
GetBaseApp() *baseapp.BaseApp
GetStakingKeeper() stakingkeeper.Keeper
GetStakingKeeper() ibctestingtypes.StakingKeeper
GetIBCKeeper() *keeper.Keeper
GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper
GetTxConfig() client.TxConfig
Expand Down
4 changes: 2 additions & 2 deletions testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -27,6 +26,7 @@ import (

"github.com/cosmos/ibc-go/v5/modules/core/keeper"
"github.com/cosmos/ibc-go/v5/testing/simapp"
ibctestingtypes "github.com/cosmos/ibc-go/v5/testing/types"
)

var DefaultTestingAppInit = SetupTestingApp
Expand All @@ -36,7 +36,7 @@ type TestingApp interface {

// ibc-go additions
GetBaseApp() *baseapp.BaseApp
GetStakingKeeper() stakingkeeper.Keeper
GetStakingKeeper() ibctestingtypes.StakingKeeper
GetIBCKeeper() *keeper.Keeper
GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper
GetTxConfig() client.TxConfig
Expand Down
6 changes: 3 additions & 3 deletions testing/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ func TestChangeValSet(t *testing.T) {
amount2, ok := sdk.NewIntFromString("30000000000000000000")
require.True(t, ok)

val := chainA.App.GetStakingKeeper().GetValidators(chainA.GetContext(), 4)
val := chainA.GetSimApp().StakingKeeper.GetValidators(chainA.GetContext(), 4)

chainA.App.GetStakingKeeper().Delegate(chainA.GetContext(), chainA.SenderAccounts[1].SenderAccount.GetAddress(),
chainA.GetSimApp().StakingKeeper.Delegate(chainA.GetContext(), chainA.SenderAccounts[1].SenderAccount.GetAddress(),
amount, types.Unbonded, val[1], true)
chainA.App.GetStakingKeeper().Delegate(chainA.GetContext(), chainA.SenderAccounts[3].SenderAccount.GetAddress(),
chainA.GetSimApp().StakingKeeper.Delegate(chainA.GetContext(), chainA.SenderAccounts[3].SenderAccount.GetAddress(),
amount2, types.Unbonded, val[3], true)

coord.CommitBlock(chainA)
Expand Down
3 changes: 2 additions & 1 deletion testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v5/modules/core/keeper"
ibcmock "github.com/cosmos/ibc-go/v5/testing/mock"
simappparams "github.com/cosmos/ibc-go/v5/testing/simapp/params"
ibctestingtypes "github.com/cosmos/ibc-go/v5/testing/types"
)

const appName = "SimApp"
Expand Down Expand Up @@ -748,7 +749,7 @@ func (app *SimApp) GetBaseApp() *baseapp.BaseApp {
}

// GetStakingKeeper implements the TestingApp interface.
func (app *SimApp) GetStakingKeeper() stakingkeeper.Keeper {
func (app *SimApp) GetStakingKeeper() ibctestingtypes.StakingKeeper {
return app.StakingKeeper
}

Expand Down
12 changes: 12 additions & 0 deletions testing/types/expected_keepers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package types

import (
sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

// StakingKeeper defines the expected staking keeper interface used in the
// IBC testing package
type StakingKeeper interface {
GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool)
}

0 comments on commit 640bc28

Please sign in to comment.