sessiontest

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package sessiontest implements test helpers for functionalities defined in session.

Index

Constants

View Source
const PeerReconnTimeout = 20 * time.Second

PeerReconnTimeout is the suggested value for peer reconnection timeout for use in test environments.

View Source
const ResponseTimeout = 10 * time.Second

ResponseTimeout is the suggested value for peer response timeout for use in tests.

Variables

This section is empty.

Functions

func NewConfig

func NewConfig(rng *rand.Rand, peerIDs ...perun.PeerID) (session.Config, error)

NewConfig generates random configuration data for the session using the given prng. It creates a local ID provider instance, populates it with the list of peer IDs passed to this function and updates the URL in the session config. This function also registers cleanup functions for removing all the temp files and dirs after the test.

This function returns a session config with user on-chain addresses that are funded on blockchain when using a particular seed for prng. The first two consecutive calls to this function will return funded accounts when using prng := rand.New(rand.NewSource(ethereumtest.RandSeedForTestAccs)).

func NewConfigFile

func NewConfigFile(config interface{}) (string, error)

NewConfigFile creates a temporary file containing the given session configuration and returns the path to it. It also registers a cleanup function on the passed test handler.

func NewConfigFileT added in v0.4.0

func NewConfigFileT(t *testing.T, config session.Config) string

NewConfigFileT is the test friendly version of NewConfigFile. It uses the passed testing.T to handle the errors and registers the cleanup functions on it.

func NewConfigT added in v0.4.0

func NewConfigT(t *testing.T, rng *rand.Rand, peerIDs ...perun.PeerID) session.Config

NewConfigT is the test friendly version of NewConfig. It uses the passed testing.T to handle the errors and registers the cleanup functions on it.

func NewUserConfig

func NewUserConfig(rng *rand.Rand, n uint) (perun.WalletBackend, session.UserConfig, error)

NewUserConfig returns a test user configuration with random data generated using the given rng. It creates "n" participant accounts to the user.

func NewUserConfigT added in v0.4.0

func NewUserConfigT(t *testing.T, rng *rand.Rand, n uint) (perun.WalletBackend, session.UserConfig)

NewUserConfigT is the test friendly version of NewUserConfig. It uses the passed testing.T to handle the errors and registers the cleanup functions on it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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