keeper

package
v0.0.0-...-cc3bc86 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 87 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CrosschainMocksAll = CrosschainMockOptions{
		UseBankMock:          true,
		UseAccountMock:       true,
		UseStakingMock:       true,
		UseObserverMock:      true,
		UseFungibleMock:      true,
		UseAuthorityMock:     true,
		UseLightclientMock:   true,
		UseIBCCrosschainMock: true,
	}
	CrosschainNoMocks = CrosschainMockOptions{}
)
View Source
var (
	FungibleMocksAll = FungibleMockOptions{
		UseBankMock:      true,
		UseAccountMock:   true,
		UseObserverMock:  true,
		UseEVMMock:       true,
		UseAuthorityMock: true,
	}
	FungibleNoMocks = FungibleMockOptions{}
)
View Source
var (
	IBCCrosschainMocksAll = IBCCroscchainMockOptions{
		UseCrosschainMock:  true,
		UseIBCTransferMock: true,
	}
	IBCCrosschainNoMocks = IBCCroscchainMockOptions{}
)
View Source
var (
	LightclientMocksAll = LightclientMockOptions{
		UseAuthorityMock: true,
	}
	LightclientNoMocks = LightclientMockOptions{}
)
View Source
var (
	ObserverMocksAll = ObserverMockOptions{
		UseStakingMock:     true,
		UseSlashingMock:    true,
		UseAuthorityMock:   true,
		UseLightclientMock: true,
	}
	ObserverNoMocks = ObserverMockOptions{}
)
View Source
var (
	AuthorityGovAddress = sample.Bech32AccAddress()
)

Functions

func AccountKeeper

func AccountKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
) authkeeper.AccountKeeper

AccountKeeper instantiates an account keeper for testing purposes

func AuthorityKeeper

func AuthorityKeeper(t testing.TB) (*keeper.Keeper, sdk.Context)

AuthorityKeeper instantiates an authority keeper for testing purposes

func BankKeeper

func BankKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	authKeeper authkeeper.AccountKeeper,
) bankkeeper.Keeper

BankKeeper instantiates a bank keeper for testing purposes

func CapabilityKeeper

func CapabilityKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
) *capabilitykeeper.Keeper

CapabilityKeeper instantiates a capability keeper for testing purposes

func ConsensusKeeper

func ConsensusKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
) consensuskeeper.Keeper

func CrosschainKeeper

func CrosschainKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

CrosschainKeeper initializes a crosschain keeper for testing purposes

func CrosschainKeeperAllMocks

func CrosschainKeeperAllMocks(t testing.TB) (*keeper.Keeper, sdk.Context)

CrosschainKeeperAllMocks initializes a crosschain keeper for testing purposes with all mocks

func CrosschainKeeperWithMocks

func CrosschainKeeperWithMocks(
	t testing.TB,
	mockOptions CrosschainMockOptions,
) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

CrosschainKeeperWithMocks initializes a crosschain keeper for testing purposes with option to mock specific keepers

func DistributionKeeper

func DistributionKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	authKeeper authkeeper.AccountKeeper,
	bankKeeper bankkeeper.Keeper,
	stakingKeeper *stakingkeeper.Keeper,
) distrkeeper.Keeper

DistributionKeeper instantiates a distribution keeper for testing purposes

func EVMKeeper

func EVMKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	authKeeper authkeeper.AccountKeeper,
	bankKeeper bankkeeper.Keeper,
	stakingKeeper stakingkeeper.Keeper,
	feemarketKeeper feemarketkeeper.Keeper,
	paramKeeper paramskeeper.Keeper,
	consensusKeeper consensuskeeper.Keeper,
) *evmkeeper.Keeper

EVMKeeper instantiates an evm keeper for testing purposes

func EmissionKeeperWithMockOptions

func EmissionKeeperWithMockOptions(
	t testing.TB,
	mockOptions EmissionMockOptions,
) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

func EmissionsKeeper

func EmissionsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

func FeeMarketKeeper

func FeeMarketKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	paramKeeper paramskeeper.Keeper,
	consensusKeeper consensuskeeper.Keeper,
) feemarketkeeper.Keeper

FeeMarketKeeper instantiates a feemarket keeper for testing purposes

func FungibleKeeper

func FungibleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

