Skip to content

Commit

Permalink
Include small improvements from v0.17.x releases in master (Kava-Labs…
Browse files Browse the repository at this point in the history
…#1265)

* add interface type checks for antehandlers

* add initial height option to test app
  • Loading branch information
rhuairahrighairidh authored Jun 6, 2022
1 parent b0e395c commit 62ab9f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 2 additions & 0 deletions app/ante/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz"
)

var _ sdk.AnteDecorator = AuthzLimiterDecorator{}

// AuthzLimiterDecorator blocks certain msg types from being granted or executed within authz.
type AuthzLimiterDecorator struct {
// disabledMsgTypes is the type urls of the msgs to block.
Expand Down
2 changes: 2 additions & 0 deletions app/ante/vesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
)

var _ sdk.AnteDecorator = VestingAccountDecorator{}

// VestingAccountDecorator blocks MsgCreateVestingAccount from reaching the mempool
type VestingAccountDecorator struct{}

Expand Down
25 changes: 18 additions & 7 deletions app/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ import (
)

var (
emptyTime time.Time
testChainID = "kavatest_1-1"
emptyTime time.Time
testChainID = "kavatest_1-1"
defaultInitialHeight int64 = 1
)

// TestApp is a simple wrapper around an App. It exposes internal keepers for use in integration tests.
Expand Down Expand Up @@ -116,18 +117,27 @@ func (app *App) AppCodec() codec.Codec {
return app.appCodec
}

// InitializeFromGenesisStates calls InitChain on the app using the default genesis state, overwitten with any passed in genesis states
// InitializeFromGenesisStates calls InitChain on the app using the provided genesis states.
// If any module genesis states are missing, defaults are used.
func (tApp TestApp) InitializeFromGenesisStates(genesisStates ...GenesisState) TestApp {
return tApp.InitializeFromGenesisStatesWithTimeAndChainID(emptyTime, testChainID, genesisStates...)
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(emptyTime, testChainID, defaultInitialHeight, genesisStates...)
}

// InitializeFromGenesisStatesWithTime calls InitChain on the app using the default genesis state, overwitten with any passed in genesis states and genesis Time
// InitializeFromGenesisStatesWithTime calls InitChain on the app using the provided genesis states and time.
// If any module genesis states are missing, defaults are used.
func (tApp TestApp) InitializeFromGenesisStatesWithTime(genTime time.Time, genesisStates ...GenesisState) TestApp {
return tApp.InitializeFromGenesisStatesWithTimeAndChainID(genTime, testChainID, genesisStates...)
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(genTime, testChainID, defaultInitialHeight, genesisStates...)
}

// InitializeFromGenesisStatesWithTimeAndChainID calls InitChain on the app using the default genesis state, overwitten with any passed in genesis states and genesis Time
// InitializeFromGenesisStatesWithTimeAndChainID calls InitChain on the app using the provided genesis states, time, and chain id.
// If any module genesis states are missing, defaults are used.
func (tApp TestApp) InitializeFromGenesisStatesWithTimeAndChainID(genTime time.Time, chainID string, genesisStates ...GenesisState) TestApp {
return tApp.InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(genTime, chainID, defaultInitialHeight, genesisStates...)
}

// InitializeFromGenesisStatesWithTimeAndChainIDAndHeight calls InitChain on the app using the provided genesis states and other parameters.
// If any module genesis states are missing, defaults are used.
func (tApp TestApp) InitializeFromGenesisStatesWithTimeAndChainIDAndHeight(genTime time.Time, chainID string, initialHeight int64, genesisStates ...GenesisState) TestApp {
// Create a default genesis state and overwrite with provided values
genesisState := NewDefaultGenesisState()
for _, state := range genesisStates {
Expand All @@ -154,6 +164,7 @@ func (tApp TestApp) InitializeFromGenesisStatesWithTimeAndChainID(genTime time.T
MaxGas: 20000000,
},
},
InitialHeight: initialHeight,
},
)
tApp.Commit()
Expand Down

0 comments on commit 62ab9f5

Please sign in to comment.