mocks

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const BLOCK_HEIGHT_DONT_CARE = math.MaxUint64
View Source
const VIEW_DONT_CARE = math.MaxUint64

Variables

This section is empty.

Functions

func ABlock

func ABlock(previousBlock interfaces.Block) interfaces.Block

func CalculateBlockHash

func CalculateBlockHash(block interfaces.Block) primitives.BlockHash

func NewMockConfig added in v0.2.0

func NewMockConfig() *interfaces.Config

Types

type BlocksPool

type BlocksPool struct {
	// contains filtered or unexported fields
}

func NewBlocksPool

func NewBlocksPool(upcomingBlocks []interfaces.Block) *BlocksPool

func (*BlocksPool) PopBlock

func (bp *BlocksPool) PopBlock(prevBlock interfaces.Block) interfaces.Block

type CommunicationMock

type CommunicationMock struct {
	// contains filtered or unexported fields
}

func NewCommunication

func NewCommunication(memberId primitives.MemberId, discovery *Discovery, log interfaces.Logger) *CommunicationMock

func (*CommunicationMock) CountMessagesSent added in v0.2.0

func (g *CommunicationMock) CountMessagesSent(messageType protocol.MessageType, height primitives.BlockHeight, view primitives.View, target primitives.MemberId) int

func (*CommunicationMock) CountSentMessages

func (g *CommunicationMock) CountSentMessages(messageType protocol.MessageType) int

TODO REMOVE THIS REDUNDANT METHOD

func (*CommunicationMock) DisableIncomingCommunication added in v0.2.0

func (g *CommunicationMock) DisableIncomingCommunication()

func (*CommunicationMock) DisableOutgoingCommunication added in v0.2.0

func (g *CommunicationMock) DisableOutgoingCommunication()

func (*CommunicationMock) EnableIncomingCommunication added in v0.2.0

func (g *CommunicationMock) EnableIncomingCommunication()

func (*CommunicationMock) EnableOutgoingCommunication added in v0.2.0

func (g *CommunicationMock) EnableOutgoingCommunication()

func (*CommunicationMock) GetSentMessages

func (g *CommunicationMock) GetSentMessages(messageType protocol.MessageType) []*interfaces.ConsensusRawMessage

TODO Refactor this, maybe get the data from messagesHistory instead of statsSentMessages

func (*CommunicationMock) OnIncomingMessage added in v0.2.0

func (g *CommunicationMock) OnIncomingMessage(ctx context.Context, rawMessage *interfaces.ConsensusRawMessage)

func (*CommunicationMock) RegisterIncomingMessageHandler added in v0.2.0

func (g *CommunicationMock) RegisterIncomingMessageHandler(cb func(ctx context.Context, message *interfaces.ConsensusRawMessage))

func (*CommunicationMock) ReturnAndMaybeCreateOutgoingChannelByTarget added in v0.2.0

func (g *CommunicationMock) ReturnAndMaybeCreateOutgoingChannelByTarget(ctx context.Context, target primitives.MemberId) chan *outgoingMessage

func (*CommunicationMock) ReturnOutgoingChannelByTarget added in v0.2.0

func (g *CommunicationMock) ReturnOutgoingChannelByTarget(target primitives.MemberId) chan *outgoingMessage

func (*CommunicationMock) SendConsensusMessage

func (g *CommunicationMock) SendConsensusMessage(ctx context.Context, targets []primitives.MemberId, message *interfaces.ConsensusRawMessage) error

func (*CommunicationMock) SendToNode

func (g *CommunicationMock) SendToNode(ctx context.Context, receiverMemberId primitives.MemberId, consensusRawMessage *interfaces.ConsensusRawMessage)

func (*CommunicationMock) SetIncomingWhitelist

func (g *CommunicationMock) SetIncomingWhitelist(incomingWhitelist []primitives.MemberId)

func (*CommunicationMock) SetMessagesMaxDelay

func (g *CommunicationMock) SetMessagesMaxDelay(duration time.Duration)

func (*CommunicationMock) SetOutgoingWhitelist

func (g *CommunicationMock) SetOutgoingWhitelist(outgoingWhitelist []primitives.MemberId)

type Discovery

type Discovery struct {
	// contains filtered or unexported fields
}

func NewDiscovery

func NewDiscovery() *Discovery

func (*Discovery) AllCommunicationsMemberIds

func (d *Discovery) AllCommunicationsMemberIds() []primitives.MemberId

func (*Discovery) Communications

func (d *Discovery) Communications(memberIds []primitives.MemberId) []*CommunicationMock

