mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 15:57:58 +00:00 
			
		
		
		
	Include small improvements from v0.17.x releases in master (#1265)
* add interface type checks for antehandlers * add initial height option to test app
This commit is contained in:
		
							parent
							
								
									b0e395c148
								
							
						
					
					
						commit
						62ab9f506a
					
				@ -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.
 | 
			
		||||
 | 
			
		||||
@ -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{}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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.
 | 
			
		||||
@ -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 {
 | 
			
		||||
@ -154,6 +164,7 @@ func (tApp TestApp) InitializeFromGenesisStatesWithTimeAndChainID(genTime time.T
 | 
			
		||||
					MaxGas:   20000000,
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			InitialHeight: initialHeight,
 | 
			
		||||
		},
 | 
			
		||||
	)
 | 
			
		||||
	tApp.Commit()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user