testing

package
v1.17.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: BSD-3-Clause Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareBatches

func CompareBatches(t *testing.T, want, got *postage.Batch)

CompareBatches is a testing helper that compares two batches and fails the test if all fields are not equal. Fails on first different value and prints the comparison.

func CompareChainState

func CompareChainState(t *testing.T, want, got *postage.ChainState)

CompareChainState is a test helper that compares two ChainStates and fails the test if they are not exactly equal. Fails on first difference and returns a descriptive comparison.

func MustNewAddress

func MustNewAddress() []byte

MustNewAddress will generate a new random address (20 byte slice). Panics on errors.

func MustNewBatch

func MustNewBatch(opts ...BatchOption) *postage.Batch

MustNewBatch will create a new test batch. Fields that are not supplied will be filled with random data. Panics on errors.

func MustNewBatchStamp added in v1.8.0

func MustNewBatchStamp(batch []byte) *postage.Stamp

MustNewBatchStamp will generate a postage stamp with the provided batch ID and assign random data to other fields. Panics on error

func MustNewFields added in v1.17.0

func MustNewFields(batch []byte, index, ts uint64) *postage.Stamp

MustNewBatchStamp will generate a postage stamp with the provided batch ID and assign random data to other fields. Panics on error

func MustNewID

func MustNewID() []byte

MustNewID will generate a new random ID (32 byte slice). Panics on errors.

func MustNewSignature

func MustNewSignature() []byte

MustNewSignature will create a new random signature (65 byte slice). Panics on errors.

func MustNewStamp

func MustNewStamp() *postage.Stamp

MustNewStamp will generate a invalid postage stamp with random data. Panics on errors.

func MustNewStampWithTimestamp added in v1.9.0

func MustNewStampWithTimestamp(ts uint64) *postage.Stamp

MustNewStampWithTimestamp will generate a postage stamp with provided timestamp and random data for other fields. Panics on errors.

func MustNewValidSignature added in v1.17.0

func MustNewValidSignature(signer crypto.Signer, addr swarm.Address, id, index, timestamp []byte) []byte

MustNewValidSignature will create a new valid signature. Panics on errors.

func MustNewValidStamp added in v1.17.0

func MustNewValidStamp(signer crypto.Signer, addr swarm.Address) *postage.Stamp

MustNewValidStamp will generate a valid postage stamp with random data. Panics on errors.

func NewBigInt

func NewBigInt() *big.Int

NewBigInt will generate a new random big int (uint64 base value).

func NewChainState

func NewChainState() *postage.ChainState

NewChainState will create a new ChainState with random values.

Types

type BatchOption

type BatchOption func(c *postage.Batch)

BatchOption is an optional parameter for NewBatch

func WithDepth added in v1.4.2

func WithDepth(depth uint8) BatchOption

WithDepth will set the batch Depth to the given depth.

func WithOwner

func WithOwner(owner []byte) BatchOption

WithOwner will set the batch owner on a randomized batch.

func WithStart added in v1.4.2

func WithStart(start uint64) BatchOption

WithStart will set the batch Start to the given start.

func WithValue added in v1.4.2

func WithValue(value int64) BatchOption

WithValue will set the batch Value to the given value.

Jump to

Keyboard shortcuts

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