func (*Discovery) GetCommunicationById

func (d *Discovery) GetCommunicationById(memberId primitives.MemberId) *CommunicationMock

func (*Discovery) RegisterCommunication

func (d *Discovery) RegisterCommunication(memberId primitives.MemberId, communication *CommunicationMock)

func (*Discovery) UnregisterCommunication

func (d *Discovery) UnregisterCommunication(memberId primitives.MemberId)

type ElectionTriggerMock

type ElectionTriggerMock struct {
	// contains filtered or unexported fields
}

func NewMockElectionTrigger

func NewMockElectionTrigger() *ElectionTriggerMock

func (*ElectionTriggerMock) CalcTimeout

func (et *ElectionTriggerMock) CalcTimeout(view primitives.View) time.Duration

func (*ElectionTriggerMock) ElectionChannel

func (et *ElectionTriggerMock) ElectionChannel() chan *interfaces.ElectionTrigger

func (*ElectionTriggerMock) ManualTrigger

func (et *ElectionTriggerMock) ManualTrigger(ctx context.Context, hv *state.HeightView) <-chan struct{}

func (*ElectionTriggerMock) ManualTriggerSync

func (et *ElectionTriggerMock) ManualTriggerSync(ctx context.Context)

func (*ElectionTriggerMock) RegisterOnElection

func (et *ElectionTriggerMock) RegisterOnElection(blockHeight primitives.BlockHeight, view primitives.View, cb func(ctx context.Context, blockHeight primitives.BlockHeight, view primitives.View, onElectionCB interfaces.OnElectionCallback))

func (*ElectionTriggerMock) Stop

func (et *ElectionTriggerMock) Stop()

type FakeMembership added in v0.2.0

type FakeMembership struct {
	// contains filtered or unexported fields
}

func NewFakeMembership added in v0.2.0

func NewFakeMembership(myMemberId primitives.MemberId, discovery *Discovery, orderCommitteeByHeight bool) *FakeMembership

func (*FakeMembership) MyMemberId added in v0.2.0

func (m *FakeMembership) MyMemberId() primitives.MemberId

func (*FakeMembership) RequestOrderedCommittee added in v0.2.0

func (m *FakeMembership) RequestOrderedCommittee(ctx context.Context, blockHeight primitives.BlockHeight, randomSeed uint64) ([]primitives.MemberId, error)

type InMemoryBlockchain added in v0.2.0

type InMemoryBlockchain struct {
	// contains filtered or unexported fields
}

func NewInMemoryBlockchain added in v0.2.0

func NewInMemoryBlockchain() *InMemoryBlockchain

func (*InMemoryBlockchain) AppendBlockToChain added in v0.2.0

func (bs *InMemoryBlockchain) AppendBlockToChain(block interfaces.Block, blockProof []byte)

func (*InMemoryBlockchain) BlockAndProofAt added in v0.2.0

func (bs *InMemoryBlockchain) BlockAndProofAt(height primitives.BlockHeight) (interfaces.Block, []byte)

func (*InMemoryBlockchain) Count added in v0.2.0

func (bs *InMemoryBlockchain) Count() int

func (*InMemoryBlockchain) LastBlock added in v0.2.0

func (bs *InMemoryBlockchain) LastBlock() interfaces.Block

func (*InMemoryBlockchain) LastBlockProof added in v0.2.0

func (bs *InMemoryBlockchain) LastBlockProof() []byte

func (*InMemoryBlockchain) WithMemberId added in v0.2.0

func (bs *InMemoryBlockchain) WithMemberId(memberId primitives.MemberId) *InMemoryBlockchain

type MockBlock

type MockBlock struct {
	fmt.Stringer
	// contains filtered or unexported fields
}

MockBlock

func (*MockBlock) Body

func (b *MockBlock) Body() string

func (*MockBlock) Height

func (b *MockBlock) Height() primitives.BlockHeight

func (*MockBlock) String added in v0.2.0

func (b *MockBlock) String() string

type MockKeyManager

type MockKeyManager struct {
	FailFutureVerifications bool
	// contains filtered or unexported fields
}

func NewMockKeyManager

func NewMockKeyManager(memberId primitives.MemberId, rejectedMemberIds ...primitives.MemberId) *MockKeyManager

func (*MockKeyManager) AggregateRandomSeed

func (km *MockKeyManager) AggregateRandomSeed(blockHeight primitives.BlockHeight, randomSeedShares []*protocol.SenderSignature) primitives.RandomSeedSignature

func (*MockKeyManager) SignConsensusMessage