FungibleKeeper initializes a fungible keeper for testing purposes

func FungibleKeeperAllMocks

func FungibleKeeperAllMocks(t testing.TB) (*keeper.Keeper, sdk.Context)

FungibleKeeperAllMocks initializes a fungible keeper for testing purposes with all keeper mocked

func FungibleKeeperWithMocks

func FungibleKeeperWithMocks(
	t testing.TB,
	mockOptions FungibleMockOptions,
) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

FungibleKeeperWithMocks initializes a fungible keeper for testing purposes with option to mock specific keepers

func GetCrosschainAccountMock

func GetCrosschainAccountMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainAccountKeeper

func GetCrosschainAuthorityMock

func GetCrosschainAuthorityMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainAuthorityKeeper

GetCrosschainAuthorityMock returns a new crosschain authority keeper mock

func GetCrosschainBankMock

func GetCrosschainBankMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainBankKeeper

func GetCrosschainFungibleMock

func GetCrosschainFungibleMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainFungibleKeeper

func GetCrosschainLightclientMock

func GetCrosschainLightclientMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainLightclientKeeper

GetCrosschainLightclientMock returns a new crosschain lightclient keeper mock

func GetCrosschainObserverMock

func GetCrosschainObserverMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainObserverKeeper

func GetCrosschainStakingMock

func GetCrosschainStakingMock(t testing.TB, keeper *keeper.Keeper) *crosschainmocks.CrosschainStakingKeeper

func GetEmissionsBankMock

func GetEmissionsBankMock(t testing.TB, keeper *keeper.Keeper) *emissionsmocks.EmissionBankKeeper

func GetEmissionsStakingMock

func GetEmissionsStakingMock(t testing.TB, keeper *keeper.Keeper) *emissionsmocks.EmissionStakingKeeper

func GetFungibleAccountMock

func GetFungibleAccountMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleAccountKeeper

func GetFungibleAuthorityMock

func GetFungibleAuthorityMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleAuthorityKeeper

GetFungibleAuthorityMock returns a new fungible authority keeper mock

func GetFungibleBankMock

func GetFungibleBankMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleBankKeeper

func GetFungibleObserverMock

func GetFungibleObserverMock(t testing.TB, keeper *keeper.Keeper) *fungiblemocks.FungibleObserverKeeper

func GetLightclientAuthorityMock

func GetLightclientAuthorityMock(t testing.TB, keeper *keeper.Keeper) *lightclientmocks.LightclientAuthorityKeeper

GetLightclientAuthorityMock returns a new lightclient authority keeper mock

func GetObserverAuthorityMock

func GetObserverAuthorityMock(t testing.TB, keeper *keeper.Keeper) *observermocks.ObserverAuthorityKeeper

GetObserverAuthorityMock returns a new observer authority keeper mock

func GetObserverLightclientMock

func GetObserverLightclientMock(t testing.TB, keeper *keeper.Keeper) *observermocks.ObserverLightclientKeeper

GetObserverLightclientMock returns a new observer lightclient keeper mock

func IBCCrosschainKeeper

func IBCCrosschainKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

IBCCrosschainKeeper creates a new ibccrosschain keeper with no mocked keepers

func IBCCrosschainKeeperAllMocks

func IBCCrosschainKeeperAllMocks(t testing.TB) (*keeper.Keeper, sdk.Context)

IBCCrosschainKeeperAllMocks creates a new ibccrosschain keeper with all mocked keepers

func IBCCrosschainKeeperWithMocks

func IBCCrosschainKeeperWithMocks(
	t testing.TB,
	mockOptions IBCCroscchainMockOptions,
) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

func IBCKeeper

func IBCKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	paramKeeper paramskeeper.Keeper,
	stakingKeeper stakingkeeper.Keeper,
	uppgradeKeeper upgradekeeper.Keeper,
	capabilityKeeper capabilitykeeper.Keeper,
) *ibckeeper.Keeper

IBCKeeper instantiates an ibc keeper for testing purposes

func LightclientKeeper

func LightclientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

LightclientKeeper instantiates an lightclient keeper for testing purposes

func LightclientKeeperWithMocks

func LightclientKeeperWithMocks(
	t testing.TB,
	mockOptions LightclientMockOptions,
) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

