apptesting

package
v7.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

  • The unit testing framework leverages the ibctesting package
  • See ibc-go/testing for an overview

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StrideChainID = "STRIDE"

	TestIcaVersion = string(icatypes.ModuleCdc.MustMarshalJSON(&icatypes.Metadata{
		Version:                icatypes.Version,
		ControllerConnectionId: ibctesting.FirstConnectionID,
		HostConnectionId:       ibctesting.FirstConnectionID,
		Encoding:               icatypes.EncodingProtobuf,
		TxType:                 icatypes.TxTypeSDKMultiMsg,
	}))
)

Functions

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

func GenerateTestAddrs() (string, string)

Generates a valid and invalid test address (used for non-keeper tests)

func GetAdminAddress

func GetAdminAddress() (address string, ok bool)

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) *ibctesting.Path

Creates an ICA channel between two chains

func NewTransferPath

func NewTransferPath(chainA *ibctesting.TestChain, chainB *ibctesting.TestChain) *ibctesting.Path

Creates a transfer channel between two chains

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

	IbcEnabled   bool
	Coordinator  *ibctesting.Coordinator
	StrideChain  *ibctesting.TestChain
	HostChain    *ibctesting.TestChain
	TransferPath *ibctesting.Path

	QueryHelper  *baseapp.QueryServiceTestHelper
	TestAccs     []sdk.AccAddress
	IcaAddresses map[string]string
	Ctx          sdk.Context
}

func (*AppTestHelper) CompareCoins

func (s *AppTestHelper) CompareCoins(expectedCoin sdk.Coin, actualCoin sdk.Coin, msg string)

Helper function to compare coins with a more legible error

func (*AppTestHelper) ConfirmUpgradeSucceededs

func (s *AppTestHelper) ConfirmUpgradeSucceededs(upgradeName string, upgradeHeight int64)

func (*AppTestHelper) CreateICAChannel

func (s *AppTestHelper) CreateICAChannel(owner string) 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

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) 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) RegisterInterchainAccount

func (s *AppTestHelper) RegisterInterchainAccount(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) Setup

func (s *AppTestHelper) Setup()

AppTestHelper Constructor

func (*AppTestHelper) SetupIBCChains

func (s *AppTestHelper) SetupIBCChains(hostChainID string)

Initializes a ibctesting coordinator to keep track of Stride and a host chain's state

type SuitelessAppTestHelper

type SuitelessAppTestHelper struct {
	App *app.StrideApp
	Ctx sdk.Context
}

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)

Jump to

Keyboard shortcuts

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