Documentation ¶
Overview ¶
Package testutil provides helper methods that are useful for implementing tests.
Index ¶
- func ConfigAddReplica(t *testing.T, cfg *mocks.MockConfiguration, replica *mocks.MockReplica)
- func CreateMockConfigurationWithReplicas(t *testing.T, ctrl *gomock.Controller, n int, keys ...consensus.PrivateKey) (*mocks.MockConfiguration, []*mocks.MockReplica)
- func CreateMockReplica(t *testing.T, ctrl *gomock.Controller, id hotstuff.ID, key consensus.PublicKey) *mocks.MockReplica
- func CreatePC(t *testing.T, block *consensus.Block, signer consensus.Crypto) consensus.PartialCert
- func CreatePCs(t *testing.T, block *consensus.Block, signers []consensus.Crypto) []consensus.PartialCert
- func CreateQC(t *testing.T, block *consensus.Block, signers []consensus.Crypto) consensus.QuorumCert
- func CreateSignatures(t *testing.T, hash consensus.Hash, signers []consensus.Crypto) []consensus.Signature
- func CreateTC(t *testing.T, view consensus.View, signers []consensus.Crypto) consensus.TimeoutCert
- func CreateTCPListener(t *testing.T) net.Listener
- func CreateTimeouts(t *testing.T, view consensus.View, signers []consensus.Crypto) (timeouts []consensus.TimeoutMsg)
- func FixedTimeout(timeout float64) synchronizer.ViewDuration
- func GenerateBLS12Key(t *testing.T) consensus.PrivateKey
- func GenerateECDSAKey(t *testing.T) consensus.PrivateKey
- func GenerateKeys(t *testing.T, n int, keyFunc func(t *testing.T) consensus.PrivateKey) (keys []consensus.PrivateKey)
- func NewLeaderRotation(t *testing.T, order ...hotstuff.ID) consensus.LeaderRotation
- func NewProposeMsg(parent consensus.Hash, qc consensus.QuorumCert, cmd consensus.Command, ...) consensus.ProposeMsg
- func Sign(t *testing.T, hash consensus.Hash, signer consensus.Crypto) consensus.Signature
- func TestModules(t *testing.T, ctrl *gomock.Controller, id hotstuff.ID, ...) consensus.Builder
- type BuilderList
- type HotStuffList
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 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 CreateTCPListener ¶
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 float64) 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
NewLeaderRotation returns a leader rotation implementation that will return leaders in the specified order.
func NewProposeMsg ¶ added in v0.3.0
func NewProposeMsg(parent consensus.Hash, qc consensus.QuorumCert, cmd consensus.Command, view consensus.View, id hotstuff.ID) consensus.ProposeMsg
NewProposeMsg wraps a new block in a ProposeMsg.
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
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
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.