apptesting

package
v20.0.0-...-e580147 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTransmuterDenomA       = "axlusdc"
	DefaultTransmuterDenomB       = "gravusdc"
	TransmuterContractName        = "transmuter"
	TransmuterMigrateContractName = "transmuter_migrate"
	DefaultCodeId                 = 1
)
View Source
const (
	BAR   = "bar"
	BAZ   = "baz"
	FOO   = "foo"
	UFURY = "ufury"
	STAKE = "stake"
)

Variables

View Source
var (
	ETH                = "eth"
	USDC               = "usdc"
	WBTC               = "ibc/D1542AA8762DB13087D8364F3EA6509FD6F009A34F00426AF9E4F9FA85CBBF1F"
	DefaultTickSpacing = uint64(100)
	DefaultLowerTick   = int64(30545000)
	DefaultUpperTick   = int64(31500000)
	DefaultCoinAmount  = osmomath.NewInt(1000000000000000000)
)
View Source
var (
	SecondaryDenom  = "uion"
	SecondaryAmount = osmomath.NewInt(100000000)
)
View Source
var DefaultAcctFunds sdk.Coins = sdk.NewCoins(
	sdk.NewCoin(UFURY, osmomath.NewInt(10000000000)),
	sdk.NewCoin(FOO, osmomath.NewInt(10000000000)),
	sdk.NewCoin(BAR, osmomath.NewInt(10000000000)),
	sdk.NewCoin(BAZ, osmomath.NewInt(10000000000)),
)
View Source
var DefaultPoolAssets = []balancer.PoolAsset{
	{
		Weight: osmomath.NewInt(100),
		Token:  sdk.NewCoin(FOO, osmomath.NewInt(5000000)),
	},
	{
		Weight: osmomath.NewInt(200),
		Token:  sdk.NewCoin(BAR, osmomath.NewInt(5000000)),
	},
	{
		Weight: osmomath.NewInt(300),
		Token:  sdk.NewCoin(BAZ, osmomath.NewInt(5000000)),
	},
	{
		Weight: osmomath.NewInt(400),
		Token:  sdk.NewCoin(UFURY, osmomath.NewInt(5000000)),
	},
}
View Source
var DefaultStableswapLiquidity = sdk.NewCoins(
	sdk.NewCoin(FOO, osmomath.NewInt(10000000)),
	sdk.NewCoin(BAR, osmomath.NewInt(10000000)),
	sdk.NewCoin(BAZ, osmomath.NewInt(10000000)),
)
View Source
var ImbalancedStableswapLiquidity = sdk.NewCoins(
	sdk.NewCoin(FOO, osmomath.NewInt(10_000_000_000)),
	sdk.NewCoin(BAR, osmomath.NewInt(20_000_000_000)),
	sdk.NewCoin(BAZ, osmomath.NewInt(30_000_000_000)),
)

Functions

func CreateRandomAccounts

func CreateRandomAccounts(numAccts int) []sdk.AccAddress

CreateRandomAccounts is a function return a list of randomly generated AccAddresses

func GenerateTestAddrs

func GenerateTestAddrs() (string, string)

func SkipIfWSL

func SkipIfWSL(t *testing.T)

SkipIfWSL skips tests if running on WSL This is a workaround to enable quickly running full unit test suite locally on WSL without failures. The failures are stemming from trying to upload wasm code. An OS permissioning issue.

func TestMessageAuthzSerialization

func TestMessageAuthzSerialization(t *testing.T, msg sdk.Msg)

Types

type KeeperTestHelper

type KeeperTestHelper struct {
	suite.Suite

	App         *app.FuryaApp
	Ctx         sdk.Context
	QueryHelper *baseapp.QueryServiceTestHelper
	TestAccs    []sdk.AccAddress
	// contains filtered or unexported fields
}

func (*KeeperTestHelper) AllocateRewardsToValidator

func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, rewardAmt osmomath.Int)

AllocateRewardsToValidator allocates reward tokens to a distribution module then allocates rewards to the validator address.

func (*KeeperTestHelper) AssertEventEmitted

func (s *KeeperTestHelper) AssertEventEmitted(ctx sdk.Context, eventTypeExpected string, numEventsExpected int)

AssertEventEmitted asserts that ctx's event manager has emitted the given number of events of the given type.

func (*KeeperTestHelper) BeginNewBlock

func (s *KeeperTestHelper) BeginNewBlock(executeNextEpoch bool)

BeginNewBlock starts a new block.