func (km *MockKeyManager) SignConsensusMessage(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.Signature

func (*MockKeyManager) SignRandomSeed

func (km *MockKeyManager) SignRandomSeed(ctx context.Context, blockHeight primitives.BlockHeight, content []byte) primitives.RandomSeedSignature

func (*MockKeyManager) VerifyConsensusMessage

func (km *MockKeyManager) VerifyConsensusMessage(blockHeight primitives.BlockHeight, content []byte, sender *protocol.SenderSignature) error

func (*MockKeyManager) VerifyRandomSeed

func (km *MockKeyManager) VerifyRandomSeed(blockHeight primitives.BlockHeight, content []byte, sender *protocol.SenderSignature) error

func (*MockKeyManager) VerifyRandomSeedHistory

func (km *MockKeyManager) VerifyRandomSeedHistory(idx int) *VerifyRandomSeedCallParams

type MockState added in v0.2.0

type MockState struct {
	*state.State
}

func NewMockState added in v0.2.0

func NewMockState() *MockState

func (*MockState) WithHeightView added in v0.2.0

func (s *MockState) WithHeightView(h primitives.BlockHeight, v primitives.View) *MockState

type PausableBlockUtils added in v0.2.0

type PausableBlockUtils struct {
	interfaces.BlockUtils

	//PauseOnRequestNewBlock       bool
	RequestNewBlockCallsLeftUntilItPausesWhenCounterIsZero int64
	RequestNewBlockLatch                                   *test.Latch
	ValidationLatch                                        *test.Latch
	PauseOnValidateBlock                                   bool
	// contains filtered or unexported fields
}

func NewMockBlockUtils

func NewMockBlockUtils(memberId primitives.MemberId, blocksPool *BlocksPool, logger interfaces.Logger) *PausableBlockUtils

func (*PausableBlockUtils) RequestNewBlockProposal added in v0.2.0

func (b *PausableBlockUtils) RequestNewBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, _ primitives.MemberId, prevBlock interfaces.Block) (interfaces.Block, primitives.BlockHash)

func (*PausableBlockUtils) ValidateBlockCommitment added in v0.2.0

func (b *PausableBlockUtils) ValidateBlockCommitment(blockHeight primitives.BlockHeight, block interfaces.Block, blockHash primitives.BlockHash) bool

func (*PausableBlockUtils) ValidateBlockProposal added in v0.2.0

func (b *PausableBlockUtils) ValidateBlockProposal(ctx context.Context, blockHeight primitives.BlockHeight, _ primitives.MemberId, block interfaces.Block, blockHash primitives.BlockHash, prevBlock interfaces.Block) error

func (*PausableBlockUtils) WithFailingBlockProposalValidations added in v0.2.0

func (b *PausableBlockUtils) WithFailingBlockProposalValidations() *PausableBlockUtils

type SubscriptionValue

type SubscriptionValue struct {
	// contains filtered or unexported fields
}

type TermMessagesHandlerMock

type TermMessagesHandlerMock struct {
	HistoryPP []*interfaces.PreprepareMessage
	HistoryP  []*interfaces.PrepareMessage
	HistoryC  []*interfaces.CommitMessage
	HistoryNV []*interfaces.NewViewMessage
	HistoryVC []*interfaces.ViewChangeMessage
}

func NewTermMessagesHandlerMock

func NewTermMessagesHandlerMock() *TermMessagesHandlerMock

func (*TermMessagesHandlerMock) HandleCommit

func (tmh *TermMessagesHandlerMock) HandleCommit(ctx context.Context, cm *interfaces.CommitMessage)

func (*TermMessagesHandlerMock) HandleNewView

func (tmh *TermMessagesHandlerMock) HandleNewView(ctx context.Context, nvm *interfaces.NewViewMessage)

func (*TermMessagesHandlerMock) HandlePrePrepare

func (tmh *TermMessagesHandlerMock) HandlePrePrepare(ctx context.Context, ppm *interfaces.PreprepareMessage)

func (*TermMessagesHandlerMock) HandlePrepare

func (tmh *TermMessagesHandlerMock) HandlePrepare(ctx context.Context, pm *interfaces.PrepareMessage)

func (*TermMessagesHandlerMock) HandleViewChange

func (tmh *TermMessagesHandlerMock) HandleViewChange(ctx context.Context, vcm *interfaces.ViewChangeMessage)

type VerifyRandomSeedCallParams

type VerifyRandomSeedCallParams struct {
	BlockHeight primitives.BlockHeight
	Content     []byte
	Sender      *protocol.SenderSignature
}

Jump to

Keyboard shortcuts

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