testutil

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package testutil provides helper methods that are useful for implementing tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigAddReplica

func ConfigAddReplica(t *testing.T, cfg *mocks.MockConfiguration, replica *mocks.MockReplica)

ConfigAddReplica adds a mock replica to a mock configuration.

func CreateMockConfigurationWithReplicas added in v0.3.0

func CreateMockConfigurationWithReplicas(t *testing.T, ctrl *gomock.Controller, n int, keys ...consensus.PrivateKey) (*mocks.MockConfiguration, []*mocks.MockReplica)

CreateMockConfigurationWithReplicas creates a configuration with n replicas.

func CreateMockReplica

func CreateMockReplica(t *testing.T, ctrl *gomock.Controller, id hotstuff.ID, key consensus.PublicKey) *mocks.MockReplica

CreateMockReplica returns a mock of a consensus.Replica.

func CreatePC added in v0.3.0

func CreatePC(t *testing.T, block *consensus.Block, signer consensus.Crypto) consensus.PartialCert

CreatePC creates a partial certificate using the given signer.

func CreatePCs added in v0.3.0

func CreatePCs(t *testing.T, block *consensus.Block, signers []consensus.Crypto) []consensus.PartialCert

CreatePCs creates one partial certificate using each of the given signers.

func CreateQC added in v0.3.0

func CreateQC(t *testing.T, block *consensus.Block, signers []consensus.Crypto) consensus.QuorumCert

CreateQC creates a QC using the given signers.

func CreateSignatures added in v0.3.0

func CreateSignatures(t *testing.T, hash consensus.Hash, signers []consensus.Crypto) []consensus.Signature

CreateSignatures creates partial certificates from multiple signers.

func CreateTC added in v0.3.0

func CreateTC(t *testing.T, view consensus.View, signers []consensus.Crypto) consensus.TimeoutCert

CreateTC generates a TC using the given signers.

func CreateTCPListener

func CreateTCPListener(t *testing.T) net.Listener

CreateTCPListener creates a net.Listener on a random port.

func CreateTimeouts added in v0.3.0

func CreateTimeouts(t *testing.T, view consensus.View, signers []consensus.Crypto) (timeouts []consensus.TimeoutMsg)

CreateTimeouts creates a set of TimeoutMsg messages from the given signers.

func FixedTimeout added in v0.3.0

func FixedTimeout(timeout time.Duration) synchronizer.ViewDuration

FixedTimeout returns an ExponentialTimeout with a max exponent of 0.

func GenerateBLS12Key added in v0.3.0

func GenerateBLS12Key(t *testing.T) consensus.PrivateKey

GenerateBLS12Key generates a BLS12-381 private key for use in tests.

func GenerateECDSAKey added in v0.3.0

func GenerateECDSAKey(t *testing.T) consensus.PrivateKey

GenerateECDSAKey generates an ECDSA private key for use in tests.

func GenerateKeys added in v0.3.0

func GenerateKeys(t *testing.T, n int, keyFunc func(t *testing.T) consensus.PrivateKey) (keys []consensus.PrivateKey)

GenerateKeys generates n keys.

func NewLeaderRotation added in v0.3.0

func NewLeaderRotation(t *testing.T, order ...hotstuff.ID) consensus.LeaderRotation

NewLeaderRotation returns a leader rotation implementation that will return leaders in the specified order.

func NewProposeMsg added in v0.3.0

NewProposeMsg wraps a new block in a ProposeMsg.

func Sign added in v0.3.0

func Sign(t *testing.T, hash consensus.Hash, signer consensus.Crypto) consensus.Signature

Sign creates a signature using the given signer.

func TestModules added in v0.3.0

func TestModules(t *testing.T, ctrl *gomock.Controller, id hotstuff.ID, privkey consensus.PrivateKey) consensus.Builder

TestModules returns a builder containing default modules for testing.

Types

type BuilderList added in v0.3.0

type BuilderList []*consensus.Builder

BuilderList is a helper type to perform actions on a set of builders.

func CreateBuilders added in v0.3.0

func CreateBuilders(t *testing.T, ctrl *gomock.Controller, n int, keys ...consensus.PrivateKey) (builders BuilderList)

CreateBuilders creates n builders with default consensus. Configurations are initialized with replicas.

func (BuilderList) Build added in v0.3.0

func (bl BuilderList) Build() HotStuffList

Build calls Build() for all of the builders.

type HotStuffList added in v0.3.0

type HotStuffList []*consensus.Modules

HotStuffList is a helper type to perform actions on a set of HotStuff instances.

func (HotStuffList) Keys added in v0.3.0

func (hl HotStuffList) Keys() (keys []consensus.PrivateKey)

Keys returns the set of private keys from all of the HotStuff instances.

func (HotStuffList) Signers added in v0.3.0

func (hl HotStuffList) Signers() (signers []consensus.Crypto)

Signers returns the set of signers from all of the HotStuff instances.

func (HotStuffList) Verifiers added in v0.3.0

func (hl HotStuffList) Verifiers() (verifiers []consensus.Crypto)

Verifiers returns the set of verifiers from all of the HotStuff instances.

Jump to

Keyboard shortcuts

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