keeper

package
v0.0.0-...-abdbe5d Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 62 Imported by: 0

Documentation

Overview

Package keeper provides methods to initialize SDK keepers with local storage for test purposes

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExampleTimestamp is a timestamp used as the current time for the context of the keepers returned from the package
	ExampleTimestamp = time.Date(2020, time.January, 1, 12, 0, 0, 0, time.UTC)

	// ExampleHeight is a block height used as the current block height for the context of test keeper
	ExampleHeight = int64(1111)
)

Functions

func LaunchKeeper

func LaunchKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, address.Codec)

func ModuleAccountAddrs

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

ModuleAccountAddrs returns all the app's module account addresses.

func MonitoringcKeeper

func MonitoringcKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, address.Codec)

func MonitoringpKeeper

func MonitoringpKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, address.Codec)

func NewTestSetup

func NewTestSetup(t testing.TB, options ...SetupOption) (sdk.Context, TestKeepers, TestMsgServers)

NewTestSetup returns initialized instances of all the keepers and message servers of the modules

func NewTestSetupWithIBCMocks

func NewTestSetupWithIBCMocks(
	t testing.TB,
	connectionMock []Connection,
	channelMock []Channel,
) (sdk.Context, TestKeepers, TestMsgServers)

NewTestSetupWithIBCMocks returns a keeper of the monitoring consumer module for testing purpose with mocks for IBC keepers

func NewTestSetupWithIBCMocksMonitoringp

func NewTestSetupWithIBCMocksMonitoringp(
	t testing.TB,
	connectionMock []Connection,
	channelMock []Channel,
) (sdk.Context, TestKeepers, TestMsgServers)

NewTestSetupWithIBCMocksMonitoringp returns a keeper of the monitoring provider module for testing purpose with mocks for IBC keepers

func NewTestSetupWithMonitoringp

func NewTestSetupWithMonitoringp(t testing.TB) (sdk.Context, TestKeepers, TestMsgServers)

NewTestSetupWithMonitoringp returns a test keepers struct and servers struct with the monitoring provider module

func ParticipationKeeper

func ParticipationKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)

func ProfileKeeper

func ProfileKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)

func ProjectKeeper

func ProjectKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)

func RewardKeeper

func RewardKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)

func WithLaunchHooksMock

func WithLaunchHooksMock() func(*setupOptions)

WithLaunchHooksMock sets a mock for the hooks in testing launch keeper

Types

type Channel

type Channel struct {
	ChannelID string
	Channel   channeltypes.Channel
}

Channel is an IBC channel end associated to a channel ID

type ChannelMock

type ChannelMock struct {
	// contains filtered or unexported fields
}

ChannelMock represents a mocked IBC channel keeper used for test purposes

func NewChannelMock

func NewChannelMock(channels []Channel) (c ChannelMock)

NewChannelMock initializes a new channel mock

func (ChannelMock) ChanCloseInit

func (c ChannelMock) ChanCloseInit(_ sdk.Context, _, _ string, _ *capabilitytypes.Capability) error

ChanCloseInit implements ChannelKeeper

func (ChannelMock) GetChannel

func (c ChannelMock) GetChannel(_ sdk.Context, _, channelID string) (channel channeltypes.Channel, found bool)

GetChannel implements ChannelKeeper

func (ChannelMock) GetNextSequenceSend

func (c ChannelMock) GetNextSequenceSend(_ sdk.Context, _, _ string) (uint64, bool)

GetNextSequenceSend implements ChannelKeeper returns true for all cases

func (ChannelMock) SendPacket

func (c ChannelMock) SendPacket(
	_ sdk.Context,
	_ *capabilitytypes.Capability,
	_ string,
	_ string,
	_ clienttypes.Height,
	_ uint64,
	_ []byte,
) (uint64, error)

SendPacket implements ChannelKeeper

func (ChannelMock) WriteAcknowledgement

WriteAcknowledgement implements ChannelKeeper

type Connection

type Connection struct {
	ConnID string
	Conn   connectiontypes.ConnectionEnd
}

Connection is an IBC connection end associated to a connection ID

type ConnectionMock

type ConnectionMock struct {
	// contains filtered or unexported fields
}

ConnectionMock represents a mocked IBC connection keeper used for test purposes

func NewConnectionMock

func NewConnectionMock(conns []Connection) (c ConnectionMock)

NewConnectionMock initializes a new connection mock

func (ConnectionMock) GetConnection

func (c ConnectionMock) GetConnection(_ sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, bool)