func (*KeeperTestHelper) BeginNewBlockWithProposer

func (s *KeeperTestHelper) BeginNewBlockWithProposer(executeNextEpoch bool, proposer sdk.ValAddress)

BeginNewBlockWithProposer begins a new block with a proposer.

func (*KeeperTestHelper) BuildTx

func (s *KeeperTestHelper) BuildTx(
	txBuilder client.TxBuilder,
	msgs []sdk.Msg,
	sigV2 signing.SignatureV2,
	memo string, txFee sdk.Coins,
	gasLimit uint64,
) authsigning.Tx

BuildTx builds a transaction.

func (*KeeperTestHelper) CalcAmoutOfTokenToGetTargetPrice

func (s *KeeperTestHelper) CalcAmoutOfTokenToGetTargetPrice(ctx sdk.Context, pool gammtypes.CFMMPoolI, targetSpotPrice osmomath.Dec, baseDenom, quoteDenom string) (amountTrade osmomath.Dec)

func (*KeeperTestHelper) Commit

func (s *KeeperTestHelper) Commit()

CreateTestContext creates a test context.

func (*KeeperTestHelper) CreateConcentratedPoolsAndFullRangePosition

func (s *KeeperTestHelper) CreateConcentratedPoolsAndFullRangePosition(poolDenoms [][]string)

createConcentratedPoolsFromCoins creates CL pools from given sets of coins (with zero swap fees). Where element 1 of the input corresponds to the first pool created, element 2 to the second pool created etc.

func (*KeeperTestHelper) CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor

func (s *KeeperTestHelper) CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(poolDenoms [][]string, spreadFactor []osmomath.Dec)

createConcentratedPoolsFromCoinsWithSpreadFactor creates CL pools from given sets of coins and respective swap fees. Where element 1 of the input corresponds to the first pool created, element 2 to the second pool created etc.

func (*KeeperTestHelper) CreateFullRangePosition

func (s *KeeperTestHelper) CreateFullRangePosition(pool types.ConcentratedPoolExtension, coins sdk.Coins) (uint64, osmomath.Dec)

CreateFullRangePosition creates a full range position and returns position id and the liquidity created.

func (*KeeperTestHelper) CreatePoolFromType

func (s *KeeperTestHelper) CreatePoolFromType(poolType poolmanagertypes.PoolType)

CreatePoolFromType creates a basic pool of the given type for testing.

func (*KeeperTestHelper) CreatePoolFromTypeWithCoins

func (s *KeeperTestHelper) CreatePoolFromTypeWithCoins(poolType poolmanagertypes.PoolType, coins sdk.Coins) uint64

CreatePoolFromTypeWithCoins creates a pool with the given type and initialized with the given coins.

func (*KeeperTestHelper) CreatePoolFromTypeWithCoinsAndSpreadFactor

func (s *KeeperTestHelper) CreatePoolFromTypeWithCoinsAndSpreadFactor(poolType poolmanagertypes.PoolType, coins sdk.Coins, spreadFactor osmomath.Dec) uint64

CreatePoolFromTypeWithCoinsAndSpreadFactor creates a pool with given type, initialized with the given coins as initial liquidity and spread factor.

func (*KeeperTestHelper) CreateTestContext

func (s *KeeperTestHelper) CreateTestContext() sdk.Context

CreateTestContext creates a test context.

func (*KeeperTestHelper) CreateTestContextWithMultiStore

func (s *KeeperTestHelper) CreateTestContextWithMultiStore() (sdk.Context, sdk.CommitMultiStore)

CreateTestContextWithMultiStore creates a test context and returns it together with multi store.

func (*KeeperTestHelper) EndBlock

func (s *KeeperTestHelper) EndBlock()

EndBlock ends the block, and runs commit

func (*KeeperTestHelper) ExtractAttributes

func (s *KeeperTestHelper) ExtractAttributes(event sdk.Event) map[string]string

func (*KeeperTestHelper) FindEvent

func (s *KeeperTestHelper) FindEvent(events []sdk.Event, name string) sdk.Event

func (*KeeperTestHelper) FundAcc

func (s *KeeperTestHelper) FundAcc(acc sdk.AccAddress, amounts sdk.Coins)

FundAcc funds target address with specified amount.

func (*KeeperTestHelper) FundModuleAcc

func (s *KeeperTestHelper) FundModuleAcc(moduleName string, amounts sdk.Coins)

FundModuleAcc funds target modules with specified amount.

func (*KeeperTestHelper) GetContractCode

