testutil

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2020 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenesisBlock

func GenesisBlock(signatories id.Signatories) block.Block

func GetStateFromProcess

func GetStateFromProcess(p *process.Process, f int) process.State

func NewMockBroadcaster

func NewMockBroadcaster(broadcastMessages, castMessages chan<- process.Message) process.Broadcaster

func NewMockProposer

func NewMockProposer(key *ecdsa.PrivateKey) process.Proposer

func NewMockSaveRestorer added in v0.4.2

func NewMockSaveRestorer() process.SaveRestorer

func NewMockScheduler

func NewMockScheduler(sig id.Signatory) process.Scheduler

func NewMockTimer

func NewMockTimer(timeout time.Duration) process.Timer

func NewMockValidator

func NewMockValidator(valid error) process.Validator

func RandomBlock

func RandomBlock(kind block.Kind) block.Block

func RandomBlockHeader

func RandomBlockHeader(kind block.Kind) block.Header

RandomBlockHeader generates a random block.Header of the given kind which guarantee to be valid.

func RandomBlockKind

func RandomBlockKind() block.Kind

RandomBlockKind returns a random valid block kind.

func RandomBytesSlice

func RandomBytesSlice() []byte

RandomBytesSlice returns a random bytes slice.

func RandomHash

func RandomHash() id.Hash

func RandomHashes

func RandomHashes() id.Hashes

func RandomHeight

func RandomHeight() block.Height

func RandomInbox

func RandomInbox(f int, t process.MessageType) *process.Inbox

func RandomMessage

func RandomMessage(t process.MessageType) process.Message

func RandomMessageType

func RandomMessageType(includeResync bool) process.MessageType

func RandomMessageWithHeightAndRound

func RandomMessageWithHeightAndRound(height block.Height, round block.Round, t process.MessageType) process.Message

func RandomPrecommit

func RandomPrecommit() *process.Precommit

func RandomPrevote

func RandomPrevote() *process.Prevote

func RandomPropose

func RandomPropose() *process.Propose

func RandomResync added in v0.4.2

func RandomResync() *process.Resync

func RandomRound

func RandomRound() block.Round

func RandomSignatories

func RandomSignatories() id.Signatories

func RandomSignatory

func RandomSignatory() id.Signatory

func RandomSignature

func RandomSignature() id.Signature

func RandomSignatures

func RandomSignatures() id.Signatures

func RandomSignedMessage

func RandomSignedMessage(t process.MessageType) process.Message

func RandomSingedMessageWithHeightAndRound

func RandomSingedMessageWithHeightAndRound(height block.Height, round block.Round, t process.MessageType) process.Message

func RandomState

func RandomState() process.State

RandomState returns a random `process.State`.

func RandomStep

func RandomStep() process.Step

Types

type BlockHeaderJSON

type BlockHeaderJSON struct {
	Kind         block.Kind      `json:"kind"`
	ParentHash   id.Hash         `json:"parentHash"`
	BaseHash     id.Hash         `json:"baseHash"`
	TxsRef       id.Hash         `json:"txsRef"`
	PlanRef      id.Hash         `json:"planRef"`
	PrevStateRef id.Hash         `json:"prevStateRef"`
	Height       block.Height    `json:"height"`
	Round        block.Round     `json:"round"`
	Timestamp    block.Timestamp `json:"timestamp"`
	Signatories  id.Signatories  `json:"signatories"`
}

BlockHeaderJSON is almost a copy of the block.Header struct except all fields are exposed. This is for the convenience of initializing and marshaling.

func RandomBlockHeaderJSON

func RandomBlockHeaderJSON(kind block.Kind) BlockHeaderJSON

RandomBlockHeaderJSON returns a valid BlockHeaderJSON of the given kind block.

func (BlockHeaderJSON) ToBlockHeader

func (header BlockHeaderJSON) ToBlockHeader() block.Header