GetConnection implements ConnectionKeeper

type HookMocks

type HookMocks struct {
	LaunchHooksMock *mocks.LaunchHooks
}

HookMocks holds mocks for the module hooks

type LaunchHooks

type LaunchHooks interface {
	launchtypes.LaunchHooks
}

type ProtocolVersionSetter

type ProtocolVersionSetter struct{}

func (ProtocolVersionSetter) SetProtocolVersion

func (vs ProtocolVersionSetter) SetProtocolVersion(uint64)

type SetupOption

type SetupOption func(*setupOptions)

SetupOption represents an option that can be provided to NewTestSetup

type TestKeepers

type TestKeepers struct {
	T                        testing.TB
	ProjectKeeper            projectkeeper.Keeper
	LaunchKeeper             *launchkeeper.Keeper
	ProfileKeeper            profilekeeper.Keeper
	RewardKeeper             rewardkeeper.Keeper
	MonitoringConsumerKeeper *monitoringckeeper.Keeper
	MonitoringProviderKeeper *monitoringpkeeper.Keeper
	AccountKeeper            authkeeper.AccountKeeper
	BankKeeper               bankkeeper.Keeper
	DistrKeeper              distrkeeper.Keeper
	IBCKeeper                *ibckeeper.Keeper
	StakingKeeper            *stakingkeeper.Keeper
	FundraisingKeeper        fundraisingkeeper.Keeper
	ParticipationKeeper      participationkeeper.Keeper
	ClaimKeeper              claimkeeper.Keeper
	HooksMocks               HookMocks
}

TestKeepers holds all keepers used during keeper tests for all modules

func (TestKeepers) CreateFixedPriceAuction

func (tk TestKeepers) CreateFixedPriceAuction(
	ctx sdk.Context,
	r *rand.Rand,
	auctioneer string,
	sellingCoin sdk.Coin,
	startTime,
	endTime time.Time,
) uint64

CreateFixedPriceAuction makes the provided address create a fixed price auction with the specified selling coin and start time. Returns the ID of the created auction.

func (TestKeepers) Delegate

func (tk TestKeepers) Delegate(ctx sdk.Context, r *rand.Rand, address string, amt int64) (stakingtypes.Delegation, error)

Delegate creates a sample delegation and sets it in the keeper

func (TestKeepers) DelegateN

func (tk TestKeepers) DelegateN(ctx sdk.Context, r *rand.Rand, address string, shareAmt int64, n int) ([]stakingtypes.Delegation, sdkmath.LegacyDec, error)

DelegateN creates N delegations from the same address

func (TestKeepers) Mint

func (tk TestKeepers) Mint(ctx sdk.Context, address string, coins sdk.Coins)

Mint mints the specified coins into the account balance

func (TestKeepers) MintModule

func (tk TestKeepers) MintModule(ctx sdk.Context, moduleAcc string, coins sdk.Coins)

MintModule mints the specified coins into the module account balance

type TestMsgServers

type TestMsgServers struct {
	T                testing.TB
	ProfileSrv       profiletypes.MsgServer
	LaunchSrv        launchtypes.MsgServer
	ProjectSrv       projecttypes.MsgServer
	RewardSrv        rewardtypes.MsgServer
	MonitoringcSrv   monitoringctypes.MsgServer
	ParticipationSrv participationtypes.MsgServer
	ClaimSrv         claimtypes.MsgServer
}

TestMsgServers holds all message servers used during keeper tests for all modules

func (TestMsgServers) CreateChain

func (tm TestMsgServers) CreateChain(ctx context.Context, r *rand.Rand, coordAddress string, genesisURL string, hasProject bool, projectID uint64) uint64

CreateChain creates a chain in the store and returns launch ID.

func (TestMsgServers) CreateCoordinator

func (tm TestMsgServers) CreateCoordinator(ctx context.Context, r *rand.Rand) (id uint64, address sdk.AccAddress)

CreateCoordinator creates a coordinator in the store and returns ID with associated address

func (TestMsgServers) CreateCoordinatorWithAddr

func (tm TestMsgServers) CreateCoordinatorWithAddr(ctx context.Context, r *rand.Rand, address string) (uint64, sdk.AccAddress)

CreateCoordinatorWithAddr creates a coordinator in the store and returns ID with associated address

func (TestMsgServers) CreateProject

func (tm TestMsgServers) CreateProject(ctx context.Context, r *rand.Rand, coordinatorAddress string) (id uint64)

CreateProject creates a coordinator in the store and returns ID with associated address

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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