LightclientKeeperWithMocks instantiates a lightclient keeper for testing purposes with the option to mock specific keepers

func MockCctxByNonce

func MockCctxByNonce(
	t *testing.T,
	ctx sdk.Context,
	k keeper.Keeper,
	observerKeeper *crosschainmocks.CrosschainObserverKeeper,
	cctxStatus types.CctxStatus,
	isErr bool,
)

MockCctxByNonce is a utility function using observer mock to returns a cctx of the given status from crosschain keeper mocks the methods called by CctxByNonce to directly return the given cctx or error

func MockCheckAuthorization

func MockCheckAuthorization(m *mock.Mock, msg sdk.Msg, authorizationResult error)

MockCheckAuthorization mocks the CheckAuthorization method of the authority keeper.

func MockFailedGetSupportedChainFromChainID

func MockFailedGetSupportedChainFromChainID(m *crosschainmocks.CrosschainObserverKeeper, senderChain chains.Chain)

func MockGetChainList

func MockGetChainList(m *mock.Mock, chainList []chains.Chain)

MockGetChainList mocks the GetAdditionalChainList method of the authority keeper.

func MockGetChainListEmpty

func MockGetChainListEmpty(m *mock.Mock)

MockGetChainListEmpty mocks the GetAdditionalChainList method of the authority keeper.

func MockGetRevertGasLimitForERC20

func MockGetRevertGasLimitForERC20(
	m *crosschainmocks.CrosschainFungibleKeeper,
	asset string,
	senderChain chains.Chain,
	returnVal int64,
)

func MockGetSupportedChainFromChainID

func MockGetSupportedChainFromChainID(m *crosschainmocks.CrosschainObserverKeeper, senderChain chains.Chain)

func MockRevertForHandleEVMDeposit

func MockRevertForHandleEVMDeposit(
	m *crosschainmocks.CrosschainFungibleKeeper,
	receiver ethcommon.Address,
	amount *big.Int,
	senderChainID int64,
	errDeposit error,
)

func MockSaveOutbound

func MockSaveOutbound(
	m *crosschainmocks.CrosschainObserverKeeper,
	ctx sdk.Context,
	cctx *types.CrossChainTx,
	tss observertypes.TSS,
	expectedNumberOfOutboundParams int,
)

func MockSaveOutboundNewRevertCreated

func MockSaveOutboundNewRevertCreated(
	m *crosschainmocks.CrosschainObserverKeeper,
	ctx sdk.Context,
	cctx *types.CrossChainTx,
	tss observertypes.TSS,
	expectedNumberOfOutboundParams int,
)

func MockUpdateNonce

func MockUpdateNonce(m *crosschainmocks.CrosschainObserverKeeper, senderChain chains.Chain) (nonce uint64)

func MockVoteOnOutboundFailedBallot

func MockVoteOnOutboundFailedBallot(
	m *crosschainmocks.CrosschainObserverKeeper,
	ctx sdk.Context,
	cctx *types.CrossChainTx,
	senderChain chains.Chain,
	observer string,
)

func MockVoteOnOutboundSuccessBallot

func MockVoteOnOutboundSuccessBallot(
	m *crosschainmocks.CrosschainObserverKeeper,
	ctx sdk.Context,
	cctx *types.CrossChainTx,
	senderChain chains.Chain,
	observer string,
)

func ModuleAccountAddrs

func ModuleAccountAddrs(maccPerms map[string][]string) map[string]bool

ModuleAccountAddrs returns all the app's module account addresses.

func NewCodec

func NewCodec() *codec.ProtoCodec

func NewContext

func NewContext(stateStore sdk.MultiStore) sdk.Context

NewContext creates a new sdk.Context for testing purposes with initialized header

func ObserverKeeper

func ObserverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

ObserverKeeper instantiates an observer keeper for testing purposes

func ObserverKeeperWithMocks

func ObserverKeeperWithMocks(
	t testing.TB,
	mockOptions ObserverMockOptions,
) (*keeper.Keeper, sdk.Context, SDKKeepers, ZetaKeepers)

ObserverKeeperWithMocks instantiates an observer keeper for testing purposes with the option to mock specific keepers

func ParamsKeeper

func ParamsKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
) paramskeeper.Keeper

