appmock

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	// UnmarshalTx allows a transaction to be unmarshalled into a transaction
	// interface for use by the consensus algorithm
	UnmarshalTx(txb []byte) (interfaces.Transaction, error)
	// IsValid returns true if the list of transactions is a valid transformation
	// and false if the list is not valid. If an error is returned, it indicates
	// a low level failure that should stop the main loop.
	IsValid(txn *badger.Txn, chainID uint32, height uint32, stateHash []byte, tx []interfaces.Transaction) (bool, error)
	// GetValidProposal is a function that returns a list of transactions
	// that will cause a valid state transition function for the local node's
	// current state. This is the function used to create a new proposal.
	// comes from application logic
	GetValidProposal(txn *badger.Txn, chainID, height, maxBytes uint32) ([]interfaces.Transaction, []byte, error)
	// ApplyState is a function that returns a list of transactions
	// that will cause a valid state transition function for the local node's
	// current state. This is the function used to create a new proposal.
	// comes from application logic
	ApplyState(txn *badger.Txn, chainID uint32, height uint32, txs []interfaces.Transaction) (stateHash []byte, err error)
	// PendingTxAdd adds a transaction to the txPool and cleans up any stale
	// tx as a result.
	PendingTxAdd(txn *badger.Txn, chainID uint32, height uint32, txs []interfaces.Transaction) error
	// MinedTxGet returns a list of mined transactions and a list of missing
	// transaction hashes for mined transactions
	MinedTxGet(txn *badger.Txn, txHash [][]byte) ([]interfaces.Transaction, [][]byte, error)
	// PendingTxGet returns a list of transactions and a list of missing
	// transaction hashes from the pending transaction pool
	PendingTxGet(txn *badger.Txn, height uint32, txHashes [][]byte) ([]interfaces.Transaction, [][]byte, error)
	// PendingTxContains returns a list of missing transaction hashes
	// from the pending tx pool
	PendingTxContains(txn *badger.Txn, height uint32, txHashes [][]byte) ([][]byte, error)
	// StoreSnapShotNodes stores a snapshot node into the state trie of the application
	StoreSnapShotNode(txn *badger.Txn, batch []byte, root []byte, layer int) ([][]byte, int, []trie.LeafNode, error)
	// GetSnapShotNode returns a snapshot node from the state trie to a peer
	GetSnapShotNode(txn *badger.Txn, height uint32, key []byte) ([]byte, error)
	// StoreSnapShotStateData stores a snapshot state element to the database
	StoreSnapShotStateData(txn *badger.Txn, key []byte, value []byte, data []byte) error
	// GetSnapShotStateData retrieves value corresponding to key from the State Data
	GetSnapShotStateData(txn *badger.Txn, key []byte) ([]byte, error)
	// FinalizeSnapShotRoot validates snapshot root and corresponding data
	FinalizeSnapShotRoot(txn *badger.Txn, root []byte, height uint32) error
	// BeginSnapShotSync deletes the entries of the database in preparation
	// for fast synchronization
	BeginSnapShotSync(txn *badger.Txn) error
	// FinalizeSync performs any final logic needed to terminate a fast sync
	FinalizeSync(txn *badger.Txn) error
}

Application ...

type MockApplication

type MockApplication struct {
	MissingTxn bool
	// contains filtered or unexported fields
}

MockApplication is the the receiver for TxHandler interface

func New

func New() *MockApplication

New returns a mocked Application

func (*MockApplication) ApplyState

func (m *MockApplication) ApplyState(*badger.Txn, uint32, uint32, []interfaces.Transaction) ([]byte, error)

ApplyState is defined on the interface object

func (*MockApplication) BeginSnapShotSync

func (m *MockApplication) BeginSnapShotSync(txn *badger.Txn) error

BeginSnapShotSync is defined on the interface object

func (*MockApplication) FinalizeSnapShotRoot

func (m *MockApplication) FinalizeSnapShotRoot(txn *badger.Txn, root []byte, height uint32) error

FinalizeSnapShotRoot is defined on the interface object

func (*MockApplication) FinalizeSync

func (m *MockApplication) FinalizeSync(txn *badger.Txn) error

FinalizeSync is defined on the interface object

func (*MockApplication) GetSnapShotNode

func (m *MockApplication) GetSnapShotNode(txn *badger.Txn, height uint32, key []byte) ([]byte, error)

GetSnapShotNode is defined on the interface object

func (*MockApplication) GetSnapShotStateData

func (m *MockApplication) GetSnapShotStateData(txn *badger.Txn, key []byte) ([]byte, error)

GetSnapShotStateData is defined on the interface object

func (*MockApplication) GetValidProposal

func (m *MockApplication) GetValidProposal(txn *badger.Txn, chainID, height, maxBytes uint32) ([]interfaces.Transaction, []byte, error)

GetValidProposal is defined on the interface object

func (*MockApplication) IsValid

func (m *MockApplication) IsValid(txn *badger.Txn, chainID uint32, height uint32, stateHash []byte, _ []interfaces.Transaction) (bool, error)

IsValid is defined on the interface object

func (*MockApplication) MinedTxGet

func (m *MockApplication) MinedTxGet(*badger.Txn, [][]byte) ([]interfaces.Transaction, [][]byte, error)

MinedTxGet is defined on the interface object

func (*MockApplication) PendingTxAdd

func (m *MockApplication) PendingTxAdd(*badger.Txn, uint32, uint32, []interfaces.Transaction) error

PendingTxAdd is defined on the interface object

func (*MockApplication) PendingTxContains

func (m *MockApplication) PendingTxContains(txn *badger.Txn, height uint32, txHashes [][]byte) ([][]byte, error)

PendingTxContains is defined on the interface object

func (*MockApplication) PendingTxGet

func (m *MockApplication) PendingTxGet(txn *badger.Txn, height uint32, txhashes [][]byte) ([]interfaces.Transaction, [][]byte, error)

PendingTxGet is defined on the interface object

func (*MockApplication) SetNextValidValue

func (m *MockApplication) SetNextValidValue(vv *objs.Proposal)

SetNextValidValue is defined on the interface object

func (*MockApplication) StoreSnapShotNode

func (m *MockApplication) StoreSnapShotNode(txn *badger.Txn, batch []byte, root []byte, layer int) ([][]byte, int, []trie.LeafNode, error)

StoreSnapShotNode is defined on the interface object

func (*MockApplication) StoreSnapShotStateData

func (m *MockApplication) StoreSnapShotStateData(txn *badger.Txn, key []byte, value []byte, data []byte) error

StoreSnapShotStateData is defined on the interface object

func (*MockApplication) UnmarshalTx

func (m *MockApplication) UnmarshalTx(v []byte) (interfaces.Transaction, error)

UnmarshalTx is defined on the interface object

type MockTransaction

type MockTransaction struct {
	V []byte
}

MockTransaction is defined on the interface object

func (*MockTransaction) MarshalBinary

func (m *MockTransaction) MarshalBinary() ([]byte, error)

MarshalBinary is defined on the interface object

func (*MockTransaction) TxHash

func (m *MockTransaction) TxHash() ([]byte, error)

TxHash is defined on the interface object

func (*MockTransaction) XXXIsTx

func (m *MockTransaction) XXXIsTx()

XXXIsTx is defined on the interface object

Jump to

Keyboard shortcuts

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