func (s *KeeperTestHelper) GetContractCode(contractName string) []byte

GetContractCode returns the contract code for the given contract name. Assumes that the contract code is stored under x/cosmwasmpool/bytecode.

func (*KeeperTestHelper) GetDefaultTransmuterInstantiateMsgBytes

func (s *KeeperTestHelper) GetDefaultTransmuterInstantiateMsgBytes() []byte

GetDefaultTransmuterInstantiateMsgBytes returns the default instantiate message for the transmuter contract with DefaultTransmuterDenomA and DefaultTransmuterDenomB as the pool asset denoms.

func (*KeeperTestHelper) GetTransmuterInstantiateMsgBytes

func (s *KeeperTestHelper) GetTransmuterInstantiateMsgBytes(poolAssetDenoms []string) []byte

GetTransmuterInstantiateMsgBytes returns the instantiate message for the transmuter contract with the given pool asset denoms.

func (*KeeperTestHelper) IncreaseVolumeForPools

func (s *KeeperTestHelper) IncreaseVolumeForPools(poolIDs []uint64, volumesForEachPool []osmomath.Int)

initializes or increases the volumes for the given pools

func (*KeeperTestHelper) JoinTransmuterPool

func (s *KeeperTestHelper) JoinTransmuterPool(lpAddress sdk.AccAddress, poolId uint64, coins sdk.Coins)

JoinTransmuterPool joins the given pool with the given coins from the given address.

func (*KeeperTestHelper) LockTokens

func (s *KeeperTestHelper) LockTokens(addr sdk.AccAddress, coins sdk.Coins, duration time.Duration) (lockID uint64)

LockTokens funds an account, locks tokens and returns a lockID.

func (*KeeperTestHelper) LockTokensNoFund

func (s *KeeperTestHelper) LockTokensNoFund(addr sdk.AccAddress, coins sdk.Coins, duration time.Duration) (lockID uint64)

LockTokensNoFund locks tokens and returns a lockID.

func (*KeeperTestHelper) MintCoins

func (s *KeeperTestHelper) MintCoins(coins sdk.Coins)

func (*KeeperTestHelper) ModifySpotPrice

func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice osmomath.Dec, baseDenom string)

Modify spotprice of a pool to target spotprice

func (*KeeperTestHelper) PrepareAllSupportedPools

func (s *KeeperTestHelper) PrepareAllSupportedPools() SupportedPoolAndGaugeInfo

PrepareAllSupportedPools creates all supported pools and returns their IDs. Additionally, attaches an internal gauge ID for each pool.

func (*KeeperTestHelper) PrepareBalancerPool

func (s *KeeperTestHelper) PrepareBalancerPool() uint64

PrepareBalancerPool returns a Balancer pool's pool-ID with pool params set in PrepareBalancerPoolWithPoolParams.

func (*KeeperTestHelper) PrepareBalancerPoolWithCoins

func (s *KeeperTestHelper) PrepareBalancerPoolWithCoins(coins ...sdk.Coin) uint64

PrepareBalancerPoolWithCoins returns a balancer pool consisted of given coins with equal weight.

func (*KeeperTestHelper) PrepareBalancerPoolWithCoinsAndWeights

func (s *KeeperTestHelper) PrepareBalancerPoolWithCoinsAndWeights(coins sdk.Coins, weights []int64) uint64

PrepareBalancerPoolWithCoins returns a balancer pool PrepareBalancerPoolWithCoinsAndWeights returns a balancer pool consisted of given coins with the specified weights.

func (*KeeperTestHelper) PrepareBalancerPoolWithPoolParams

func (s *KeeperTestHelper) PrepareBalancerPoolWithPoolParams(poolParams balancer.PoolParams) uint64

PrepareBalancerPoolWithPoolParams sets up a Balancer pool with poolParams. Uses default pool assets.

func (*KeeperTestHelper) PrepareBasicStableswapPool

func (s *KeeperTestHelper) PrepareBasicStableswapPool() uint64

func (*KeeperTestHelper) PrepareConcentratedPool

func (s *KeeperTestHelper) PrepareConcentratedPool() types.ConcentratedPoolExtension

PrepareConcentratedPool sets up an eth usdc concentrated liquidity pool with a tick spacing of 100, no liquidity and zero spread factor.

func (*KeeperTestHelper) PrepareConcentratedPoolWithCoins

func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoins(denom1, denom2 string) types.ConcentratedPoolExtension

PrepareConcentratedPoolWithCoins sets up a concentrated liquidity pool with custom denoms.