ParamsKeeper instantiates a param keeper for testing purposes TODO: remove https://github.com/zeta-chain/node/issues/848

func SetAdminPolicies

func SetAdminPolicies(ctx sdk.Context, ak *keeper.Keeper) string

func SlashingKeeper

func SlashingKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	stakingKeeper stakingkeeper.Keeper,
) slashingkeeper.Keeper

SlashingKeeper instantiates a slashing keeper for testing purposes

func StakingKeeper

func StakingKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	authKeeper authkeeper.AccountKeeper,
	bankKeeper bankkeeper.Keeper,
) stakingkeeper.Keeper

StakingKeeper instantiates a staking keeper for testing purposes

func TransferKeeper

func TransferKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
	paramKeeper paramskeeper.Keeper,
	ibcKeeper *ibckeeper.Keeper,
	authKeeper authkeeper.AccountKeeper,
	bankKeeper bankkeeper.Keeper,
	capabilityKeeper capabilitykeeper.Keeper,
	ibcRouter *porttypes.Router,
) ibctransferkeeper.Keeper

TransferKeeper instantiates an ibc transfer keeper for testing purposes

func UpgradeKeeper

func UpgradeKeeper(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
) upgradekeeper.Keeper

UpgradeKeeper instantiates an upgrade keeper for testing purposes

Types

type CrosschainMockOptions

type CrosschainMockOptions struct {
	UseBankMock          bool
	UseAccountMock       bool
	UseStakingMock       bool
	UseObserverMock      bool
	UseFungibleMock      bool
	UseAuthorityMock     bool
	UseLightclientMock   bool
	UseIBCCrosschainMock bool
}

type EmissionMockOptions

type EmissionMockOptions struct {
	UseBankMock       bool
	UseStakingMock    bool
	UseObserverMock   bool
	UseAccountMock    bool
	SkipSettingParams bool
}

type FungibleMockEVMKeeper

type FungibleMockEVMKeeper struct {
	*fungiblemocks.FungibleEVMKeeper
}

func GetFungibleEVMMock

func GetFungibleEVMMock(t testing.TB, keeper *keeper.Keeper) *FungibleMockEVMKeeper

func (*FungibleMockEVMKeeper) MockEVMFailCallOnce

func (m *FungibleMockEVMKeeper) MockEVMFailCallOnce()

func (*FungibleMockEVMKeeper) MockEVMSuccessCallOnce

func (m *FungibleMockEVMKeeper) MockEVMSuccessCallOnce()

func (*FungibleMockEVMKeeper) MockEVMSuccessCallOnceWithReturn

func (m *FungibleMockEVMKeeper) MockEVMSuccessCallOnceWithReturn(ret *evmtypes.MsgEthereumTxResponse)

func (*FungibleMockEVMKeeper) MockEVMSuccessCallTimes

func (m *FungibleMockEVMKeeper) MockEVMSuccessCallTimes(times int)

func (*FungibleMockEVMKeeper) MockEVMSuccessCallTimesWithReturn

func (m *FungibleMockEVMKeeper) MockEVMSuccessCallTimesWithReturn(ret *evmtypes.MsgEthereumTxResponse, times int)

func (*FungibleMockEVMKeeper) SetupMockEVMKeeperForSystemContractDeployment

func (m *FungibleMockEVMKeeper) SetupMockEVMKeeperForSystemContractDeployment()

type FungibleMockOptions

type FungibleMockOptions struct {
	UseBankMock      bool
	UseAccountMock   bool
	UseObserverMock  bool
	UseEVMMock       bool
	UseAuthorityMock bool
}

type IBCCroscchainMockOptions

type IBCCroscchainMockOptions struct {
	UseCrosschainMock  bool
	UseIBCTransferMock bool
}

type LightclientMockOptions

type LightclientMockOptions struct {
	UseAuthorityMock bool
}

LightclientMockOptions represents options for instantiating a lightclient keeper with mocks

type ObserverMockOptions

type ObserverMockOptions struct {
	UseStakingMock     bool
	UseSlashingMock    bool
	UseAuthorityMock   bool
	UseLightclientMock bool
}

ObserverMockOptions represents options for instantiating an observer keeper with mocks

type ObserverMockSlashingKeeper

type ObserverMockSlashingKeeper struct {
	*observermocks.ObserverSlashingKeeper
}

