simapp

package
v0.0.0-...-325c2d7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TestParamUsers represents the map of simapp users
	TestParamUsers = make(map[string]TestUser)

	// TestParamValidatorAddresses represents the map of test validators
	TestParamValidatorAddresses = make(map[string]TestValidator)
)
View Source
var DefaultConsensusParams = &abci.ConsensusParams{
	Block: &abci.BlockParams{
		MaxBytes: 200000,
		MaxGas:   2000000,
	},
	Evidence: &tmproto.EvidenceParams{
		MaxAgeNumBlocks: 302400,
		MaxAgeDuration:  504 * time.Hour,
		MaxBytes:        10000,
	},
	Validator: &tmproto.ValidatorParams{
		PubKeyTypes: []string{
			tmtypes.ABCIPubKeyTypeEd25519,
		},
	},
}

DefaultConsensusParams parameters for tendermint consensus

View Source
var (
	// PKs is a slice of public keys for test
	PKs = CreateTestPubKeys(500)
)
View Source
var (
	// TestDVMPublicKey represents test public keys needed for dvm
	// TestDVMPrivateKey represents test private keys needed for dvm
	TestDVMPublicKey, TestDVMPrivateKey, _ = ed25519.GenerateKey(rand.Reader)
)

nolint

Functions

func AddTestAddrsIncremental

func AddTestAddrsIncremental(tApp *TestApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress

AddTestAddrsIncremental constructs and returns accNum amount of accounts with an initial balance of accAmt in random order

func ConvertAddrsToValAddrs

func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress

ConvertAddrsToValAddrs converts the provided addresses to ValAddress.

func CreateTestPubKeys

func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey

CreateTestPubKeys returns a total of numPubKeys public keys in ascending order.

func FundModuleAccount

func FundModuleAccount(app *TestApp, ctx sdk.Context, recipientMod string, coins sdk.Coins) error

FundModuleAccount is a utility function that funds a module account by minting and sending the coins to the address. This should be used for testing purposes only!

func NewPubKeyFromHex

func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey)

NewPubKeyFromHex returns a PubKey from a hex string.

func NewStakingHelper

func NewStakingHelper(t *testing.T, ctx sdk.Context, k stakingKeeper.Keeper) *teststaking.Helper

NewStakingHelper creates staking Handler wrapper for tests

func SetAccountCoins

func SetAccountCoins(ctx *sdk.Context, k bankkeeper.Keeper, addr sdk.AccAddress, amount int64) error

SetAccountCoins sets the balance of accounts for testing

func SetModuleAccountCoins

func SetModuleAccountCoins(ctx *sdk.Context, k bankkeeper.Keeper, moduleName string, amount int64) error

SetModuleAccountCoins sets the balance of accounts for testing

func TestAddr

func TestAddr(addr string, bech string) (sdk.AccAddress, error)

TestAddr returns sample account address

Types

type SimappOptions

type SimappOptions struct {
	CreateGenesisValidators bool
}

SimappOptions defines options related to simapp initialization

type TestApp

type TestApp struct {
	app.FanxApp
}

TestApp is used as a container of the sgex app

func GetTestObjects

func GetTestObjects() (*TestApp, sdk.Context, error)

GetTestObjects gets the test objects and ingredients for testing phase start with default options

func GetTestObjectsWithOptions

func GetTestObjectsWithOptions(options SimappOptions) (*TestApp, sdk.Context, error)

GetTestObjectsWithOptions gets the test objects and ingredients for testing phase start with custom options

func Setup

func Setup(isCheckTx bool) *TestApp

Setup initializes genesis the same as simapp

func SetupWithGenesisAccounts

func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, options SimappOptions, balances ...banktypes.Balance) *TestApp

SetupWithGenesisAccounts sets up the genesis accounts for testing

type TestUser

type TestUser struct {
	PrvKey  secp256k1.PrivKey
	Address sdk.AccAddress
	Balance int64
}

TestUser is simapp user type for testing

type TestValidator

type TestValidator struct {
	PubKey      types.PubKey
	Address     sdk.ValAddress
	ConsAddress sdk.ConsAddress
	Power       sdk.Int
}

TestValidator is simapp validator type for testing

Jump to

Keyboard shortcuts

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