Documentation
¶
Index ¶
- func AllowAllMessages(*simplex.Message, simplex.NodeID, simplex.NodeID) bool
- func DefaultTestNodeEpochConfig(t *testing.T, nodeID simplex.NodeID, comm simplex.Communication, ...) (simplex.EpochConfig, *TestWAL, *InMemStorage)
- func InjectTestFinalization(t *testing.T, e *simplex.Epoch, finalization *simplex.Finalization, ...)
- func InjectTestFinalizeVote(t *testing.T, e *simplex.Epoch, block simplex.VerifiedBlock, id simplex.NodeID)
- func InjectTestNotarization(t *testing.T, e *simplex.Epoch, notarization simplex.Notarization, ...)
- func InjectTestVote(t *testing.T, e *simplex.Epoch, block simplex.VerifiedBlock, id simplex.NodeID)
- func NewEmptyNotarization(nodes []simplex.NodeID, round uint64) *simplex.EmptyNotarization
- func NewFinalizationRecord(t *testing.T, logger simplex.Logger, ...) (simplex.Finalization, []byte)
- func NewNotarization(logger simplex.Logger, signatureAggregator simplex.SignatureAggregator, ...) (simplex.Notarization, error)
- func NewNotarizationRecord(logger simplex.Logger, signatureAggregator simplex.SignatureAggregator, ...) ([]byte, error)
- func NewTestControlledBlockBuilder(t *testing.T) *testControlledBlockBuilder
- func NewTestFinalizeVote(t *testing.T, block simplex.VerifiedBlock, id simplex.NodeID) *simplex.FinalizeVote
- func NewTestVote(block AnyBlock, id simplex.NodeID) (*simplex.Vote, error)
- func WaitForBlockProposerTimeout(t *testing.T, e *simplex.Epoch, startTime *time.Time, startRound uint64)
- func WaitToEnterRound(t *testing.T, e *simplex.Epoch, round uint64)
- type AnyBlock
- type BlockDeserializer
- type EncodedTestBlock
- type InMemNetwork
- func (n *InMemNetwork) AdvanceWithoutLeader(epochTimes []time.Time, round uint64, laggingNodeId simplex.NodeID)
- func (n *InMemNetwork) Connect(node simplex.NodeID)
- func (n *InMemNetwork) Disconnect(node simplex.NodeID)
- func (n *InMemNetwork) IsDisconnected(node simplex.NodeID) bool
- func (n *InMemNetwork) SetAllNodesMessageFilter(filter MessageFilter)
- func (n *InMemNetwork) StartInstances()
- func (n *InMemNetwork) TriggerLeaderBlockBuilder(round uint64) *TestBlock
- type InMemStorage
- func (mem *InMemStorage) Clone() *InMemStorage
- func (mem *InMemStorage) EnsureNoBlockCommit(t *testing.T, seq uint64)
- func (mem *InMemStorage) Index(ctx context.Context, block simplex.VerifiedBlock, ...) error
- func (mem *InMemStorage) NumBlocks() uint64
- func (mem *InMemStorage) Retrieve(seq uint64) (simplex.VerifiedBlock, simplex.Finalization, error)
- func (mem *InMemStorage) WaitForBlockCommit(seq uint64) simplex.VerifiedBlock
- type MessageFilter
- type NoopComm
- type TestBlock
- type TestBlockBuilder
- type TestComm
- type TestLogger
- type TestNetworkCommunication
- type TestNode
- type TestNodeConfig
- type TestQC
- type TestSignatureAggregator
- type TestWAL
- func (tw *TestWAL) Append(b []byte) error
- func (tw *TestWAL) AssertBlockProposal(round uint64)
- func (tw *TestWAL) AssertEmptyVote(round uint64)
- func (tw *TestWAL) AssertNotarization(round uint64) uint16
- func (tw *TestWAL) AssertWALSize(n int)
- func (tw *TestWAL) Clone() *TestWAL
- func (tw *TestWAL) ContainsEmptyNotarization(round uint64) bool
- func (tw *TestWAL) ContainsEmptyVote(round uint64) bool
- func (tw *TestWAL) ContainsNotarization(round uint64) bool
- func (tw *TestWAL) ReadAll() ([][]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowAllMessages ¶
AllowAllMessages allows every message to be sent
func DefaultTestNodeEpochConfig ¶
func DefaultTestNodeEpochConfig(t *testing.T, nodeID simplex.NodeID, comm simplex.Communication, bb simplex.BlockBuilder) (simplex.EpochConfig, *TestWAL, *InMemStorage)
DefaultTestNodeEpochConfig returns a default epoch config for a given node.
func InjectTestFinalization ¶
func InjectTestFinalizeVote ¶
func InjectTestNotarization ¶
func InjectTestVote ¶
func NewEmptyNotarization ¶
func NewEmptyNotarization(nodes []simplex.NodeID, round uint64) *simplex.EmptyNotarization
NewEmptyNotarization creates a new empty notarization
func NewFinalizationRecord ¶
func NewFinalizationRecord(t *testing.T, logger simplex.Logger, signatureAggregator simplex.SignatureAggregator, block simplex.VerifiedBlock, ids []simplex.NodeID) (simplex.Finalization, []byte)
creates a new finalization
func NewNotarization ¶
func NewNotarization(logger simplex.Logger, signatureAggregator simplex.SignatureAggregator, block simplex.VerifiedBlock, ids []simplex.NodeID) (simplex.Notarization, error)
func NewNotarizationRecord ¶
func NewNotarizationRecord(logger simplex.Logger, signatureAggregator simplex.SignatureAggregator, block simplex.VerifiedBlock, ids []simplex.NodeID) ([]byte, error)
func NewTestControlledBlockBuilder ¶
NewTestControlledBlockBuilder returns a BlockBuilder that only builds a block when triggerNewBlock is called.
func NewTestFinalizeVote ¶
func NewTestFinalizeVote(t *testing.T, block simplex.VerifiedBlock, id simplex.NodeID) *simplex.FinalizeVote
Types ¶
type AnyBlock ¶
type AnyBlock interface { // BlockHeader encodes a succinct and collision-free representation of a block. BlockHeader() simplex.BlockHeader }
type BlockDeserializer ¶
type BlockDeserializer struct {
// DelayedVerification will block verifying any deserialized blocks until we send to the channel
DelayedVerification chan struct{}
}
func (*BlockDeserializer) DeserializeBlock ¶
type EncodedTestBlock ¶
type InMemNetwork ¶
type InMemNetwork struct { Instances []*TestNode // contains filtered or unexported fields }
func NewInMemNetwork ¶
func NewInMemNetwork(t *testing.T, nodes []simplex.NodeID) *InMemNetwork
NewInMemNetwork creates an in-memory network. Node IDs must be provided before adding instances, as nodes require prior knowledge of all participants.
func (*InMemNetwork) AdvanceWithoutLeader ¶
func (*InMemNetwork) Connect ¶
func (n *InMemNetwork) Connect(node simplex.NodeID)
func (*InMemNetwork) Disconnect ¶
func (n *InMemNetwork) Disconnect(node simplex.NodeID)
func (*InMemNetwork) IsDisconnected ¶
func (n *InMemNetwork) IsDisconnected(node simplex.NodeID) bool
func (*InMemNetwork) SetAllNodesMessageFilter ¶
func (n *InMemNetwork) SetAllNodesMessageFilter(filter MessageFilter)
func (*InMemNetwork) StartInstances ¶
func (n *InMemNetwork) StartInstances()
StartInstances starts all instances in the network. The first one is typically the leader, so we make sure to start it last.
func (*InMemNetwork) TriggerLeaderBlockBuilder ¶
func (n *InMemNetwork) TriggerLeaderBlockBuilder(round uint64) *TestBlock
type InMemStorage ¶
type InMemStorage struct {
// contains filtered or unexported fields
}
func NewInMemStorage ¶
func NewInMemStorage() *InMemStorage
func (*InMemStorage) Clone ¶
func (mem *InMemStorage) Clone() *InMemStorage
func (*InMemStorage) EnsureNoBlockCommit ¶
func (mem *InMemStorage) EnsureNoBlockCommit(t *testing.T, seq uint64)
func (*InMemStorage) Index ¶
func (mem *InMemStorage) Index(ctx context.Context, block simplex.VerifiedBlock, certificate simplex.Finalization) error
func (*InMemStorage) NumBlocks ¶
func (mem *InMemStorage) NumBlocks() uint64
func (*InMemStorage) Retrieve ¶
func (mem *InMemStorage) Retrieve(seq uint64) (simplex.VerifiedBlock, simplex.Finalization, error)
func (*InMemStorage) WaitForBlockCommit ¶
func (mem *InMemStorage) WaitForBlockCommit(seq uint64) simplex.VerifiedBlock
type MessageFilter ¶
MessageFilter is a function type that determines whether a message can be transmitted from one node to another. Parameters:
- msg: The message being evaluated for transmission
- from: The ID of the sending node
- to: The ID of the receiving node
Returns:
- bool: true if the message can be transmitted, false otherwise
type NoopComm ¶
func NewNoopComm ¶
type TestBlock ¶
type TestBlock struct { Data []byte Metadata simplex.ProtocolMetadata Digest [32]byte OnVerify func() VerificationDelay chan struct{} VerificationError error // contains filtered or unexported fields }
func NewTestBlock ¶
func NewTestBlock(metadata simplex.ProtocolMetadata, blacklist simplex.Blacklist) *TestBlock
func (*TestBlock) BlockHeader ¶
func (t *TestBlock) BlockHeader() simplex.BlockHeader
func (*TestBlock) ComputeDigest ¶
func (tb *TestBlock) ComputeDigest()
type TestBlockBuilder ¶
type TestBlockBuilder struct { Out chan *TestBlock In chan *TestBlock BlockShouldBeBuilt chan struct{} }
func NewTestBlockBuilder ¶
func NewTestBlockBuilder() *TestBlockBuilder
func (*TestBlockBuilder) BuildBlock ¶
func (t *TestBlockBuilder) BuildBlock(_ context.Context, metadata simplex.ProtocolMetadata, blacklist simplex.Blacklist) (simplex.VerifiedBlock, bool)
BuildBlock builds a new testblock and sends it to the BlockBuilder channel
func (*TestBlockBuilder) WaitForPendingBlock ¶
func (t *TestBlockBuilder) WaitForPendingBlock(ctx context.Context)
type TestComm ¶
type TestComm struct {
// contains filtered or unexported fields
}
func NewTestComm ¶
func NewTestComm(from simplex.NodeID, net *InMemNetwork, messageFilter MessageFilter) *TestComm
func (*TestComm) SetFilter ¶
func (c *TestComm) SetFilter(filter MessageFilter)
type TestLogger ¶
func MakeLogger ¶
func MakeLogger(t *testing.T, node ...int) *TestLogger
func (*TestLogger) Silence ¶
func (t *TestLogger) Silence()
type TestNetworkCommunication ¶
type TestNetworkCommunication interface { simplex.Communication SetFilter(filter MessageFilter) }
type TestNode ¶
type TestNode struct { WAL *TestWAL Storage *InMemStorage E *simplex.Epoch BB *testControlledBlockBuilder // contains filtered or unexported fields }
func NewSimplexNode ¶
func NewSimplexNode(t *testing.T, nodeID simplex.NodeID, net *InMemNetwork, config *TestNodeConfig) *TestNode
newSimplexNode creates a new testNode and adds it to net.
func (*TestNode) HandleMessage ¶
func (*TestNode) TriggerBlockShouldBeBuilt ¶
func (t *TestNode) TriggerBlockShouldBeBuilt()
TriggerBlockShouldBeBuilt signals this nodes block builder it is expecting a block to be built.
type TestNodeConfig ¶
type TestNodeConfig struct { // optional InitialStorage []simplex.VerifiedFinalizedBlock Comm simplex.Communication ReplicationEnabled bool }
type TestSignatureAggregator ¶
type TestSignatureAggregator struct {
Err error
}
func (*TestSignatureAggregator) Aggregate ¶
func (t *TestSignatureAggregator) Aggregate(signatures []simplex.Signature) (simplex.QuorumCertificate, error)
type TestWAL ¶
type TestWAL struct { simplex.WriteAheadLog // contains filtered or unexported fields }