mock

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJournal added in v1.0.0

func NewJournal() *journal

newJournal create a new initialized journal.

Types

type ActiveVersionValue added in v1.1.0

type ActiveVersionValue struct {
	ActiveVersion uint32 `json:"ActiveVersion"`
	ActiveBlock   uint64 `json:"ActiveBlock"`
}

type Chain added in v0.7.4

type Chain struct {
	Genesis *types.Block

	StateDB *MockStateDB
	SnapDB  snapshotdb.DB
	// contains filtered or unexported fields
}

func NewChain

func NewChain() *Chain

func (*Chain) AddBlock added in v0.7.4

func (c *Chain) AddBlock()

notic AddBlock will not append snapshotdb

func (*Chain) AddBlockWithSnapDB added in v0.7.6

func (c *Chain) AddBlockWithSnapDB(miner bool, beforeTxHook, afterTxHook func(hash common.Hash, header *types.Header, sdb snapshotdb.DB) error, txs []Transaction) error

func (*Chain) AddBlockWithTx added in v1.3.2

func (c *Chain) AddBlockWithTx(txs []*types.Transaction)

func (*Chain) AddBlockWithTxHash added in v0.7.4

func (c *Chain) AddBlockWithTxHash(txHash common.Hash)

func (*Chain) AddBlockWithTxHashAndCommit added in v0.7.6

func (c *Chain) AddBlockWithTxHashAndCommit(txHash common.Hash, miner bool, f func(hash common.Hash, header *types.Header, sdb snapshotdb.DB) error) error

func (*Chain) CurrentBlock added in v1.3.2

func (c *Chain) CurrentBlock() *types.Block

func (*Chain) CurrentForkHeader added in v0.7.4

func (c *Chain) CurrentForkHeader() *types.Header

func (*Chain) CurrentHeader added in v0.7.4

func (c *Chain) CurrentHeader() *types.Header

func (*Chain) GetBlockByNumber added in v1.3.2

func (c *Chain) GetBlockByNumber(number uint64) *types.Block

func (*Chain) GetHeaderByHash added in v0.7.4

func (c *Chain) GetHeaderByHash(hash common.Hash) *types.Header

func (*Chain) GetHeaderByNumber added in v0.7.5

func (c *Chain) GetHeaderByNumber(number uint64) *types.Header

func (*Chain) SetCoinbaseGenerate added in v0.7.6

func (c *Chain) SetCoinbaseGenerate(f func() common.Address)

func (*Chain) SetHeaderTimeGenerate added in v0.7.5

func (c *Chain) SetHeaderTimeGenerate(f func(uint64) uint64)

type MockStateDB

type MockStateDB struct {
	Code     map[common.Address][]byte
	CodeHash map[common.Address][]byte
	Nonce    map[common.Address]uint64
	Suicided map[common.Address]bool

	Balance      map[common.Address]*big.Int
	State        map[common.Address]map[string][]byte
	Thash, Bhash common.Hash
	TxIndex      int

	Logs    map[common.Hash][]*types.Log
	Journal *journal
	// contains filtered or unexported fields
}

func NewMockStateDB added in v0.7.6

func NewMockStateDB() *MockStateDB

func (*MockStateDB) AddAddressToAccessList added in v1.3.2

func (s *MockStateDB) AddAddressToAccessList(common.Address)

func (*MockStateDB) AddBalance

func (s *MockStateDB) AddBalance(adr common.Address, amount *big.Int)

func (*MockStateDB) AddLog

func (s *MockStateDB) AddLog(logInfo *types.Log)

func (*MockStateDB) AddPreimage

func (s *MockStateDB) AddPreimage(common.Hash, []byte)

func (*MockStateDB) AddRefund

func (s *MockStateDB) AddRefund(uint64)

func (*MockStateDB) AddSlotToAccessList added in v1.3.2

func (s *MockStateDB) AddSlotToAccessList(common.Address, common.Hash)

func (*MockStateDB) AddressInAccessList added in v1.3.2

func (s *MockStateDB) AddressInAccessList(addr common.Address) bool

func (*MockStateDB) CreateAccount

func (s *MockStateDB) CreateAccount(addr common.Address)

