test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package test provides helper and setup functions to test the pallet package.

Index

Constants

View Source
const (
	// DefaultExtFee is a rough cost estimation for one extrinsic.
	// The value is oriented at the base-fee of a default substrate
	// node: https://crates.parity.io/frame_support/weights/constants/struct.ExtrinsicBaseWeight.html
	// The exact value can be configured in the substrate node itself.
	// More info on weight calculation: https://docs.substrate.io/v3/runtime/weights-and-fees/
	DefaultExtFee = uint64(125100000)
	// PastBlocks defines how many past blocks should be queried.
	// Must be large enough to ensure that event subs can query all past events
	// of the current test.
	PastBlocks = 100
)

Variables

This section is empty.

Functions

func DepositAll

func DepositAll(ctx context.Context, deps []*pallet.Depositor, reqs []*pallet.DepositReq) error

DepositAll executes all requests with the given depositors in parallel.

func FundAll

func FundAll(ctx context.Context, funders []*pallet.Funder, reqs []*pchannel.FundingReq) error

FundAll executes all requests with the given funders in parallel.

func MixBals

func MixBals(rng io.Reader, bals []pchannel.Bal)

MixBals randomly modifies the values of bals while the sum stays the same. All values should be > 0.

func Multiply

func Multiply(f int64, bals ...pchannel.Bal) []pchannel.Bal

Multiply multiplies the passed `bals` with `f` and returns them.

Types

type Setup

type Setup struct {
	*chtest.Setup

	Pallet *pallet.Pallet

	Deps    []*pallet.Depositor
	Funders []*pallet.Funder
	Adjs    []*pallet.Adjudicator
}

Setup is the test setup.

func NewSetup

func NewSetup(t *testing.T) *Setup

NewSetup returns a new Setup.

func (*Setup) AssertBalanceChanges

func (s *Setup) AssertBalanceChanges(deltas map[types.AccountID]*big.Int, epsilon *big.Int, f func())

AssertBalanceChange checks that an on-chain account gains delta with absolute error of epsilon by executing f.

func (*Setup) AssertDeposit

func (s *Setup) AssertDeposit(fid channel.FundingID, bal *big.Int)

AssertDeposit checks that the funding ID holds the specified amount.

func (*Setup) AssertDeposits

func (s *Setup) AssertDeposits(fids []channel.FundingID, bals []*big.Int)

AssertDeposit checks that the funding ids holds the specified amounts.

func (*Setup) AssertNoDeposit

func (s *Setup) AssertNoDeposit(fid channel.FundingID)

AssertNoDeposit checks that the funding ID holds no amount.

func (*Setup) AssertNoRegistered

func (s *Setup) AssertNoRegistered(cid channel.ChannelID)

AssertNoRegistered checks that the channel is not registered.

func (*Setup) AssertRegistered

func (s *Setup) AssertRegistered(state *channel.State, concluded bool)

AssertRegistered checks that the channel is registered with the passed state and concluded value.

Jump to

Keyboard shortcuts

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