helpers

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SimAppChainID = "govgen-app"
)

SimAppChainID hardcoded chainID for simulation

Variables

View Source
var (
	TestTextProposal            = types.NewTextProposal("Test", "description")
	TestParameterChangeProposal = paramsproposal.NewParameterChangeProposal(
		"Test", "description", []paramsproposal.ParamChange{},
	)
	TestSoftwareUpgradeProposal = upgradetypes.NewSoftwareUpgradeProposal(
		"Test", "description", upgradetypes.Plan{
			Name:   "plan",
			Height: 42,
		},
	)
	TestCancelSoftwareUpgradeProposal = upgradetypes.NewCancelSoftwareUpgradeProposal(
		"Test", "description",
	)

	// DefaultConsensusParams defines the default Tendermint consensus params used
	// in GovGenApp testing.
	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,
			},
		},
	}
)

Functions

func AddTestAddrs

func AddTestAddrs(app *govgenapp.GovGenApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress

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

func AddTestAddrsFromPubKeys

func AddTestAddrsFromPubKeys(app *govgenapp.GovGenApp, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt sdk.Int)

AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys.

func AddTestAddrsIncremental

func AddTestAddrsIncremental(app *govgenapp.GovGenApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress

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

func CheckBalance

func CheckBalance(t *testing.T, app *govgenapp.GovGenApp, addr sdk.AccAddress, balances sdk.Coins)

CheckBalance checks the balance of an account.

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 FundAccount

func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error

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

TODO: Instead of using the mint module account, which has the permission of minting, create a "faucet" account. (@fdymylja)

func FundModuleAccount

func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientMod string, amounts 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!

TODO: Instead of using the mint module account, which has the permission of minting, create a "faucet" account. (@fdymylja)

func GenSequenceOfTxs

func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, initSeqNums []uint64, numToGenerate int, priv ...cryptotypes.PrivKey) ([]sdk.Tx, error)

GenSequenceOfTxs generates a set of signed transactions of messages, such that they differ only by having the sequence numbers incremented between every transaction.

func NewPubKeyFromHex

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

NewPubKeyFromHex returns a PubKey from a hex string.

func Setup

func Setup(t *testing.T) *govgenapp.GovGenApp

func SetupNoValset

func SetupNoValset(isCheckTx bool) *govgenapp.GovGenApp

func SetupWithGenesisValSet

func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *govgenapp.GovGenApp

SetupWithGenesisValSet initializes a new GovGenApp with a validator set and genesis accounts that also act as delegators. For simplicity, each validator is bonded with a delegation of one consensus engine unit in the default token of the GovGenApp from first genesis account. A Nop logger is set in GovGenApp.

func SignCheckDeliver

func SignCheckDeliver(
	t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg,
	chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error)

SignCheckDeliver checks a generated signed transaction and simulates a block commitment with the given transaction. A test assertion is made using the parameter 'expPass' against the result. A corresponding result is returned.

func TestAddr

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

Types

type EmptyAppOptions

type EmptyAppOptions struct{}

EmptyAppOptions is a stub implementing AppOptions

func (EmptyAppOptions) Get

func (EmptyAppOptions) Get(_ string) interface{}

Get implements AppOptions

type GenerateAccountStrategy

type GenerateAccountStrategy func(int) []sdk.AccAddress

type PV

type PV struct {
	PrivKey cryptotypes.PrivKey
}

func NewPV

func NewPV() PV

func (PV) GetPubKey

func (pv PV) GetPubKey() (crypto.PubKey, error)

GetPubKey implements PrivValidator interface

Jump to

Keyboard shortcuts

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