Documentation
¶
Overview ¶
Package testutil provides helper methods that are useful for implementing tests.
Index ¶
- func CreatePC(t *testing.T, block *hotstuff.Block, signer modules.Crypto) hotstuff.PartialCert
- func CreatePCs(t *testing.T, block *hotstuff.Block, signers []modules.Crypto) []hotstuff.PartialCert
- func CreateQC(t *testing.T, block *hotstuff.Block, signers []modules.Crypto) hotstuff.QuorumCert
- func CreateSignatures(t *testing.T, message []byte, signers []modules.Crypto) []hotstuff.QuorumSignature
- func CreateTC(t *testing.T, view hotstuff.View, signers []modules.Crypto) hotstuff.TimeoutCert
- func CreateTCPListener(t *testing.T) net.Listener
- func CreateTimeouts(t *testing.T, view hotstuff.View, signers []modules.Crypto) (timeouts []hotstuff.TimeoutMsg)
- func FixedTimeout(timeout time.Duration) synchronizer.ViewDuration
- func GenerateBLS12Key(t *testing.T) hotstuff.PrivateKey
- func GenerateECDSAKey(t *testing.T) hotstuff.PrivateKey
- func GenerateEDDSAKey(t *testing.T) hotstuff.PrivateKey
- func GenerateKeys(t *testing.T, n int, keyFunc func(t *testing.T) hotstuff.PrivateKey) (keys []hotstuff.PrivateKey)
- func NewLeaderRotation(t *testing.T, order ...hotstuff.ID) modules.LeaderRotation
- func NewProposeMsg(parent hotstuff.Hash, qc hotstuff.QuorumCert, cmd hotstuff.Command, ...) hotstuff.ProposeMsg
- func Sign(t *testing.T, message []byte, signer modules.Crypto) hotstuff.QuorumSignature
- func TestModules(t *testing.T, ctrl *gomock.Controller, id hotstuff.ID, _ hotstuff.PrivateKey, ...)
- type BuilderList
- type HotStuffList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePCs ¶ added in v0.3.0
func CreatePCs(t *testing.T, block *hotstuff.Block, signers []modules.Crypto) []hotstuff.PartialCert
CreatePCs creates one partial certificate using each of the given signers.
func CreateSignatures ¶ added in v0.3.0
func CreateSignatures(t *testing.T, message []byte, signers []modules.Crypto) []hotstuff.QuorumSignature
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 hotstuff.View, signers []modules.Crypto) (timeouts []hotstuff.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) hotstuff.PrivateKey
GenerateBLS12Key generates a BLS12-381 private key for use in tests.
func GenerateECDSAKey ¶ added in v0.3.0
func GenerateECDSAKey(t *testing.T) hotstuff.PrivateKey
GenerateECDSAKey generates an ECDSA private key for use in tests.
func GenerateEDDSAKey ¶ added in v0.5.0
func GenerateEDDSAKey(t *testing.T) hotstuff.PrivateKey
GenerateEDDSAKey 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) hotstuff.PrivateKey) (keys []hotstuff.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 hotstuff.Hash, qc hotstuff.QuorumCert, cmd hotstuff.Command, view hotstuff.View, id hotstuff.ID) hotstuff.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, _ hotstuff.PrivateKey, builder *modules.Builder)
TestModules registers default modules for testing to the given builder.
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 ...hotstuff.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 []hotstuff.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 []modules.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 []modules.Crypto)
Verifiers returns the set of verifiers from all of the HotStuff instances.