Documentation ¶
Overview ¶
Package keeper provides methods to initialize SDK keepers with local storage for test purposes
Index ¶
- Variables
- func ModuleAccountAddrs(maccPerms map[string][]string) map[string]bool
- 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 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 HooksMocks
- 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
- func (tk TestKeepers) DelegateN(ctx sdk.Context, r *rand.Rand, address string, shareAmt int64, n int) ([]stakingtypes.Delegation, sdk.Dec)
- 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
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 ¶ added in v0.2.0
ModuleAccountAddrs returns all the app's module account addresses.
func NewTestSetup ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
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 ¶ added in v0.2.0
func NewTestSetupWithMonitoringp(t testing.TB) (sdk.Context, TestKeepers, TestMsgServers)
NewTestSetupWithMonitoringp returns a test keepers struct and servers struct with the monitoring provider module
func WithLaunchHooksMock ¶ added in v0.3.0
func WithLaunchHooksMock() func(*setupOptions)
WithHooksMock sets a mock for the hooks in testing launch keeper
Types ¶
type Channel ¶ added in v0.2.0
type Channel struct { ChannelID string Channel channeltypes.Channel }
Channel is an IBC channel end associated to a channel ID
type ChannelMock ¶ added in v0.2.0
type ChannelMock struct {
// contains filtered or unexported fields
}
ChannelMock represents a mocked IBC channel keeper used for test purposes
func NewChannelMock ¶ added in v0.2.0
func NewChannelMock(channels []Channel) (c ChannelMock)
NewChannelMock initializes a new channel mock
func (ChannelMock) ChanCloseInit ¶ added in v0.2.0
func (c ChannelMock) ChanCloseInit(_ sdk.Context, _, _ string, _ *capabilitytypes.Capability) error
ChanCloseInit implements ChannelKeeper
func (ChannelMock) GetChannel ¶ added in v0.2.0
func (c ChannelMock) GetChannel(_ sdk.Context, _, channelID string) (channel channeltypes.Channel, found bool)
GetChannel implements ChannelKeeper
func (ChannelMock) GetNextSequenceSend ¶ added in v0.2.0
GetNextSequenceSend implements ChannelKeeper returns true for all cases
func (ChannelMock) SendPacket ¶ added in v0.2.0
func (c ChannelMock) SendPacket( _ sdk.Context, _ *capabilitytypes.Capability, _ string, _ string, _ clienttypes.Height, _ uint64, _ []byte, ) (uint64, error)
SendPacket implements ChannelKeeper
func (ChannelMock) WriteAcknowledgement ¶ added in v0.2.0
func (c ChannelMock) WriteAcknowledgement(_ sdk.Context, _ *capabilitytypes.Capability, _ exported.PacketI, _ exported.Acknowledgement) error
WriteAcknowledgement implements ChannelKeeper
type Connection ¶ added in v0.2.0
type Connection struct { ConnID string Conn connectiontypes.ConnectionEnd }
Connection is an IBC connection end associated to a connection ID
type ConnectionMock ¶ added in v0.2.0
type ConnectionMock struct {
// contains filtered or unexported fields
}
ConnectionMock represents a mocked IBC connection keeper used for test purposes
func NewConnectionMock ¶ added in v0.2.0
func NewConnectionMock(conns []Connection) (c ConnectionMock)
NewConnectionMock initializes a new connection mock
func (ConnectionMock) GetConnection ¶ added in v0.2.0
func (c ConnectionMock) GetConnection(_ sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, bool)
GetConnection implements ConnectionKeeper
type HooksMocks ¶ added in v0.3.0
type HooksMocks struct {
LaunchHooksMock *mocks.LaunchHooks
}
HookMocks holds mocks for the module hooks
type LaunchHooks ¶ added in v0.3.0
type LaunchHooks interface { launchtypes.LaunchHooks }
type ProtocolVersionSetter ¶ added in v0.3.0
type ProtocolVersionSetter struct{}
func (ProtocolVersionSetter) SetProtocolVersion ¶ added in v0.3.0
func (vs ProtocolVersionSetter) SetProtocolVersion(uint64)
type SetupOption ¶ added in v0.3.0
type SetupOption func(*setupOptions)
SetupOption represents an option that can be provided to NewTestSetup
type TestKeepers ¶ added in v0.2.0
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 HooksMocks }
TestKeepers holds all keepers used during keeper tests for all modules
func (TestKeepers) CreateFixedPriceAuction ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (tk TestKeepers) Delegate(ctx sdk.Context, r *rand.Rand, address string, amt int64) stakingtypes.Delegation
Delegate creates a sample delegation and sets it in the keeper
func (TestKeepers) DelegateN ¶ added in v0.2.0
func (tk TestKeepers) DelegateN(ctx sdk.Context, r *rand.Rand, address string, shareAmt int64, n int) ([]stakingtypes.Delegation, sdk.Dec)
DelegateN creates N delegations from the same address
func (TestKeepers) MintModule ¶ added in v0.2.0
MintModule mints the specified coins into the module account balance
type TestMsgServers ¶ added in v0.2.0
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) CreateCoordinator ¶ added in v0.2.0
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