testutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0, BSD-2-Clause Imports: 16 Imported by: 1

Documentation

Overview

Package testutil provides mock implementations of various wasp components. They are used for unit-testing different parts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTrustedNetworkManager added in v0.2.0

func NewTrustedNetworkManager() peering.TrustedNetworkManager

func RunHeavy added in v0.2.1

func RunHeavy(t *testing.T)

Types

type ChainRecordRegistryProvider added in v0.2.0

type ChainRecordRegistryProvider struct {
	DB map[[ledgerstate.AddressLength]byte]*registry.ChainRecord
}

func NewChainRecordRegistryProvider added in v0.2.0

func NewChainRecordRegistryProvider() *ChainRecordRegistryProvider

func (*ChainRecordRegistryProvider) LoadChainRecord added in v0.2.0

func (p *ChainRecordRegistryProvider) LoadChainRecord(chainID *iscp.ChainID) (*registry.ChainRecord, error)

func (*ChainRecordRegistryProvider) SaveChainRecord added in v0.2.0

func (p *ChainRecordRegistryProvider) SaveChainRecord(chainRecord *registry.ChainRecord) error

type DkgRegistryProvider added in v0.1.0

type DkgRegistryProvider struct {
	DB    map[string][]byte
	Suite tcrypto.Suite
}

DkgRegistryProvider stands for a mock for dkg.DKShareRegistryProvider.

func NewDkgRegistryProvider added in v0.1.0

func NewDkgRegistryProvider(suite tcrypto.Suite) *DkgRegistryProvider

NewDkgRegistryProvider creates new mocked DKG registry provider.

func (*DkgRegistryProvider) LoadDKShare added in v0.1.0

func (p *DkgRegistryProvider) LoadDKShare(sharedAddress ledgerstate.Address) (*tcrypto.DKShare, error)

LoadDKShare implements dkg.DKShareRegistryProvider.

func (*DkgRegistryProvider) SaveDKShare added in v0.1.0

func (p *DkgRegistryProvider) SaveDKShare(dkShare *tcrypto.DKShare) error

SaveDKShare implements dkg.DKShareRegistryProvider.

type PeeringNetBehavior added in v0.1.0

type PeeringNetBehavior interface {
	AddLink(inCh, outCh chan *peeringMsg, dstNetID string)
	Close()
}

An interface for all the network behaviors.

func NewPeeringNetReliable added in v0.1.0

func NewPeeringNetReliable(log *logger.Logger) PeeringNetBehavior

NewPeeringNetReliable constructs the PeeringNetBehavior.

func NewPeeringNetUnreliable added in v0.1.0

func NewPeeringNetUnreliable(deliverPct, repeatPct int, delayFrom, delayTill time.Duration, log *logger.Logger) PeeringNetBehavior

NewPeeringNetReliable constructs the PeeringNetBehavior.

type PeeringNetDynamic added in v0.2.0

type PeeringNetDynamic struct {
	// contains filtered or unexported fields
}

peeringNetDynamic provides a behavior of a network with dynamically changeable working conditions. It works as peeringNetReliable without any handlers set.

func NewPeeringNetDynamic added in v0.2.0

func NewPeeringNetDynamic(log *logger.Logger) *PeeringNetDynamic

NewPeeringNetDynamic constructs the PeeringNetBehavior.

func (pndT *PeeringNetDynamic) AddLink(inCh, outCh chan *peeringMsg, dstNetID string)

Run implements PeeringNetBehavior.

func (*PeeringNetDynamic) Close added in v0.2.0

func (pndT *PeeringNetDynamic) Close()

Close implements PeeringNetBehavior.

func (*PeeringNetDynamic) RemoveHandler added in v0.2.0

func (pndT *PeeringNetDynamic) RemoveHandler(id string) bool

func (*PeeringNetDynamic) WithDelayingChannel added in v0.2.0

func (pndT *PeeringNetDynamic) WithDelayingChannel(id *string, delayFrom, delayTill time.Duration) *PeeringNetDynamic

func (*PeeringNetDynamic) WithLosingChannel added in v0.2.0

func (pndT *PeeringNetDynamic) WithLosingChannel(id *string, deliveryProbability int) *PeeringNetDynamic

func (*PeeringNetDynamic) WithPeerDisconnected added in v0.2.0

func (pndT *PeeringNetDynamic) WithPeerDisconnected(id *string, peerName string) *PeeringNetDynamic

func (*PeeringNetDynamic) WithRepeatingChannel added in v0.2.0

func (pndT *PeeringNetDynamic) WithRepeatingChannel(id *string, repeatProbability int) *PeeringNetDynamic

type PeeringNetwork added in v0.1.0

type PeeringNetwork struct {
	// contains filtered or unexported fields
}

PeeringNetwork represents a global view of the mocked network.

func NewPeeringNetwork added in v0.1.0

func NewPeeringNetwork(
	netIDs []string,
	nodeIdentities []*ed25519.KeyPair,
	bufSize int,
	behavior PeeringNetBehavior,
	log *logger.Logger,
) *PeeringNetwork

NewPeeringNetwork creates new test network, it can then be used to create network nodes.

func NewPeeringNetworkForLocs added in v0.1.0

func NewPeeringNetworkForLocs(peerNetIDs []string, bufSize int, log *logger.Logger) *PeeringNetwork

NewPeeringNetworkForLocs creates a test network with new keys, etc.

func (*PeeringNetwork) Close added in v0.2.0

func (p *PeeringNetwork) Close() error

Close implements the io.Closer interface.

func (*PeeringNetwork) NetworkProviders added in v0.1.0

func (p *PeeringNetwork) NetworkProviders() []peering.NetworkProvider

NetworkProviders returns network providers for each of the nodes in the network.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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