test

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: MIT Imports: 8 Imported by: 13

Documentation

Overview

Package test contains generic tests and benchmarks for wallet backend implementation. Furthermore, it exports random generators of Addresses and Accounts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenericAccountBenchmark

func GenericAccountBenchmark(b *testing.B, s *Setup)

GenericAccountBenchmark runs a suite designed to benchmark the general speed of an implementation of an Account. This function should be called by every implementation of the Account interface.

func GenericAddressTest

func GenericAddressTest(t *testing.T, s *Setup)

GenericAddressTest runs a test suite designed to test the general functionality of addresses. This function should be called by every implementation of the wallet interface.

func GenericBackendBenchmark

func GenericBackendBenchmark(b *testing.B, s *Setup)

GenericBackendBenchmark runs a suite designed to benchmark the general speed of an implementation of a Backend. This function should be called by every implementation of the Backend interface.

func GenericSignatureSizeTest

func GenericSignatureSizeTest(t *testing.T, s *Setup)

GenericSignatureSizeTest tests that the size of the signatures produced by Account.Sign(…) does not vary between executions (tested with 2048 samples).

func GenericSignatureTest

func GenericSignatureTest(t *testing.T, s *Setup)

GenericSignatureTest runs a test suite designed to test the general functionality of an account. This function should be called by every implementation of the wallet interface.

func NewRandomAccount

func NewRandomAccount(rng *rand.Rand) wallet.Account

NewRandomAccount returns a new random account by calling the currently set wallet randomizer.

func NewRandomAddress

func NewRandomAddress(rng *rand.Rand) wallet.Address

NewRandomAddress returns a new random address by calling the currently set wallet randomizer.

func SetRandomizer

func SetRandomizer(b Randomizer)

SetRandomizer sets the wallet randomizer. It may be set multiple times.

func SetRandomizerTest

func SetRandomizerTest(t *testing.T)

SetRandomizerTest is a generic test to test that the wallet randomizer is set correctly.

Types

type Randomizer

type Randomizer interface {
	NewRandomAddress(*rand.Rand) wallet.Address
	NewRandomAccount(*rand.Rand) wallet.Account
}

Randomizer is the wallet testing backend. It currently supports the generation of random addresses.

type Setup

type Setup struct {
	UnlockedAccount UnlockedAccount // provides an account that is ready to sign
	//Address tests
	AddressBytes []byte         // a valid nonzero address not in the wallet
	Backend      wallet.Backend // backend implementation
	// Signature tests
	DataToSign []byte
}

Setup provides all objects needed for the generic tests

type UnlockedAccount

type UnlockedAccount func() (wallet.Account, error)

UnlockedAccount provides an unlocked account.

Jump to

Keyboard shortcuts

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