Documentation
¶
Index ¶
- Variables
- func AddressAndDenomFromBalancesStore(key []byte) (sdk.AccAddress, string, error)
- func CopyConnectionAndClientToPath(path *ibctesting.Path, pathToCopy *ibctesting.Path) *ibctesting.Path
- func CreateRandomAccounts(numAccts int) []sdk.AccAddress
- func GenerateTestAddrs() (string, string)
- func GetAdminAddress() (address string, ok bool)
- func ICAPacketAcknowledgement(t *testing.T, msgType string, msgResponses []proto.Message) channeltypes.Acknowledgement
- func ICAPacketAcknowledgementLegacy(t *testing.T, msgType string, msgResponses []proto.Message) channeltypes.Acknowledgement
- func NewIcaPath(chainA *ibctesting.TestChain, chainB *ibctesting.TestChain, ...) *ibctesting.Path
- func NewTransferPath(chainA *ibctesting.TestChain, chainB *ibctesting.TestChain, ...) *ibctesting.Path
- func RunWithDifferentBechPrefix(bechPrefix string, function func())
- func SampleHostAddress() string
- func SampleStrideAddress() string
- func SetConfigBechPrefix(bechPrefix string)
- func SetupConfig()
- type AppTestHelper
- func (s *AppTestHelper) CheckEventTypeEmitted(eventType string) []sdk.Event
- func (s *AppTestHelper) CheckEventTypeNotEmitted(eventType string)
- func (s *AppTestHelper) CheckEventValueEmitted(eventType, attributeKey, expectedValue string)
- func (s *AppTestHelper) CheckEventValueNotEmitted(eventType, attributeKey, expectedValue string)
- func (s *AppTestHelper) CheckICATxNotSubmitted(portId, channelId string, icaFunction func() error)
- func (s *AppTestHelper) CheckICATxSubmitted(portId, channelId string, icaFunction func() error)
- func (s *AppTestHelper) CheckMultipleICATxSubmitted(portId, channelId string, icaFunction func() error)
- func (s *AppTestHelper) CompareCoins(expectedCoin sdk.Coin, actualCoin sdk.Coin, msg string)
- func (s *AppTestHelper) ConfirmUpgradeSucceeded(upgradeName string)
- func (s *AppTestHelper) CreateAndStoreIBCDenom(baseDenom string) (ibcDenom string)
- func (s *AppTestHelper) CreateICAChannel(owner string) (channelID, portID string)
- func (s *AppTestHelper) CreateTransferChannel(hostChainID string)
- func (s *AppTestHelper) ExtractAddressAndDenomFromBankPrefix(data []byte) (address, denom string)
- func (s *AppTestHelper) FundAccount(acc sdk.AccAddress, amount sdk.Coin)
- func (s *AppTestHelper) FundModuleAccount(moduleName string, amount sdk.Coin)
- func (s *AppTestHelper) GetBankStoreKeyPrefix(address, denom string) []byte
- func (s *AppTestHelper) GetIBCDenomTrace(denom string) transfertypes.DenomTrace
- func (s *AppTestHelper) MarshalledICS20PacketData() sdk.AccAddress
- func (s *AppTestHelper) MockClientAndConnection(chainId, clientId, connectionId string)
- func (s *AppTestHelper) MockClientLatestHeight(height uint64)
- func (s *AppTestHelper) MockICAChannel(connectionId, channelId, owner, address string)
- func (s *AppTestHelper) MustGetNextSequenceNumber(portId, channelId string) uint64
- func (s *AppTestHelper) RegisterInterchainAccountWithOrdering(endpoint *ibctesting.Endpoint, owner string)
- func (s *AppTestHelper) SetNewAccount(addr sdk.AccAddress)
- func (s *AppTestHelper) Setup()
- func (s *AppTestHelper) SetupIBCChains(hostChainID string)
- func (s *AppTestHelper) UpdateChannelState(portId, channelId string, channelState channeltypes.State)
- type SuitelessAppTestHelper
Constants ¶
This section is empty.
Variables ¶
var ( StrideChainID = "stride-test-1" ProviderChainID = "provider-test-1" TestIcaVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{ Version: icatypes.Version, ControllerConnectionId: ibctesting.FirstConnectionID, HostConnectionId: ibctesting.FirstConnectionID, Encoding: icatypes.EncodingProtobuf, TxType: icatypes.TxTypeSDKMultiMsg, })) )
Functions ¶
func AddressAndDenomFromBalancesStore ¶
func AddressAndDenomFromBalancesStore(key []byte) (sdk.AccAddress, string, error)
AddressAndDenomFromBalancesStore returns an account address and denom from a balances prefix store. The key must not contain the prefix BalancesPrefix as the prefix store iterator discards the actual prefix.
If invalid key is passed, AddressAndDenomFromBalancesStore returns ErrInvalidKey.
func CopyConnectionAndClientToPath ¶
func CopyConnectionAndClientToPath(path *ibctesting.Path, pathToCopy *ibctesting.Path) *ibctesting.Path
In ibctesting, there's no easy way to create a new channel on an existing connection To get around this, this helper function will copy the client/connection info from an existing channel We use this when creating ICA channels, because we want to reuse the same connections/clients from the transfer channel
func CreateRandomAccounts ¶
func CreateRandomAccounts(numAccts int) []sdk.AccAddress
Generate random account addresss
func GenerateTestAddrs ¶
Generates a valid and invalid test address (used for non-keeper tests)
func GetAdminAddress ¶
Grabs an admin address to test validate basic on admin txs
func ICAPacketAcknowledgement ¶
func ICAPacketAcknowledgement(t *testing.T, msgType string, msgResponses []proto.Message) channeltypes.Acknowledgement
Constructs an ICA Packet Acknowledgement compatible with ibc-go v5+
func ICAPacketAcknowledgementLegacy ¶
func ICAPacketAcknowledgementLegacy(t *testing.T, msgType string, msgResponses []proto.Message) channeltypes.Acknowledgement
Constructs an legacy ICA Packet Acknowledgement compatible with ibc-go version v4 and lower
func NewIcaPath ¶
func NewIcaPath(chainA *ibctesting.TestChain, chainB *ibctesting.TestChain, providerChain *ibctesting.TestChain) *ibctesting.Path
Creates an ICA channel between two chains
func NewTransferPath ¶
func NewTransferPath(chainA *ibctesting.TestChain, chainB *ibctesting.TestChain, providerChain *ibctesting.TestChain) *ibctesting.Path
Creates a transfer channel between two chains
func RunWithDifferentBechPrefix ¶
func RunWithDifferentBechPrefix(bechPrefix string, function func())
During setup, it's common to need to change the bech prefix temporarily The prefix is controlled by a global config so we need to update the prefix globally, call our respective function, and then reset it back to stride Note: We disable caching to prevent addresses from using the previously configured prefix
func SetConfigBechPrefix ¶
func SetConfigBechPrefix(bechPrefix string)
Sets the account, validator, and consensus address bech prefixes
func SetupConfig ¶
func SetupConfig()
Modifies sdk config to have stride address prefixes (used for non-keeper tests)
Types ¶
type AppTestHelper ¶
type AppTestHelper struct {
suite.Suite
App *app.StrideApp
HostApp *simapp.SimApp
ProviderApp e2e.ProviderApp
IbcEnabled bool
Coordinator *ibctesting.Coordinator
StrideChain *ibctesting.TestChain
HostChain *ibctesting.TestChain
ProviderChain *ibctesting.TestChain
TransferPath *ibctesting.Path
QueryHelper *baseapp.QueryServiceTestHelper
TestAccs []sdk.AccAddress
IcaAddresses map[string]string
Ctx sdk.Context
}
func (*AppTestHelper) CheckEventTypeEmitted ¶
func (s *AppTestHelper) CheckEventTypeEmitted(eventType string) []sdk.Event
Checks if an event was emitted
func (*AppTestHelper) CheckEventTypeNotEmitted ¶
func (s *AppTestHelper) CheckEventTypeNotEmitted(eventType string)
Checks that an event was not emitted
func (*AppTestHelper) CheckEventValueEmitted ¶
func (s *AppTestHelper) CheckEventValueEmitted(eventType, attributeKey, expectedValue string)
Checks that an event was emitted and that the value matches expectations
func (*AppTestHelper) CheckEventValueNotEmitted ¶
func (s *AppTestHelper) CheckEventValueNotEmitted(eventType, attributeKey, expectedValue string)
Checks that there was no event emitted that matches the event type, attribute, and value
func (*AppTestHelper) CheckICATxNotSubmitted ¶
func (s *AppTestHelper) CheckICATxNotSubmitted(portId, channelId string, icaFunction func() error)
Helper function to check if an ICA was NOT submitted by seeing if the sequence number did not increment
func (*AppTestHelper) CheckICATxSubmitted ¶
func (s *AppTestHelper) CheckICATxSubmitted(portId, channelId string, icaFunction func() error)
Helper function to check if an ICA was submitted by seeing if the sequence number incremented
func (*AppTestHelper) CheckMultipleICATxSubmitted ¶
func (s *AppTestHelper) CheckMultipleICATxSubmitted(portId, channelId string, icaFunction func() error)
Helper function to check if multiple ICA txs were submitted by seeing if the sequence number incremented by more than 1
func (*AppTestHelper) CompareCoins ¶
Helper function to compare coins with a more legible error
func (*AppTestHelper) ConfirmUpgradeSucceeded ¶
func (s *AppTestHelper) ConfirmUpgradeSucceeded(upgradeName string)
func (*AppTestHelper) CreateAndStoreIBCDenom ¶
func (s *AppTestHelper) CreateAndStoreIBCDenom(baseDenom string) (ibcDenom string)
Creates and stores an IBC denom from a base denom on transfer channel-0 This is only required for tests that use the transfer keeper and require that the IBC denom is present in the store
Returns the IBC hash
func (*AppTestHelper) CreateICAChannel ¶
func (s *AppTestHelper) CreateICAChannel(owner string) (channelID, portID string)
Creates an ICA channel through ibctesting Also creates a transfer channel is if hasn't been done yet
func (*AppTestHelper) CreateTransferChannel ¶
func (s *AppTestHelper) CreateTransferChannel(hostChainID string)
Creates clients, connections, and a transfer channel between stride and a host chain NOTE: This was previously done by calling s.Coordinator.Setup(path) However since SDK 50, that wont work as it requires that the bech prefix for the host chain to be "cosmos", and will fail during each transaction if it's not (and the prefix for unit tests is "stride") To get around this, instead of calling s.Coordinator.Setup(path), we call each handshake function explicitly and override the bech prefix on the relevant txs
func (*AppTestHelper) ExtractAddressAndDenomFromBankPrefix ¶
func (s *AppTestHelper) ExtractAddressAndDenomFromBankPrefix(data []byte) (address, denom string)
Extracts the address and denom from a bank store prefix Useful for testing balance ICQs as it can confirm that the serialized query request data has the proper address and denom
func (*AppTestHelper) FundAccount ¶
func (s *AppTestHelper) FundAccount(acc sdk.AccAddress, amount sdk.Coin)
Mints and sends coins to a user account
func (*AppTestHelper) FundModuleAccount ¶
func (s *AppTestHelper) FundModuleAccount(moduleName string, amount sdk.Coin)
Mints coins directly to a module account
func (*AppTestHelper) GetBankStoreKeyPrefix ¶
func (s *AppTestHelper) GetBankStoreKeyPrefix(address, denom string) []byte
Returns the bank store key prefix for an address and denom Useful for testing balance ICQs
func (*AppTestHelper) GetIBCDenomTrace ¶
func (s *AppTestHelper) GetIBCDenomTrace(denom string) transfertypes.DenomTrace
Get an IBC denom from it's native host denom This assumes the transfer channel is channel-0
func (*AppTestHelper) MarshalledICS20PacketData ¶
func (s *AppTestHelper) MarshalledICS20PacketData() sdk.AccAddress
func (*AppTestHelper) MockClientAndConnection ¶
func (s *AppTestHelper) MockClientAndConnection(chainId, clientId, connectionId string)
Helper function to mock out a client and connection to test mapping from connection ID back to chain ID This also mocks out the consensus state to enable testing registering interchain accounts
func (*AppTestHelper) MockClientLatestHeight ¶
func (s *AppTestHelper) MockClientLatestHeight(height uint64)
Helper function to mock out a connection, client, and revision height
func (*AppTestHelper) MockICAChannel ¶
func (s *AppTestHelper) MockICAChannel(connectionId, channelId, owner, address string)
Helper function to mock out an ICA address
func (*AppTestHelper) MustGetNextSequenceNumber ¶
func (s *AppTestHelper) MustGetNextSequenceNumber(portId, channelId string) uint64
Helper function to get the next sequence number for testing when an ICA was submitted
func (*AppTestHelper) RegisterInterchainAccountWithOrdering ¶
func (s *AppTestHelper) RegisterInterchainAccountWithOrdering(endpoint *ibctesting.Endpoint, owner string)
Register's a new ICA account on the next channel available This function assumes a connection already exists
func (*AppTestHelper) SetNewAccount ¶
func (s *AppTestHelper) SetNewAccount(addr sdk.AccAddress)
func (*AppTestHelper) SetupIBCChains ¶
func (s *AppTestHelper) SetupIBCChains(hostChainID string)
Initializes a ibctesting coordinator to keep track of Stride and a host chain's state
func (*AppTestHelper) UpdateChannelState ¶
func (s *AppTestHelper) UpdateChannelState(portId, channelId string, channelState channeltypes.State)
Helper function to change the state of a channel (i.e. to open/close it)
type SuitelessAppTestHelper ¶
func SetupSuitelessTestHelper ¶
func SetupSuitelessTestHelper() SuitelessAppTestHelper
Instantiates an TestHelper without the test suite This is for testing scenarios where we simply need the setup function to run, and need access to the TestHelper attributes and keepers (e.g. genesis tests)