testing

package
v0.0.0-...-ff2c966 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TurnOffRewards = func(cfg *GenesisCfg) { cfg.rewardsPoolAmount = basics.MicroAlgos{Raw: 100_000} }

TurnOffRewards turns off the rewards pool for tests that are sensitive to "surprise" balance changes.

Functions

func BenchConsensusRange

func BenchConsensusRange(b *testing.B, start, stop int, bench func(t *testing.B, ver int, cv protocol.ConsensusVersion))

BenchConsensusRange is for getting benchmarks across consensus versions.

func CalculateNewRoundAccountTotals

func CalculateNewRoundAccountTotals(t *gotesting.T, newRoundDeltas ledgercore.AccountDeltas, newRoundRewardLevel uint64, newRoundConsensusParams config.ConsensusParams, prevRoundBalances map[basics.Address]basics.AccountData, prevRoundTotals ledgercore.AccountTotals) (newTotals ledgercore.AccountTotals)

CalculateNewRoundAccountTotals calculates the accounts totals for a given round

func GenerateInitState

func GenerateInitState(tb testing.TB, proto protocol.ConsensusVersion, baseAlgoPerAccount int) (genesisInitState ledgercore.InitState, initKeys map[basics.Address]*crypto.SignatureSecrets)

GenerateInitState generates testing init state

func Genesis

func Genesis(naccts int) (ledgercore.InitState, []basics.Address, []*crypto.SignatureSecrets)

Genesis creates a genesis state for naccts accounts using the ConsensusCurrentVersion

func GenesisWithProto

func GenesisWithProto(naccts int, proto protocol.ConsensusVersion) (ledgercore.InitState, []basics.Address, []*crypto.SignatureSecrets)

GenesisWithProto creates a genesis state for naccts accounts using the proto consensus protocol

func NewTestGenesis

NewTestGenesis creates a bunch of accounts, splits up 10B algos between them and the rewardspool and feesink, and gives out the addresses and secrets it creates to enable tests. For special scenarios, manipulate these return values before using newTestLedger.

func PoolAddr

func PoolAddr() basics.Address

PoolAddr returns a copy of the test pool address

func RandomAccountData

func RandomAccountData(rewardsBase uint64) basics.AccountData

RandomAccountData generates a random AccountData with no associated resources.

func RandomAccounts

func RandomAccounts(niter int, simpleAccounts bool) map[basics.Address]basics.AccountData

RandomAccounts generates a random set of accounts map

func RandomAddress

func RandomAddress() basics.Address

RandomAddress generates a random address

func RandomAppLocalState

func RandomAppLocalState() basics.AppLocalState

RandomAppLocalState creates a random basics.AppLocalState

func RandomAppParams

func RandomAppParams() basics.AppParams

RandomAppParams creates a random basics.AppParams

func RandomAssetHolding

func RandomAssetHolding(forceFrozen bool) basics.AssetHolding

RandomAssetHolding creates a random basics.AssetHolding. If forceFrozen is set the Frozen field is set to True to prevent possible empty AssetHolding struct

func RandomAssetParams

func RandomAssetParams() basics.AssetParams

RandomAssetParams creates a random basics.AssetParams

func RandomDeltas

func RandomDeltas(niter int, base map[basics.Address]basics.AccountData, rewardsLevel uint64) (updates ledgercore.AccountDeltas, totals map[basics.Address]ledgercore.AccountData, imbalance int64)

RandomDeltas generates a random set of accounts delta

func RandomDeltasBalanced

func RandomDeltasBalanced(niter int, base map[basics.Address]basics.AccountData, rewardsLevel uint64) (updates ledgercore.AccountDeltas, totals map[basics.Address]ledgercore.AccountData)

RandomDeltasBalanced generates a random set of accounts delta

func RandomDeltasBalancedFull

func RandomDeltasBalancedFull(niter int, base map[basics.Address]basics.AccountData, rewardsLevel uint64, lastCreatableID *basics.CreatableIndex) (updates ledgercore.AccountDeltas, totals map[basics.Address]ledgercore.AccountData)

RandomDeltasBalancedFull generates a random set of accounts delta

func RandomDeltasBalancedImpl

func RandomDeltasBalancedImpl(niter int, base map[basics.Address]basics.AccountData, rewardsLevel uint64, simple bool, lastCreatableID *basics.CreatableIndex) (updates ledgercore.AccountDeltas, totals map[basics.Address]ledgercore.AccountData)

RandomDeltasBalancedImpl generates a random set of accounts delta

func RandomDeltasFull

func RandomDeltasFull(niter int, base map[basics.Address]basics.AccountData, rewardsLevel uint64, lastCreatableID *basics.CreatableIndex) (updates ledgercore.AccountDeltas, totals map[basics.Address]ledgercore.AccountData, imbalance int64)

RandomDeltasFull generates a random set of accounts delta

func RandomDeltasImpl

func RandomDeltasImpl(niter int, base map[basics.Address]basics.AccountData, rewardsLevel uint64, simple bool, lastCreatableID *basics.CreatableIndex) (updates ledgercore.AccountDeltas, totals map[basics.Address]ledgercore.AccountData, imbalance int64)

RandomDeltasImpl generates a random set of accounts delta

func RandomFullAccountData

func RandomFullAccountData(rewardsLevel uint64, lastCreatableID *basics.CreatableIndex, assets map[basics.AssetIndex]struct{}, apps map[basics.AppIndex]struct{}) basics.AccountData

RandomFullAccountData generates a random AccountData

func RandomNote

func RandomNote() []byte

RandomNote generates a random notes data

func RandomOnlineAccountData

func RandomOnlineAccountData(rewardsBase uint64) basics.AccountData

RandomOnlineAccountData is similar to RandomAccountData but always creates online account

func SinkAddr

func SinkAddr() basics.Address

SinkAddr returns a copy of the test sink address

func TestConsensusRange

func TestConsensusRange(t *testing.T, start, stop int, test func(t *testing.T, ver int, cv protocol.ConsensusVersion, cfg config.Local))

TestConsensusRange allows for running tests against a range of consensus versions. Generally `start` will be the version that introduced the feature, and `stop` will be 0 to indicate it should work right on up through vFuture. `stop` will be an actual version number if we're confirming that something STOPS working as of a particular version. When writing the test for a new feature that is currently in vFuture, use the expected version number as `start`. That will correspond to vFuture until a new consensus version is created and inserted in consensusByNumber. At that point, your feature is probably active in that version. (If it's being held in vFuture, just increment your `start`.)

func WithAndWithoutLRUCache

func WithAndWithoutLRUCache(t *testing.T, cfg config.Local, test func(t *testing.T, cfg config.Local))

WithAndWithoutLRUCache allows for running a test with ledger LRU cache activated and deactivated.

Types

type GenesisCfg

type GenesisCfg struct {
	OnlineCount int
	// contains filtered or unexported fields
}

GenesisCfg provides a configuration object for NewTestGenesis.

type TestGenesisOption

type TestGenesisOption func(*GenesisCfg)

TestGenesisOption provides functional options for testGenesisCfg.

Jump to

Keyboard shortcuts

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