test

package
v2.0.5-testnet Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 0

Documentation

Overview

Package test offers some common functionalities that are used throughout many different tests in drand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Addresses

func Addresses(n int) []string

Addresses returns a list of TCP 127.0.0.1 addresses starting from the given port= start.

func BatchIdentities

func BatchIdentities(t *testing.T, n int, sch *crypto.Scheme, beaconID string) ([]*key.Pair, *key.Group)

BatchIdentities generates n insecure identities

func ComputeDBName

func ComputeDBName() string

ComputeDBName helps generate new, unique database names during the runtime of a test. By adding the time, with milliseconds, we can avoid this, e.g. drand_test_09223736225

func DumpContainerLogs

func DumpContainerLogs(id string) []byte

DumpContainerLogs outputs logs from the running docker container.

func FreeBind

func FreeBind(a string) string

FreeBind provides an address for binding on provided address

func FreePort

func FreePort() string

FreePort returns an free TCP port. Taken from https://github.com/phayes/freeport/blob/master/freeport.go

func GenerateIDs

func GenerateIDs(n int) []*key.Pair

GenerateIDs returns n keys with random port 127.0.0.1 addresses

func GetBeaconIDFromEnv

func GetBeaconIDFromEnv() string

GetBeaconIDFromEnv read beacon id from an environment variable.

func ListFromPrivates

func ListFromPrivates(keys []*key.Pair) []*key.Node

ListFromPrivates returns a list of Identity from a list of Pair keys.

func NewKeyStore

func NewKeyStore() key.Store

func NewPeer

func NewPeer(addr string) net.Peer

NewPeer returns a new net.Peer

func NewUnit

func NewUnit(t *testing.T, c *Container, dbName string) (log.Logger, *sqlx.DB)

NewUnit creates a test database inside a Docker container. It creates the required table structure but the database is otherwise empty. It returns the database to use as well as a function to call at the end of the test.

func Ports

func Ports(n int) []string

Ports returns a list of ports starting from the given port= start. TODO: This function is flaky.

func StopContainer

func StopContainer(id string) error

StopContainer stops and removes the specified container.

func StopPGDB

func StopPGDB(c *Container)

StopPGDB stops a running database instance.

func Tracer

func Tracer(t *testing.T, ctx context.Context) oteltrace.Tracer

Tracer allows building a tracer in the context of a test

func TracerWithName

func TracerWithName(t *testing.T, ctx context.Context, name string) oteltrace.Tracer

TracerWithName like Tracer but also adds the `_$name` suffix to the tracer name

Types

type Container

type Container struct {
	ID   string
	Host string // IP:Port
}

Container tracks information about the docker container started for tests.

func StartContainer

func StartContainer(image string, port string, args ...string) (*Container, error)

StartContainer starts the specified container for running tests.

func StartPGDB

func StartPGDB() (*Container, error)

StartPGDB starts a database instance.

type KeyStore

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

func (*KeyStore) LoadDistPublic

func (k *KeyStore) LoadDistPublic() (*key.DistPublic, error)

func (*KeyStore) LoadGroup

func (k *KeyStore) LoadGroup() (*key.Group, error)

func (*KeyStore) LoadKeyPair

func (k *KeyStore) LoadKeyPair() (*key.Pair, error)

func (*KeyStore) LoadShare

func (k *KeyStore) LoadShare() (*key.Share, error)

func (*KeyStore) Reset

func (k *KeyStore) Reset() error

func (*KeyStore) SaveDistPublic

func (k *KeyStore) SaveDistPublic(d *key.DistPublic) error

func (*KeyStore) SaveGroup

func (k *KeyStore) SaveGroup(g *key.Group) error

func (*KeyStore) SaveKeyPair

func (k *KeyStore) SaveKeyPair(p *key.Pair) error

func (*KeyStore) SaveShare

func (k *KeyStore) SaveShare(share *key.Share) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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