ToBlockHeader converts the BlockHeaderJSON object to a block.Header.

type BlockJSON

type BlockJSON struct {
	Hash      id.Hash      `json:"hash"`
	Header    block.Header `json:"header"`
	Txs       block.Txs    `json:"txs"`
	Plan      block.Plan   `json:"plan"`
	PrevState block.State  `json:"prevState"`
}

BlockHeaderJSON is almost a copy of the block.Header struct except all fields are exposed. This is for the convenience of initializing and marshaling.

type MockBlockchain

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

func NewMockBlockchain

func NewMockBlockchain(signatories id.Signatories) *MockBlockchain

func (*MockBlockchain) BlockAtHeight

func (bc *MockBlockchain) BlockAtHeight(height block.Height) (block.Block, bool)

func (*MockBlockchain) BlockExistsAtHeight

func (bc *MockBlockchain) BlockExistsAtHeight(height block.Height) bool

func (*MockBlockchain) InsertBlockAtHeight

func (bc *MockBlockchain) InsertBlockAtHeight(height block.Height, block block.Block)

func (*MockBlockchain) InsertBlockStateAtHeight added in v0.4.2

func (bc *MockBlockchain) InsertBlockStateAtHeight(height block.Height, state block.State)

func (*MockBlockchain) LatestBlock

func (bc *MockBlockchain) LatestBlock(kind block.Kind) block.Block

func (*MockBlockchain) StateAtHeight

func (bc *MockBlockchain) StateAtHeight(height block.Height) (block.State, bool)

type MockBroadcaster

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

func (*MockBroadcaster) Broadcast

func (m *MockBroadcaster) Broadcast(message process.Message)

func (*MockBroadcaster) Cast added in v0.4.2

func (m *MockBroadcaster) Cast(to id.Signatory, message process.Message)

type MockObserver

type MockObserver struct {
}

func (MockObserver) DidCommitBlock

func (m MockObserver) DidCommitBlock(block.Height)

func (MockObserver) DidReceiveSufficientNilPrevotes added in v0.3.2

func (m MockObserver) DidReceiveSufficientNilPrevotes(process.Messages, int)

type MockProposer

type MockProposer struct {
	Key *ecdsa.PrivateKey
}

func (*MockProposer) BlockProposal

func (m *MockProposer) BlockProposal(height block.Height, round block.Round) block.Block

type MockSaveRestorer added in v0.4.2

type MockSaveRestorer struct {
}

func (*MockSaveRestorer) Restore added in v0.4.2

func (m *MockSaveRestorer) Restore(state *process.State)

func (*MockSaveRestorer) Save added in v0.4.2

func (m *MockSaveRestorer) Save(state *process.State)

type MockScheduler

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

func (*MockScheduler) Schedule

type MockTimer

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

func (*MockTimer) Timeout

func (timer *MockTimer) Timeout(step process.Step, round block.Round) time.Duration

type MockValidator

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

func (MockValidator) IsBlockValid

func (m MockValidator) IsBlockValid(block.Block, bool) (process.NilReasons, error)

type ProcessOrigin

type ProcessOrigin struct {
	PrivateKey        *ecdsa.PrivateKey
	Signatory         id.Signatory
	Blockchain        process.Blockchain
	State             process.State
	BroadcastMessages chan process.Message
	CastMessages      chan process.Message

	SaveRestorer process.SaveRestorer
	Proposer     process.Proposer
	Validator    process.Validator
	Scheduler    process.Scheduler
	Broadcaster  process.Broadcaster
	Timer        process.Timer
	Observer     process.Observer
}

func NewProcessOrigin

func NewProcessOrigin(f int) ProcessOrigin

func (ProcessOrigin) ToProcess

func (p ProcessOrigin) ToProcess() *process.Process

func (*ProcessOrigin) UpdateState added in v0.4.2

func (p *ProcessOrigin) UpdateState(state process.State)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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