tests

package
v0.2012.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package tests is a collection of registry implementation test cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BulkPopulate

func BulkPopulate(t *testing.T, backend api.Backend, consensus consensusAPI.Backend, runtimes []*TestRuntime, seed []byte) []*node.Node

PopulateBulk bulk populates the registry for the given TestRuntimes.

func EnsureRegistryEmpty

func EnsureRegistryEmpty(t *testing.T, backend api.Backend)

EnsureRegistryEmpty enforces that the registry has no entities or nodes registered.

Note: Runtimes and their owning entities are allowed, as there is no way to deregister them.

func RegistryImplementationTests

func RegistryImplementationTests(t *testing.T, backend api.Backend, consensus consensusAPI.Backend)

RegistryImplementationTests exercises the basic functionality of a registry backend.

WARNING: This assumes that the registry is empty, and will leave a Runtime registered.

Types

type TestEntity

type TestEntity struct {
	Entity *entity.Entity
	Signer signature.Signer

	SignedRegistration *entity.SignedEntity
	// contains filtered or unexported fields
}

TestEntity is a testing Entity and some common pre-generated/signed blobs useful for testing.

func NewTestEntities

func NewTestEntities(seed []byte, n int) ([]*TestEntity, error)

NewTestEntities returns the specified number of TestEntities, generated deterministically from the seed.

func (*TestEntity) Deregister

func (ent *TestEntity) Deregister(consensus consensusAPI.Backend) error

Deregister attempts to deregister the entity.

func (*TestEntity) NewTestNodes

func (ent *TestEntity) NewTestNodes(nCompute, nStorage int, idNonce []byte, runtimes []*node.Runtime, expiration epochtime.EpochTime, consensus consensusAPI.Backend) ([]*TestNode, error)

NewTestNodes returns the specified number of TestNodes, generated deterministically using the entity's public key as the seed.

func (*TestEntity) Register

func (ent *TestEntity) Register(consensus consensusAPI.Backend, sigEnt *entity.SignedEntity) error

Register attempts to register an entity.

type TestNode

type TestNode struct {
	Entity *TestEntity

	Node        *node.Node
	UpdatedNode *node.Node
	Signer      signature.Signer

	SignedRegistration        *node.MultiSignedNode
	SignedValidReRegistration *node.MultiSignedNode
	// contains filtered or unexported fields
}

TestNode is a testing Node and some common pre-generated/signed blobs useful for testing.

func (*TestNode) Register

func (n *TestNode) Register(consensus consensusAPI.Backend, sigNode *node.MultiSignedNode) error

Register attempts to register a node.

type TestRuntime

type TestRuntime struct {
	Runtime *api.Runtime
	Signer  signature.Signer
	// contains filtered or unexported fields
}

TestRuntime is a testing Runtime and some common pre-generated/signed blobs useful for testing.

func NewTestRuntime

func NewTestRuntime(seed []byte, ent *TestEntity, isKeyManager bool) (*TestRuntime, error)

NewTestRuntime returns a pre-generated TestRuntime for use with various tests, generated deterministically from the seed.

func (*TestRuntime) Cleanup

func (rt *TestRuntime) Cleanup(t *testing.T, backend api.Backend, consensus consensusAPI.Backend)

Cleanup deregisteres the entity and nodes for a given TestRuntime.

func (*TestRuntime) MustNotRegister

func (rt *TestRuntime) MustNotRegister(t *testing.T, backend api.Backend, consensus consensusAPI.Backend)

MustNotRegister attempts to register the TestRuntime with the provided registry and expects failure.

func (*TestRuntime) MustRegister

func (rt *TestRuntime) MustRegister(t *testing.T, backend api.Backend, consensus consensusAPI.Backend)

MustRegister registers the TestRuntime with the provided registry.

func (*TestRuntime) Populate

func (rt *TestRuntime) Populate(t *testing.T, backend api.Backend, consensus consensusAPI.Backend, seed []byte) []*node.Node

Populate populates the registry for a given TestRuntime.

func (*TestRuntime) TestNodes

func (rt *TestRuntime) TestNodes() []*TestNode

TestNodes returns the test runtime's TestNodes.

Jump to

Keyboard shortcuts

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