Documentation
¶
Overview ¶
Package keeper provides methods to initialize SDK keepers with local storage for test purposes
Index ¶
- Variables
- func LaunchKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, address.Codec)
- func ModuleAccountAddrs(maccPerms map[string][]string) map[string]bool
- func MonitoringcKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, address.Codec)
- func MonitoringpKeeper(t testing.TB) (*keeper.Keeper, sdk.Context, address.Codec)
- func NewTestSetup(t testing.TB, options ...SetupOption) (sdk.Context, TestKeepers, TestMsgServers)
- func NewTestSetupWithIBCMocks(t testing.TB, connectionMock []Connection, channelMock []Channel) (sdk.Context, TestKeepers, TestMsgServers)
- func NewTestSetupWithIBCMocksMonitoringp(t testing.TB, connectionMock []Connection, channelMock []Channel) (sdk.Context, TestKeepers, TestMsgServers)
- func NewTestSetupWithMonitoringp(t testing.TB) (sdk.Context, TestKeepers, TestMsgServers)
- func ParticipationKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)
- func ProfileKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)
- func ProjectKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)
- func RewardKeeper(t testing.TB) (keeper.Keeper, sdk.Context, address.Codec)
- func WithLaunchHooksMock() func(*setupOptions)
- type Channel
- type ChannelMock
- func (c ChannelMock) ChanCloseInit(_ sdk.Context, _, _ string, _ *capabilitytypes.Capability) error
- func (c ChannelMock) GetChannel(_ sdk.Context, _, channelID string) (channel channeltypes.Channel, found bool)
- func (c ChannelMock) GetNextSequenceSend(_ sdk.Context, _, _ string) (uint64, bool)
- func (c ChannelMock) SendPacket(_ sdk.Context, _ *capabilitytypes.Capability, _ string, _ string, ...) (uint64, error)
- func (c ChannelMock) WriteAcknowledgement(_ sdk.Context, _ *capabilitytypes.Capability, _ exported.PacketI, ...) error
- type Connection
- type ConnectionMock
- type HookMocks
- type LaunchHooks
- type ProtocolVersionSetter
- type SetupOption
- type TestKeepers
- func (tk TestKeepers) CreateFixedPriceAuction(ctx sdk.Context, r *rand.Rand, auctioneer string, sellingCoin sdk.Coin, ...) uint64
- func (tk TestKeepers) Delegate(ctx sdk.Context, r *rand.Rand, address string, amt int64) (stakingtypes.Delegation, error)
- func (tk TestKeepers) DelegateN(ctx sdk.Context, r *rand.Rand, address string, shareAmt int64, n int) ([]stakingtypes.Delegation, sdkmath.LegacyDec, error)
- func (tk TestKeepers) Mint(ctx sdk.Context, address string, coins sdk.Coins)
- func (tk TestKeepers) MintModule(ctx sdk.Context, moduleAcc string, coins sdk.Coins)
- type TestMsgServers
- func (tm TestMsgServers) CreateChain(ctx context.Context, r *rand.Rand, coordAddress string, genesisURL string, ...) uint64
- func (tm TestMsgServers) CreateCoordinator(ctx context.Context, r *rand.Rand) (id uint64, address sdk.AccAddress)
- func (tm TestMsgServers) CreateCoordinatorWithAddr(ctx context.Context, r *rand.Rand, address string) (uint64, sdk.AccAddress)
- func (tm TestMsgServers) CreateProject(ctx context.Context, r *rand.Rand, coordinatorAddress string) (id uint64)
Constants ¶
This section is empty.
Variables ¶
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 ModuleAccountAddrs ¶
ModuleAccountAddrs returns all the app's module account addresses.
func MonitoringcKeeper ¶
func MonitoringpKeeper ¶
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 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 ¶
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 ¶
func (c ChannelMock) WriteAcknowledgement(_ sdk.Context, _ *capabilitytypes.Capability, _ exported.PacketI, _ exported.Acknowledgement) error
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) MintModule ¶
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