func (*KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndFullRangePosition

func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndFullRangePosition(denom1, denom2 string) types.ConcentratedPoolExtension

PrepareConcentratedPoolWithCoinsAndFullRangePosition sets up a concentrated liquidity pool with custom denoms. It also creates a full range position.

func (*KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndLockedFullRangePosition

func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndLockedFullRangePosition(denom1, denom2 string) (types.ConcentratedPoolExtension, uint64, uint64)

PrepareConcentratedPoolWithCoinsAndLockedFullRangePosition sets up a concentrated liquidity pool with custom denoms. It also creates a full range position and locks it for 14 days.

func (*KeeperTestHelper) PrepareCosmWasmPool

func (s *KeeperTestHelper) PrepareCosmWasmPool() cosmwasmpooltypes.CosmWasmExtension

PrepareCosmWasmPool sets up a cosmwasm pool with the default parameters.

func (*KeeperTestHelper) PrepareCustomBalancerPool

func (s *KeeperTestHelper) PrepareCustomBalancerPool(assets []balancer.PoolAsset, params balancer.PoolParams) uint64

PrepareCustomBalancerPool sets up a Balancer pool with an array of assets and given parameters

func (*KeeperTestHelper) PrepareCustomBalancerPoolFromCoins

func (s *KeeperTestHelper) PrepareCustomBalancerPoolFromCoins(coins sdk.Coins, params balancer.PoolParams) uint64

PrepareCustomBalancerPoolFromCoins sets up a Balancer pool with an array of coins and given parameters The coins are converted to pool assets where each asset has a weight of 1.

func (*KeeperTestHelper) PrepareCustomConcentratedPool

func (s *KeeperTestHelper) PrepareCustomConcentratedPool(owner sdk.AccAddress, denom0, denom1 string, tickSpacing uint64, spreadFactor osmomath.Dec) types.ConcentratedPoolExtension

PrepareCustomConcentratedPool sets up a concentrated liquidity pool with the custom parameters.

func (*KeeperTestHelper) PrepareCustomTransmuterPool

func (s *KeeperTestHelper) PrepareCustomTransmuterPool(owner sdk.AccAddress, denoms []string) cosmwasmpooltypes.CosmWasmExtension

PrepareCustomTransmuterPool sets up a transmuter pool with the custom parameters.

func (*KeeperTestHelper) PrepareImbalancedStableswapPool

func (s *KeeperTestHelper) PrepareImbalancedStableswapPool() uint64

func (*KeeperTestHelper) PrepareMultipleBalancerPools

func (s *KeeperTestHelper) PrepareMultipleBalancerPools(poolsToCreate uint16) []uint64

PrepareMultipleBalancerPools returns X Balancer pool's with X being provided by the user.

func (*KeeperTestHelper) PrepareMultipleConcentratedPools

func (s *KeeperTestHelper) PrepareMultipleConcentratedPools(poolsToCreate uint16) []uint64

PrepareMultipleConcentratedPools returns X cl pool's with X being provided by the user.

func (*KeeperTestHelper) Reset

func (s *KeeperTestHelper) Reset()

resets the test environment requires that all commits go through helpers in s. On first reset, will instantiate a new app, with caching enabled. NOTE: If you are using ABCI methods, usage of Reset vs Setup has not been well tested. It is believed to work, but if you get an odd error, try changing the call to this for setup to sanity check. whats supposed to happen is a new setup call, and reset just does that in such a case.

func (*KeeperTestHelper) RunBasicExit

func (s *KeeperTestHelper) RunBasicExit(poolId uint64)

func (*KeeperTestHelper) RunBasicJoin

func (s *KeeperTestHelper) RunBasicJoin(poolId uint64)

func (*KeeperTestHelper) RunBasicSwap

func (s *KeeperTestHelper) RunBasicSwap(poolId uint64)

func (*KeeperTestHelper) RunMsg

func (s *KeeperTestHelper) RunMsg(msg sdk.Msg) (*sdk.Result, error)

func (*KeeperTestHelper) RunTestCaseWithoutStateUpdates

func (s *KeeperTestHelper) RunTestCaseWithoutStateUpdates(name string, cb func(t *testing.T))

RunTestCaseWithoutStateUpdates runs the testcase as a callback with the given name. Does not persist any state changes. This is useful when test suite uses common state setup but desures each test case to be run in isolation.

func (*KeeperTestHelper) SetEpochStartTime

func (s *KeeperTestHelper) SetEpochStartTime()

func (*KeeperTestHelper) Setup

func (s *KeeperTestHelper) Setup()

Setup sets up basic environment for suite (App, Ctx, and test accounts) preserves the caching enabled/disabled state.

func (*KeeperTestHelper) SetupConcentratedLiquidityDenomsAndPoolCreation

func (s *KeeperTestHelper) SetupConcentratedLiquidityDenomsAndPoolCreation()

SetupConcentratedLiquidityDenomsAndPoolCreation sets up the default authorized quote denoms. Additionally, enables permissionless pool creation. This is to overwrite the default params set in concentrated liquidity genesis to account for the test cases that used various denoms before the authorized quote denoms were introduced.

func (*KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier

func (s *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier(multipliers []osmomath.Dec) []gammtypes.CFMMPoolI

SetupGammPoolsWithBondDenomMultiplier uses given multipliers to set initial pool supply of bond denom.

func (*KeeperTestHelper) SetupMultipleValidators

func (s *KeeperTestHelper) SetupMultipleValidators(numValidator int) []string

SetupMultipleValidators setups "numValidator" validators and returns their address in string

func (*KeeperTestHelper) SetupTestForInitGenesis

func (s *KeeperTestHelper) SetupTestForInitGenesis()

func (*KeeperTestHelper) SetupValidator

func (s *KeeperTestHelper) SetupValidator(bondStatus stakingtypes.BondStatus) sdk.ValAddress

SetupValidator sets up a validator and returns the ValAddress.

func (*KeeperTestHelper) SetupVolumeForPools

func (s *KeeperTestHelper) SetupVolumeForPools(poolIDs []uint64, volumesForEachPool []osmomath.Int, poolIDToVolumeMap map[uint64]math.Int)

sets up the volume for the pools in the group mutates poolIDToVolumeMap

func (*KeeperTestHelper) SetupWithLevelDb

func (s *KeeperTestHelper) SetupWithLevelDb() func()

func (*KeeperTestHelper) SkipIfWSL

func (s *KeeperTestHelper) SkipIfWSL()

func (*KeeperTestHelper) StateNotAltered

func (s *KeeperTestHelper) StateNotAltered()

StateNotAltered validates that app state is not altered. Fails if it is.

func (*KeeperTestHelper) StoreCosmWasmPoolContractCode

func (s *KeeperTestHelper) StoreCosmWasmPoolContractCode(contractName string) uint64

StoreCosmWasmPoolContractCode stores the cosmwasm pool contract code in the wasm keeper and returns the code id. contractName is the name of the contract file in the x/cosmwasmpool/bytecode directory without the .wasm extension.

func (*KeeperTestHelper) SuperfluidDelegateToDefaultVal

func (s *KeeperTestHelper) SuperfluidDelegateToDefaultVal(sender sdk.AccAddress, poolId uint64, lockId uint64) error

func (*KeeperTestHelper) SuperfluidDelegateToVal

func (s *KeeperTestHelper) SuperfluidDelegateToVal(sender sdk.AccAddress, poolId uint64, lockId uint64, valAddr string) error

func (*KeeperTestHelper) SwapAndSetSpotPrice

func (s *KeeperTestHelper) SwapAndSetSpotPrice(poolId uint64, fromAsset sdk.Coin, toAsset sdk.Coin) osmomath.BigDec

SwapAndSetSpotPrice runs a swap to set Spot price of a pool using arbitrary values returns spot price after the arbitrary swap.

func (*KeeperTestHelper) ValidateGroupExists

func (s *KeeperTestHelper) ValidateGroupExists(gaugeID uint64)

validates that Group and group Gauge exist

func (*KeeperTestHelper) WithdrawFullRangePosition

func (s *KeeperTestHelper) WithdrawFullRangePosition(pool types.ConcentratedPoolExtension, positionId uint64, liquidityToRemove osmomath.Dec)

WithdrawFullRangePosition withdraws given liquidity from a position specified by id.

type SupportedPoolAndGaugeInfo

type SupportedPoolAndGaugeInfo struct {
	ConcentratedPoolID uint64
	BalancerPoolID     uint64
	StableSwapPoolID   uint64
	CosmWasmPoolID     uint64

	ConcentratedGaugeID uint64
	BalancerGaugeID     uint64
	StableSwapGaugeID   uint64
}

Defines IDs for all supported Furya pools. Additionally, encapsulates an internal gauge ID for each pool. This struct is initialized and returned by PrepareAllSupportedPools().

Jump to

Keyboard shortcuts

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