consensus_mock

package
v0.0.0-...-8d456d7 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockBlockchainStore

type MockBlockchainStore struct {
	mock.MockBlockchainStore
	// contains filtered or unexported fields
}

func NewMockMockBlockchainStore

func NewMockMockBlockchainStore(gensis *commonPb.Block, cf *chainconf.ChainConf) *MockBlockchainStore

func (*MockBlockchainStore) ArchiveBlock

func (bs *MockBlockchainStore) ArchiveBlock(archiveHeight uint64) error

func (*MockBlockchainStore) GetArchivedPivot

func (bs *MockBlockchainStore) GetArchivedPivot() uint64

func (*MockBlockchainStore) GetBlockAt

func (bs *MockBlockchainStore) GetBlockAt(height uint64) (*commonPb.Block, error)

func (*MockBlockchainStore) GetBlockHeaderByHeight

func (bs *MockBlockchainStore) GetBlockHeaderByHeight(height uint64) (*commonPb.BlockHeader, error)

func (*MockBlockchainStore) GetHeightByHash

func (bs *MockBlockchainStore) GetHeightByHash(blockHash []byte) (uint64, error)

func (*MockBlockchainStore) GetLastBlock

func (bs *MockBlockchainStore) GetLastBlock() (*commonPb.Block, error)

func (*MockBlockchainStore) GetTxHeight

func (bs *MockBlockchainStore) GetTxHeight(txId string) (uint64, error)

func (*MockBlockchainStore) ReadObject

func (bs *MockBlockchainStore) ReadObject(contractName string, key []byte) ([]byte, error)

func (*MockBlockchainStore) RestoreBlocks

func (bs *MockBlockchainStore) RestoreBlocks(serializedBlocks [][]byte) error

func (*MockBlockchainStore) SaveBlock

func (bs *MockBlockchainStore) SaveBlock(block *commonPb.Block) error

func (*MockBlockchainStore) WriteObject

func (bs *MockBlockchainStore) WriteObject(contractName string, object []byte) error

type MockCommitter

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

func NewMockCommitter

func NewMockCommitter(ledgerCache protocol.LedgerCache,
	store *MockBlockchainStore,
	msgbus msgbus.MessageBus,
	log *logger.CMLogger,
	commitEventC chan uint64) *MockCommitter

func (*MockCommitter) AddBlock

func (cm *MockCommitter) AddBlock(block *commonPb.Block) error

type MockCoreEngine

type MockCoreEngine struct {
	sync.Mutex
	msgbus.DefaultSubscriber

	Proposer  *MockProposer
	Verifer   *MockVerifier
	Committer *MockCommitter

	Ledger protocol.LedgerCache
	// contains filtered or unexported fields
}

func NewMockCoreEngine

func NewMockCoreEngine(t *testing.T, id string,
	chainid string,
	mb msgbus.MessageBus,
	ledger protocol.LedgerCache,
	store *MockBlockchainStore,
	iscreate bool) *MockCoreEngine

func (*MockCoreEngine) GetHeight

func (ce *MockCoreEngine) GetHeight() uint64

func (*MockCoreEngine) GetID

func (ce *MockCoreEngine) GetID() string

func (*MockCoreEngine) Loop

func (ce *MockCoreEngine) Loop()

func (*MockCoreEngine) OnMessage

func (ce *MockCoreEngine) OnMessage(msg *msgbus.Message)

func (*MockCoreEngine) String

func (ce *MockCoreEngine) String() string

func (*MockCoreEngine) ToStringWithoutLock

func (ce *MockCoreEngine) ToStringWithoutLock() string

type MockLedger

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

func NewLedger

func NewLedger(chainid string, block *commonPb.Block) *MockLedger

func (*MockLedger) CurrentHeight

func (l *MockLedger) CurrentHeight() (uint64, error)

func (*MockLedger) GetLastCommittedBlock

func (l *MockLedger) GetLastCommittedBlock() *commonPb.Block

func (*MockLedger) SetLastCommittedBlock