ObserverMockSlashingKeeper is a wrapper of the observer slashing keeper mock that add methods to mock the IsTombstoned method

func GetObserverSlashingMock

func GetObserverSlashingMock(t testing.TB, keeper *keeper.Keeper) *ObserverMockSlashingKeeper

GetObserverSlashingMock returns a new observer slashing keeper mock

func (*ObserverMockSlashingKeeper) MockIsTombstoned

func (m *ObserverMockSlashingKeeper) MockIsTombstoned(isTombstoned bool)

type ObserverMockStakingKeeper

type ObserverMockStakingKeeper struct {
	*observermocks.ObserverStakingKeeper
}

ObserverMockStakingKeeper is a wrapper of the observer staking keeper mock that add methods to mock the GetValidator method

func GetObserverStakingMock

func GetObserverStakingMock(t testing.TB, keeper *keeper.Keeper) *ObserverMockStakingKeeper

GetObserverStakingMock returns a new observer staking keeper mock

func (*ObserverMockStakingKeeper) MockGetValidator

func (m *ObserverMockStakingKeeper) MockGetValidator(validator stakingtypes.Validator)

type ProtocolVersionSetter

type ProtocolVersionSetter struct{}

ProtocolVersionSetter mock

func (ProtocolVersionSetter) SetProtocolVersion

func (vs ProtocolVersionSetter) SetProtocolVersion(uint64)

type SDKKeepers

type SDKKeepers struct {
	ParamsKeeper         paramskeeper.Keeper
	AuthKeeper           authkeeper.AccountKeeper
	BankKeeper           bankkeeper.Keeper
	StakingKeeper        stakingkeeper.Keeper
	SlashingKeeper       slashingkeeper.Keeper
	FeeMarketKeeper      feemarketkeeper.Keeper
	EvmKeeper            *evmkeeper.Keeper
	CapabilityKeeper     *capabilitykeeper.Keeper
	IBCKeeper            *ibckeeper.Keeper
	TransferKeeper       ibctransferkeeper.Keeper
	ScopedIBCKeeper      capabilitykeeper.ScopedKeeper
	ScopedTransferKeeper capabilitykeeper.ScopedKeeper

	IBCRouter *porttypes.Router
}

SDKKeepers is a struct containing regular SDK module keepers for test purposes

func NewSDKKeepers

func NewSDKKeepers(
	cdc codec.Codec,
	db *tmdb.MemDB,
	ss store.CommitMultiStore,
) SDKKeepers

NewSDKKeepers instantiates regular Cosmos SDK keeper such as staking with local storage for testing purposes

func NewSDKKeepersWithKeys

func NewSDKKeepersWithKeys(
	cdc codec.Codec,
	keys map[string]*storetypes.KVStoreKey,
	memKeys map[string]*storetypes.MemoryStoreKey,
	tKeys map[string]*storetypes.TransientStoreKey,
	allKeys map[string]storetypes.StoreKey,
) SDKKeepers

NewSDKKeepers instantiates regular Cosmos SDK keeper such as staking with local storage for testing purposes

func (SDKKeepers) InitBlockProposer

func (sdkk SDKKeepers) InitBlockProposer(t testing.TB, ctx sdk.Context) sdk.Context

InitBlockProposer initialize the block proposer for test purposes with an associated validator

func (SDKKeepers) InitGenesis

func (sdkk SDKKeepers) InitGenesis(ctx sdk.Context)

InitGenesis initializes the test modules genesis state

type ZetaKeepers

type ZetaKeepers struct {
	AuthorityKeeper     *authoritykeeper.Keeper
	CrosschainKeeper    *crosschainkeeper.Keeper
	EmissionsKeeper     *emissionskeeper.Keeper
	FungibleKeeper      *fungiblekeeper.Keeper
	ObserverKeeper      *observerkeeper.Keeper
	LightclientKeeper   *lightclientkeeper.Keeper
	IBCCrosschainKeeper *ibccrosschainkeeper.Keeper
}

ZetaKeepers is a struct containing Zeta module keepers for test purposes

func (ZetaKeepers) InitGenesis

func (zk ZetaKeepers) InitGenesis(ctx sdk.Context)

InitGenesis initializes the test modules genesis state for defined Zeta modules

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL