Documentation ¶
Index ¶
- type Node
- func (node *Node) Blockchain() *mocks.InMemoryBlockchain
- func (node *Node) BuildConfig(logger interfaces.Logger) *interfaces.Config
- func (node *Node) ConsensusRoundChannel() chan primitives.BlockHeight
- func (node *Node) DontPauseOnNewConsensusRound() *Node
- func (node *Node) GetCurrentHeight() primitives.BlockHeight
- func (node *Node) GetKeyManager() interfaces.KeyManager
- func (node *Node) GetLatestBlock() interfaces.Block
- func (node *Node) GetMemberId() primitives.MemberId
- func (node *Node) SetPauseOnNewConsensusRoundUntilReadingFrom(c chan primitives.BlockHeight) *Node
- func (node *Node) SetRequestNewBlockCallsLeftUntilItPausesWhenCounterIsZero(counter int64)
- func (node *Node) StartConsensus(ctx context.Context) error
- func (node *Node) State() *state.State
- func (node *Node) Sync(ctx context.Context, block interfaces.Block, blockProofBytes []byte, ...) error
- func (node *Node) TriggerElectionOnNode(ctx context.Context) <-chan struct{}
- func (node *Node) ValidateBlockConsensus(ctx context.Context, block interfaces.Block, blockProof []byte, ...) error
- func (node *Node) ValidateBlockConsensusSoft(ctx context.Context, block interfaces.Block, blockProof []byte, ...) error
- type NodeBuilder
- func (builder *NodeBuilder) AsInstanceId(instanceId primitives.InstanceId) *NodeBuilder
- func (builder *NodeBuilder) Build() *Node
- func (builder *NodeBuilder) CommunicatesVia(communication *mocks.CommunicationMock) *NodeBuilder
- func (builder *NodeBuilder) ThatIsPartOf(membership interfaces.Membership) *NodeBuilder
- func (builder *NodeBuilder) WithBlockUtils(utils interfaces.BlockUtils) *NodeBuilder
- func (builder *NodeBuilder) WithElectionTrigger(electionTrigger interfaces.ElectionScheduler) *NodeBuilder
- func (builder *NodeBuilder) WithLogger(logger interfaces.Logger) *NodeBuilder
- func (builder *NodeBuilder) WithMemberId(memberId primitives.MemberId) *NodeBuilder
- type NodeState
- type TestNetwork
- func ABasicTestNetwork(ctx context.Context) *TestNetwork
- func ABasicTestNetworkWithTimeBasedElectionsAndConsoleLogs(ctx context.Context, tb testing.TB) *TestNetwork
- func ABasicTestNetworkWithWeights(ctx context.Context) *TestNetwork
- func NewTestNetwork(instanceId primitives.InstanceId, discovery *mocks.Discovery, ...) *TestNetwork
- func (net *TestNetwork) AllNodesChainEndsWithABlock(block interfaces.Block) bool
- func (net *TestNetwork) AllNodesValidatedNoMoreThanOnceBeforeCommit(ctx context.Context) bool
- func (net *TestNetwork) GetNodeCommunication(memberId primitives.MemberId) *mocks.CommunicationMock
- func (net *TestNetwork) RegisterNode(node *Node)
- func (net *TestNetwork) RegisterNodes(nodes []*Node)
- func (net *TestNetwork) ResumeRequestNewBlockOnNodes(ctx context.Context, node *Node)
- func (net *TestNetwork) ResumeValidateBlockOnNodes(ctx context.Context, nodes ...*Node)
- func (net *TestNetwork) ReturnWhenNodeIsPausedOnRequestNewBlock(ctx context.Context, node *Node)
- func (net *TestNetwork) ReturnWhenNodesPauseOnUpdateState(ctx context.Context, node *Node)
- func (net *TestNetwork) ReturnWhenNodesPauseOnValidateBlock(ctx context.Context, nodes ...*Node)
- func (net *TestNetwork) SetNodesPauseOnRequestNewBlockWhenCounterIsZero(counter int64, nodes ...*Node)
- func (net *TestNetwork) SetNodesToNotPauseOnRequestNewBlock(nodes ...*Node)
- func (net *TestNetwork) SetNodesToPauseOnRequestNewBlock(nodes ...*Node)
- func (net *TestNetwork) SetNodesToPauseOnValidateBlock(nodes ...*Node)
- func (net *TestNetwork) StartConsensus(ctx context.Context) *TestNetwork
- func (net *TestNetwork) TriggerElectionsOnAllNodes(ctx context.Context)
- func (net *TestNetwork) TriggerElectionsOnNodes(ctx context.Context, nodes ...*Node)
- func (net *TestNetwork) WaitForShutdown(ctx context.Context)
- func (net *TestNetwork) WaitUntilNetworkIsRunning(ctx context.Context)
- func (net *TestNetwork) WaitUntilNodesEventuallyCommitASpecificBlock(ctx context.Context, t *testing.T, timeout time.Duration, ...)
- func (net *TestNetwork) WaitUntilNodesEventuallyReachASpecificHeight(ctx context.Context, height primitives.BlockHeight, nodes ...*Node)
- func (net *TestNetwork) WaitUntilQuorumOfNodesEventuallyReachASpecificHeight(ctx context.Context, height primitives.BlockHeight)
- func (net *TestNetwork) WaitUntilSubsetOfNodesEventuallyReachASpecificHeight(ctx context.Context, height primitives.BlockHeight, subset int, nodes ...*Node)
- type TestNetworkBuilder
- func (tb *TestNetworkBuilder) Build(ctx context.Context) *TestNetwork
- func (tb *TestNetworkBuilder) GossipMessagesMaxDelay(duration time.Duration) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) InNetwork(instanceId primitives.InstanceId) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) LogToConsole(t testing.TB) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) OrderCommitteeByHeight() *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithBlockUtils(utils []interfaces.BlockUtils) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithBlocks(upcomingBlocks ...interfaces.Block) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithCommunication(communication interfaces.Communication) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithKeyManager(mgr interfaces.KeyManager) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithMaybeFailingBlockProposalValidations(b bool, blocksPool ...interfaces.Block) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithNodeCount(nodeCount int) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithNodeWeights(weights []primitives.MemberWeight) *TestNetworkBuilder
- func (tb *TestNetworkBuilder) WithTimeBasedElectionTrigger(timeout time.Duration) *TestNetworkBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { ElectionTrigger interfaces.ElectionScheduler BlockUtils interfaces.BlockUtils KeyManager *mocks.MockKeyManager Storage interfaces.Storage Communication *mocks.CommunicationMock Membership interfaces.Membership MemberId primitives.MemberId MemberWeight uint64 CommittedBlockChannel chan *NodeState OnNewConsensusRoundChannel chan primitives.BlockHeight WriteToStateChannel bool OnUpdateStateLatch *test.Latch OnElectionCallback interface{} // contains filtered or unexported fields }
func ADummyNode ¶
func ADummyNode() *Node
func NewNode ¶
func NewNode( instanceId primitives.InstanceId, membership interfaces.Membership, communication *mocks.CommunicationMock, blockUtils interfaces.BlockUtils, electionTrigger interfaces.ElectionScheduler, logger interfaces.Logger) *Node
func (*Node) Blockchain ¶ added in v0.2.0
func (node *Node) Blockchain() *mocks.InMemoryBlockchain
func (*Node) BuildConfig ¶
func (node *Node) BuildConfig(logger interfaces.Logger) *interfaces.Config
func (*Node) ConsensusRoundChannel ¶ added in v0.2.0
func (node *Node) ConsensusRoundChannel() chan primitives.BlockHeight
func (*Node) DontPauseOnNewConsensusRound ¶ added in v0.2.0
func (*Node) GetCurrentHeight ¶ added in v0.2.0
func (node *Node) GetCurrentHeight() primitives.BlockHeight
func (*Node) GetKeyManager ¶
func (node *Node) GetKeyManager() interfaces.KeyManager
func (*Node) GetLatestBlock ¶
func (node *Node) GetLatestBlock() interfaces.Block
func (*Node) GetMemberId ¶
func (node *Node) GetMemberId() primitives.MemberId
func (*Node) SetPauseOnNewConsensusRoundUntilReadingFrom ¶ added in v0.2.0
func (node *Node) SetPauseOnNewConsensusRoundUntilReadingFrom(c chan primitives.BlockHeight) *Node
func (*Node) SetRequestNewBlockCallsLeftUntilItPausesWhenCounterIsZero ¶ added in v0.2.0
func (*Node) Sync ¶
func (node *Node) Sync(ctx context.Context, block interfaces.Block, blockProofBytes []byte, prevBlock interfaces.Block, prevBlockProofBytes []byte) error
func (*Node) TriggerElectionOnNode ¶ added in v0.2.0
func (*Node) ValidateBlockConsensus ¶
func (node *Node) ValidateBlockConsensus(ctx context.Context, block interfaces.Block, blockProof []byte, prevBlock interfaces.Block, prevBlockProof []byte) error
func (*Node) ValidateBlockConsensusSoft ¶ added in v0.6.0
func (node *Node) ValidateBlockConsensusSoft(ctx context.Context, block interfaces.Block, blockProof []byte, prevBlock interfaces.Block, prevBlockProof []byte) error
type NodeBuilder ¶
type NodeBuilder struct {
// contains filtered or unexported fields
}
func NewNodeBuilder ¶
func NewNodeBuilder() *NodeBuilder
func (*NodeBuilder) AsInstanceId ¶
func (builder *NodeBuilder) AsInstanceId(instanceId primitives.InstanceId) *NodeBuilder
func (*NodeBuilder) Build ¶
func (builder *NodeBuilder) Build() *Node
func (*NodeBuilder) CommunicatesVia ¶
func (builder *NodeBuilder) CommunicatesVia(communication *mocks.CommunicationMock) *NodeBuilder
func (*NodeBuilder) ThatIsPartOf ¶
func (builder *NodeBuilder) ThatIsPartOf(membership interfaces.Membership) *NodeBuilder
func (*NodeBuilder) WithBlockUtils ¶ added in v0.2.0
func (builder *NodeBuilder) WithBlockUtils(utils interfaces.BlockUtils) *NodeBuilder
func (*NodeBuilder) WithElectionTrigger ¶
func (builder *NodeBuilder) WithElectionTrigger(electionTrigger interfaces.ElectionScheduler) *NodeBuilder
func (*NodeBuilder) WithLogger ¶ added in v0.2.0
func (builder *NodeBuilder) WithLogger(logger interfaces.Logger) *NodeBuilder
func (*NodeBuilder) WithMemberId ¶
func (builder *NodeBuilder) WithMemberId(memberId primitives.MemberId) *NodeBuilder
type TestNetwork ¶
type TestNetwork struct { InstanceId primitives.InstanceId Nodes []*Node Discovery *mocks.Discovery // contains filtered or unexported fields }
func ABasicTestNetwork ¶
func ABasicTestNetwork(ctx context.Context) *TestNetwork
func ABasicTestNetworkWithTimeBasedElectionsAndConsoleLogs ¶ added in v0.2.0
func ABasicTestNetworkWithTimeBasedElectionsAndConsoleLogs(ctx context.Context, tb testing.TB) *TestNetwork
func ABasicTestNetworkWithWeights ¶ added in v0.4.0
func ABasicTestNetworkWithWeights(ctx context.Context) *TestNetwork
func NewTestNetwork ¶
func NewTestNetwork(instanceId primitives.InstanceId, discovery *mocks.Discovery, log interfaces.Logger) *TestNetwork
func (*TestNetwork) AllNodesChainEndsWithABlock ¶
func (net *TestNetwork) AllNodesChainEndsWithABlock(block interfaces.Block) bool
func (*TestNetwork) AllNodesValidatedNoMoreThanOnceBeforeCommit ¶
func (net *TestNetwork) AllNodesValidatedNoMoreThanOnceBeforeCommit(ctx context.Context) bool
func (*TestNetwork) GetNodeCommunication ¶
func (net *TestNetwork) GetNodeCommunication(memberId primitives.MemberId) *mocks.CommunicationMock
func (*TestNetwork) RegisterNode ¶
func (net *TestNetwork) RegisterNode(node *Node)
func (*TestNetwork) RegisterNodes ¶
func (net *TestNetwork) RegisterNodes(nodes []*Node)
func (*TestNetwork) ResumeRequestNewBlockOnNodes ¶ added in v0.2.0
func (net *TestNetwork) ResumeRequestNewBlockOnNodes(ctx context.Context, node *Node)
func (*TestNetwork) ResumeValidateBlockOnNodes ¶ added in v0.2.0
func (net *TestNetwork) ResumeValidateBlockOnNodes(ctx context.Context, nodes ...*Node)
func (*TestNetwork) ReturnWhenNodeIsPausedOnRequestNewBlock ¶ added in v0.2.0
func (net *TestNetwork) ReturnWhenNodeIsPausedOnRequestNewBlock(ctx context.Context, node *Node)
func (*TestNetwork) ReturnWhenNodesPauseOnUpdateState ¶ added in v0.2.0
func (net *TestNetwork) ReturnWhenNodesPauseOnUpdateState(ctx context.Context, node *Node)
func (*TestNetwork) ReturnWhenNodesPauseOnValidateBlock ¶ added in v0.2.0
func (net *TestNetwork) ReturnWhenNodesPauseOnValidateBlock(ctx context.Context, nodes ...*Node)
func (*TestNetwork) SetNodesPauseOnRequestNewBlockWhenCounterIsZero ¶ added in v0.2.0
func (net *TestNetwork) SetNodesPauseOnRequestNewBlockWhenCounterIsZero(counter int64, nodes ...*Node)
func (*TestNetwork) SetNodesToNotPauseOnRequestNewBlock ¶ added in v0.2.0
func (net *TestNetwork) SetNodesToNotPauseOnRequestNewBlock(nodes ...*Node)
func (*TestNetwork) SetNodesToPauseOnRequestNewBlock ¶
func (net *TestNetwork) SetNodesToPauseOnRequestNewBlock(nodes ...*Node)
func (*TestNetwork) SetNodesToPauseOnValidateBlock ¶ added in v0.2.0
func (net *TestNetwork) SetNodesToPauseOnValidateBlock(nodes ...*Node)
func (*TestNetwork) StartConsensus ¶
func (net *TestNetwork) StartConsensus(ctx context.Context) *TestNetwork
func (*TestNetwork) TriggerElectionsOnAllNodes ¶ added in v0.2.0
func (net *TestNetwork) TriggerElectionsOnAllNodes(ctx context.Context)
func (*TestNetwork) TriggerElectionsOnNodes ¶ added in v0.2.4
func (net *TestNetwork) TriggerElectionsOnNodes(ctx context.Context, nodes ...*Node)
func (*TestNetwork) WaitForShutdown ¶ added in v0.2.0
func (net *TestNetwork) WaitForShutdown(ctx context.Context)
func (*TestNetwork) WaitUntilNetworkIsRunning ¶ added in v0.2.0
func (net *TestNetwork) WaitUntilNetworkIsRunning(ctx context.Context)
Wait for H=1 so that election triggers will be sent with H=1 o/w they will sometimes be sent with H=0 and subsequently be ignored by workerloop's election channel, causing election to not happen, failing/hanging the test.
func (*TestNetwork) WaitUntilNodesEventuallyCommitASpecificBlock ¶ added in v0.2.0
func (net *TestNetwork) WaitUntilNodesEventuallyCommitASpecificBlock(ctx context.Context, t *testing.T, timeout time.Duration, block interfaces.Block, nodes ...*Node)
func (*TestNetwork) WaitUntilNodesEventuallyReachASpecificHeight ¶ added in v0.2.0
func (net *TestNetwork) WaitUntilNodesEventuallyReachASpecificHeight(ctx context.Context, height primitives.BlockHeight, nodes ...*Node)
func (*TestNetwork) WaitUntilQuorumOfNodesEventuallyReachASpecificHeight ¶ added in v0.2.0
func (net *TestNetwork) WaitUntilQuorumOfNodesEventuallyReachASpecificHeight(ctx context.Context, height primitives.BlockHeight)
func (*TestNetwork) WaitUntilSubsetOfNodesEventuallyReachASpecificHeight ¶ added in v0.2.0
func (net *TestNetwork) WaitUntilSubsetOfNodesEventuallyReachASpecificHeight(ctx context.Context, height primitives.BlockHeight, subset int, nodes ...*Node)
type TestNetworkBuilder ¶
type TestNetworkBuilder struct { NodeCount int NodeWeights []primitives.MemberWeight // contains filtered or unexported fields }
func ATestNetworkBuilder ¶ added in v0.2.0
func ATestNetworkBuilder(countOfNodes int, blocksPool ...interfaces.Block) *TestNetworkBuilder
func NewTestNetworkBuilder ¶
func NewTestNetworkBuilder() *TestNetworkBuilder
func (*TestNetworkBuilder) Build ¶
func (tb *TestNetworkBuilder) Build(ctx context.Context) *TestNetwork
func (*TestNetworkBuilder) GossipMessagesMaxDelay ¶
func (tb *TestNetworkBuilder) GossipMessagesMaxDelay(duration time.Duration) *TestNetworkBuilder
func (*TestNetworkBuilder) InNetwork ¶
func (tb *TestNetworkBuilder) InNetwork(instanceId primitives.InstanceId) *TestNetworkBuilder
func (*TestNetworkBuilder) LogToConsole ¶
func (tb *TestNetworkBuilder) LogToConsole(t testing.TB) *TestNetworkBuilder
func (*TestNetworkBuilder) OrderCommitteeByHeight ¶
func (tb *TestNetworkBuilder) OrderCommitteeByHeight() *TestNetworkBuilder
func (*TestNetworkBuilder) WithBlockUtils ¶
func (tb *TestNetworkBuilder) WithBlockUtils(utils []interfaces.BlockUtils) *TestNetworkBuilder
func (*TestNetworkBuilder) WithBlocks ¶
func (tb *TestNetworkBuilder) WithBlocks(upcomingBlocks ...interfaces.Block) *TestNetworkBuilder
func (*TestNetworkBuilder) WithCommunication ¶
func (tb *TestNetworkBuilder) WithCommunication(communication interfaces.Communication) *TestNetworkBuilder
func (*TestNetworkBuilder) WithKeyManager ¶
func (tb *TestNetworkBuilder) WithKeyManager(mgr interfaces.KeyManager) *TestNetworkBuilder
func (*TestNetworkBuilder) WithMaybeFailingBlockProposalValidations ¶ added in v0.2.0
func (tb *TestNetworkBuilder) WithMaybeFailingBlockProposalValidations(b bool, blocksPool ...interfaces.Block) *TestNetworkBuilder
func (*TestNetworkBuilder) WithNodeCount ¶
func (tb *TestNetworkBuilder) WithNodeCount(nodeCount int) *TestNetworkBuilder
func (*TestNetworkBuilder) WithNodeWeights ¶ added in v0.4.0
func (tb *TestNetworkBuilder) WithNodeWeights(weights []primitives.MemberWeight) *TestNetworkBuilder
func (*TestNetworkBuilder) WithTimeBasedElectionTrigger ¶
func (tb *TestNetworkBuilder) WithTimeBasedElectionTrigger(timeout time.Duration) *TestNetworkBuilder
Click to show internal directories.
Click to hide internal directories.