Documentation
¶
Overview ¶
Package sessiontest implements test helpers for functionalities defined in session.
Index ¶
- Constants
- func NewConfig(rng *rand.Rand, peerIDs ...perun.PeerID) (session.Config, error)
- func NewConfigFile(config interface{}) (string, error)
- func NewConfigFileT(t *testing.T, config session.Config) string
- func NewConfigT(t *testing.T, rng *rand.Rand, peerIDs ...perun.PeerID) session.Config
- func NewUserConfig(rng *rand.Rand, n uint) (perun.WalletBackend, session.UserConfig, error)
- func NewUserConfigT(t *testing.T, rng *rand.Rand, n uint) (perun.WalletBackend, session.UserConfig)
Constants ¶
const PeerReconnTimeout = 20 * time.Second
PeerReconnTimeout is the suggested value for peer reconnection timeout for use in test environments.
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 ¶
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 ¶
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
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
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 ¶
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
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.