Documentation ¶
Overview ¶
Package test offers some common functionalities that are used throughout many different tests in drand.
Index ¶
- func Addresses(n int) []string
- func BatchIdentities(n int, sch *crypto.Scheme, beaconID string) ([]*key.Pair, *key.Group)
- func BatchTLSIdentities(n int, sch *crypto.Scheme, beaconID string) ([]*key.Pair, *key.Group)
- func ComputeDBName() string
- func DumpContainerLogs(id string) []byte
- func FreeBind(a string) string
- func FreePort() string
- func GenerateIDs(n int) []*key.Pair
- func GetBeaconIDFromEnv() string
- func ListFromPrivates(keys []*key.Pair) []*key.Node
- func LocalHost() string
- func LogLevel(t *testing.T) int
- func Logger(t *testing.T) log.Logger
- func NewKeyStore() key.Store
- func NewPeer(addr string) net.Peer
- func NewTLSPeer(addr string) net.Peer
- func NewUnit(t *testing.T, c *Container, dbName string) (log.Logger, *sqlx.DB)
- func Ports(n int) []string
- func StopContainer(id string) error
- func StopPGDB(c *Container)
- func StringToPoint(s string) (kyber.Point, error)
- type Container
- type KeyStore
- func (k *KeyStore) LoadDistPublic() (*key.DistPublic, error)
- func (k *KeyStore) LoadGroup() (*key.Group, error)
- func (k *KeyStore) LoadKeyPair(_ *crypto.Scheme) (*key.Pair, error)
- func (k *KeyStore) LoadShare(_ *crypto.Scheme) (*key.Share, error)
- func (k *KeyStore) Reset(...key.ResetOption) error
- func (k *KeyStore) SaveDistPublic(d *key.DistPublic) error
- func (k *KeyStore) SaveGroup(g *key.Group) error
- func (k *KeyStore) SaveKeyPair(p *key.Pair) error
- func (k *KeyStore) SaveShare(share *key.Share) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Addresses ¶
Addresses returns a list of TCP localhost addresses starting from the given port= start.
func BatchIdentities ¶
BatchIdentities generates n insecure identities
func BatchTLSIdentities ¶ added in v0.3.7
BatchTLSIdentities generates n secure (TLS) identities
func ComputeDBName ¶ added in v1.5.3
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 ¶ added in v1.5.3
DumpContainerLogs outputs logs from the running docker container.
func FreePort ¶
func FreePort() string
FreePort returns an free TCP port. Taken from https://github.com/phayes/freeport/blob/master/freeport.go
func GenerateIDs ¶
GenerateIDs returns n keys with random port localhost addresses
func GetBeaconIDFromEnv ¶ added in v1.4.6
func GetBeaconIDFromEnv() string
GetBeaconIDFromEnv read beacon id from an environment variable.
func ListFromPrivates ¶
ListFromPrivates returns a list of Identity from a list of Pair keys.
func LocalHost ¶ added in v1.0.0
func LocalHost() string
LocalHost returns the default local bind address: e.g. [::] or 127.0.0.1
func LogLevel ¶ added in v1.5.3
LogLevel returns the level to default the logger based on the DRAND_TEST_LOGS presence
func NewKeyStore ¶
func NewTLSPeer ¶ added in v0.3.7
NewTLSPeer returns a new net.Peer with TLS enabled
func NewUnit ¶ added in v1.5.3
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 ¶ added in v0.4.0
Ports returns a list of ports starting from the given port= start. TODO: This function is flaky.
func StopContainer ¶ added in v1.5.3
StopContainer stops and removes the specified container.
Types ¶
type Container ¶ added in v1.5.3
Container tracks information about the docker container started for tests.
func StartContainer ¶ added in v1.5.3
StartContainer starts the specified container for running tests.
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
func (*KeyStore) LoadDistPublic ¶
func (k *KeyStore) LoadDistPublic() (*key.DistPublic, error)
func (*KeyStore) LoadKeyPair ¶ added in v0.3.6
func (*KeyStore) SaveDistPublic ¶
func (k *KeyStore) SaveDistPublic(d *key.DistPublic) error