func (l *MockLedger) SetLastCommittedBlock(block *commonPb.Block)

func (*MockLedger) SetLastProposedBlock

func (l *MockLedger) SetLastProposedBlock(block *commonPb.Block)

type MockNet

type MockNet struct {
	msgbus.DefaultSubscriber
	// contains filtered or unexported fields
}

func NewMockNet

func NewMockNet(id string, buses map[string]msgbus.MessageBus) *MockNet

func (*MockNet) OnMessage

func (net *MockNet) OnMessage(msg *msgbus.Message)

type MockProposer

type MockProposer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewMockProposer

func NewMockProposer(chainid string,
	id string,

	ledgerCache protocol.LedgerCache,
	msgbus msgbus.MessageBus, log *logger.CMLogger) *MockProposer

func (*MockProposer) ClearProposedBlockAt

func (p *MockProposer) ClearProposedBlockAt(height uint64)

func (*MockProposer) ClearTheBlock

func (p *MockProposer) ClearTheBlock(block *commonPb.Block)

func (*MockProposer) CreateBlock

func (b *MockProposer) CreateBlock(height uint64, perHash []byte) *commonPb.Block

func (*MockProposer) DiscardAboveHeight

func (p *MockProposer) DiscardAboveHeight(baseHeight int64) []*commonPb.Block

func (*MockProposer) GetProposedBlock

func (p *MockProposer) GetProposedBlock(b *commonPb.Block) (*commonPb.Block, map[string]*commonPb.TxRWSet)

func (*MockProposer) GetProposedBlockByHashAndHeight

func (p *MockProposer) GetProposedBlockByHashAndHeight(hash []byte, height uint64) (*commonPb.Block, map[string]*commonPb.TxRWSet)

func (*MockProposer) GetProposedBlocksAt

func (p *MockProposer) GetProposedBlocksAt(height uint64) []*commonPb.Block

func (*MockProposer) GetSelfProposedBlockAt

func (p *MockProposer) GetSelfProposedBlockAt(height uint64) *commonPb.Block

func (*MockProposer) HasProposedBlockAt

func (p *MockProposer) HasProposedBlockAt(height uint64) bool

func (*MockProposer) IsProposedAt

func (p *MockProposer) IsProposedAt(height uint64) bool

func (*MockProposer) KeepProposedBlock

func (p *MockProposer) KeepProposedBlock(hash []byte, height uint64) []*commonPb.Block

func (*MockProposer) ResetProposedAt

func (p *MockProposer) ResetProposedAt(height uint64)

func (*MockProposer) SetProposedAt

func (p *MockProposer) SetProposedAt(height uint64)

func (*MockProposer) SetProposedBlock

func (p *MockProposer) SetProposedBlock(b *commonPb.Block, rwSetMap map[string]*commonPb.TxRWSet, selfProposed bool) error

type MockProtocolNetService

type MockProtocolNetService struct {
	mock.MockNetService
	// contains filtered or unexported fields
}

func NewMockProtocolNetService

func NewMockProtocolNetService(nodeids map[string]string) *MockProtocolNetService

func (*MockProtocolNetService) AppendNodeID

func (ns *MockProtocolNetService) AppendNodeID(certid string, nodeid string) error

func (*MockProtocolNetService) GetNodeUidByCertId

func (ns *MockProtocolNetService) GetNodeUidByCertId(certid string) (string, error)

type MockVerifier

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

func NewMockVerifier

func NewMockVerifier(ledgerCache protocol.LedgerCache, msgBus msgbus.MessageBus, log *logger.CMLogger) *MockVerifier

func (*MockVerifier) GetLastProposedBlock

func (v *MockVerifier) GetLastProposedBlock(block *commonPb.Block) (*commonPb.Block, map[string]*commonPb.TxRWSet)

func (*MockVerifier) VerifyBlock

func (v *MockVerifier) VerifyBlock(block *commonPb.Block, mode protocol.VerifyMode) error

Jump to

Keyboard shortcuts

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