testutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 19 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 CreatePC added in v0.3.0

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

CreatePC creates a partial certificate using the given signer.

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 CreateQC added in v0.3.0

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

CreateQC creates a QC using 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 CreateTC added in v0.3.0

func CreateTC(t *testing.T, view hotstuff.View, signers []modules.Crypto) hotstuff.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 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

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

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 Sign added in v0.3.0

func Sign(t *testing.T, message []byte, signer modules.Crypto) hotstuff.QuorumSignature

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, _ hotstuff.PrivateKey, builder *modules.Builder)

TestModules registers default modules for testing to the given builder.

Types

type BuilderList added in v0.3.0

type BuilderList []*modules.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 ...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

type HotStuffList []*modules.Core

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.

Jump to

Keyboard shortcuts

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