func (*MockStateDB) DeepCopy added in v1.0.0

func (lhs *MockStateDB) DeepCopy(rhs *MockStateDB)

func (*MockStateDB) Empty

func (s *MockStateDB) Empty(common.Address) bool

Empty returns whether the given account is empty. Empty is defined according to EIP161 (balance = nonce = code = 0).

func (*MockStateDB) Equal added in v1.0.0

func (s *MockStateDB) Equal(other *MockStateDB) bool

func (*MockStateDB) Exist

func (s *MockStateDB) Exist(common.Address) bool

Exist reports whether the given account exists in state. Notably this should also return true for suicided accounts.

func (*MockStateDB) ForEachStorage

func (s *MockStateDB) ForEachStorage(addr common.Address, fn func([]byte, []byte) bool)

func (*MockStateDB) GetBalance

func (s *MockStateDB) GetBalance(adr common.Address) *big.Int

func (*MockStateDB) GetCode

func (s *MockStateDB) GetCode(addr common.Address) []byte

func (*MockStateDB) GetCodeHash

func (s *MockStateDB) GetCodeHash(addr common.Address) common.Hash

func (*MockStateDB) GetCodeSize

func (s *MockStateDB) GetCodeSize(addr common.Address) int

func (*MockStateDB) GetCommittedState

func (s *MockStateDB) GetCommittedState(common.Address, []byte) []byte

func (*MockStateDB) GetCurrentActiveVersion added in v1.1.0

func (state *MockStateDB) GetCurrentActiveVersion() uint32

func (*MockStateDB) GetLogs added in v1.0.0

func (s *MockStateDB) GetLogs(hash common.Hash) []*types.Log

func (*MockStateDB) GetNonce

func (s *MockStateDB) GetNonce(addr common.Address) uint64

func (*MockStateDB) GetRefund

func (s *MockStateDB) GetRefund() uint64

func (*MockStateDB) GetState

func (s *MockStateDB) GetState(adr common.Address, key []byte) []byte

func (*MockStateDB) HasSuicided

func (s *MockStateDB) HasSuicided(addr common.Address) bool

func (*MockStateDB) IntermediateRoot

func (s *MockStateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash

func (*MockStateDB) MigrateStorage added in v1.0.0

func (s *MockStateDB) MigrateStorage(from, to common.Address)

func (*MockStateDB) Prepare

func (s *MockStateDB) Prepare(thash, bhash common.Hash, ti int)

func (*MockStateDB) PrepareAccessList added in v1.4.1

func (s *MockStateDB) PrepareAccessList(common.Address, *common.Address, []common.Address, types.AccessList)

func (*MockStateDB) RevertToSnapshot

func (s *MockStateDB) RevertToSnapshot(snapshot int)

func (*MockStateDB) SetCode

func (s *MockStateDB) SetCode(addr common.Address, code []byte)

func (*MockStateDB) SetNonce

func (s *MockStateDB) SetNonce(addr common.Address, nonce uint64)

func (*MockStateDB) SetState

func (s *MockStateDB) SetState(adr common.Address, key, val []byte)

func (*MockStateDB) SlotInAccessList added in v1.3.2

func (s *MockStateDB) SlotInAccessList(addr common.Address, slot common.Hash) (addressPresent bool, slotPresent bool)

func (*MockStateDB) Snapshot

func (s *MockStateDB) Snapshot() int

func (*MockStateDB) SubBalance

func (s *MockStateDB) SubBalance(adr common.Address, amount *big.Int)

func (*MockStateDB) SubRefund

func (s *MockStateDB) SubRefund(uint64)

func (*MockStateDB) Suicide

func (s *MockStateDB) Suicide(addr common.Address) bool

func (*MockStateDB) TxHash

func (s *MockStateDB) TxHash() common.Hash

func (*MockStateDB) TxIdx

func (s *MockStateDB) TxIdx() uint32

type Transaction added in v1.0.0

type Transaction func(blockHash common.Hash, header *types.Header, statedb *MockStateDB, sdb snapshotdb.DB) error

func (*Transaction) Hash added in v1.0.0

func (T *Transaction) Hash() (h common.Hash)

Jump to

Keyboard shortcuts

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