Documentation ¶
Index ¶
- Variables
- type SimulatedBackend
- func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error
- func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract common.Address, blockNumber *big.Int) (*big.Int, error)
- func (b *SimulatedBackend) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (b *SimulatedBackend) BlockChain() *core.BlockChain
- func (b *SimulatedBackend) BlockNumber(ctx context.Context) (uint64, error)
- func (b *SimulatedBackend) Blockchain() *core.BlockChain
- func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (b *SimulatedBackend) ChainDb() ethdb.Database
- func (b *SimulatedBackend) Close() error
- func (b *SimulatedBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (b *SimulatedBackend) CodeAtHash(ctx context.Context, contract common.Address, blockHash common.Hash) ([]byte, error)
- func (b *SimulatedBackend) Commit() common.Hash
- func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)
- func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
- func (b *SimulatedBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (b *SimulatedBackend) HeaderByNumber(ctx context.Context, block *big.Int) (*types.Header, error)
- func (b *SimulatedBackend) NonceAt(ctx context.Context, contract common.Address, blockNumber *big.Int) (uint64, error)
- func (b *SimulatedBackend) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
- func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
- func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (b *SimulatedBackend) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
- func (b *SimulatedBackend) PendingTransactionCount(ctx context.Context) (uint, error)
- func (b *SimulatedBackend) Rollback()
- func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Address, key common.Hash, ...) ([]byte, error)
- func (b *SimulatedBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (b *SimulatedBackend) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
- func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (b *SimulatedBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
- func (b *SimulatedBackend) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
- func (b *SimulatedBackend) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
- func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- type TickingSimulatedBackend
Constants ¶
This section is empty.
Variables ¶
var TickDepositorKeyHex = "6ad661dea8f20dff26c1529ec80eb479e16c39468dcacfe72d2a819ec59a4f25"
Functions ¶
This section is empty.
Types ¶
type SimulatedBackend ¶
type SimulatedBackend struct {
// contains filtered or unexported fields
}
SimulatedBackend implements bind.ContractBackend, simulating a blockchain in the background. Its main purpose is to allow for easy testing of contract bindings. Simulated backend implements the following interfaces: ChainReader, ChainStateReader, ContractBackend, ContractCaller, ContractFilterer, ContractTransactor, DeployBackend, GasEstimator, GasPricer, LogFilterer, PendingContractCaller, TransactionReader, and TransactionSender
func NewSimulatedBackend ¶
func NewSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64, concreteRegistry concrete.PrecompileRegistry) *SimulatedBackend
NewSimulatedBackend creates a new binding backend using a simulated blockchain for testing purposes. A simulated backend always uses chainID 1337.
func NewSimulatedBackendWithDatabase ¶
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc types.GenesisAlloc, gasLimit uint64, concreteRegistry concrete.PrecompileRegistry) *SimulatedBackend
NewSimulatedBackendWithDatabase creates a new binding backend based on the given database and uses a simulated blockchain for testing purposes. A simulated backend always uses chainID 1337.
func (*SimulatedBackend) AdjustTime ¶
func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error
AdjustTime adds a time shift to the simulated clock. It can only be called on empty blocks.
func (*SimulatedBackend) BalanceAt ¶
func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract common.Address, blockNumber *big.Int) (*big.Int, error)
BalanceAt returns the wei balance of a certain account in the blockchain.
func (*SimulatedBackend) BlockByHash ¶
BlockByHash retrieves a block based on the block hash.
func (*SimulatedBackend) BlockByNumber ¶
func (b *SimulatedBackend) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
BlockByNumber retrieves a block from the database by number, caching it (associated with its hash) if found.
func (*SimulatedBackend) BlockChain ¶
func (b *SimulatedBackend) BlockChain() *core.BlockChain
func (*SimulatedBackend) BlockNumber ¶
func (b *SimulatedBackend) BlockNumber(ctx context.Context) (uint64, error)
func (*SimulatedBackend) Blockchain ¶
func (b *SimulatedBackend) Blockchain() *core.BlockChain
Blockchain returns the underlying blockchain.
func (*SimulatedBackend) CallContract ¶
func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract executes a contract call.
func (*SimulatedBackend) ChainDb ¶
func (b *SimulatedBackend) ChainDb() ethdb.Database
func (*SimulatedBackend) Close ¶
func (b *SimulatedBackend) Close() error
Close terminates the underlying blockchain's update loop.
func (*SimulatedBackend) CodeAt ¶
func (b *SimulatedBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
CodeAt returns the code associated with a certain account in the blockchain.
func (*SimulatedBackend) CodeAtHash ¶
func (b *SimulatedBackend) CodeAtHash(ctx context.Context, contract common.Address, blockHash common.Hash) ([]byte, error)
CodeAtHash returns the code associated with a certain account in the blockchain.
func (*SimulatedBackend) Commit ¶
func (b *SimulatedBackend) Commit() common.Hash
Commit imports all the pending transactions as a single block and starts a fresh new state.
func (*SimulatedBackend) EstimateGas ¶
func (b *SimulatedBackend) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)
EstimateGas executes the requested code against the currently pending block/state and returns the used amount of gas.
func (*SimulatedBackend) FilterLogs ¶
func (b *SimulatedBackend) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
FilterLogs executes a log filter operation, blocking during execution and returning all the results in one batch.
TODO(karalabe): Deprecate when the subscription one can return past data too.
func (*SimulatedBackend) HeaderByHash ¶
func (b *SimulatedBackend) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
HeaderByHash returns a block header from the current canonical chain.
func (*SimulatedBackend) HeaderByNumber ¶
func (b *SimulatedBackend) HeaderByNumber(ctx context.Context, block *big.Int) (*types.Header, error)
HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.
func (*SimulatedBackend) NonceAt ¶
func (b *SimulatedBackend) NonceAt(ctx context.Context, contract common.Address, blockNumber *big.Int) (uint64, error)
NonceAt returns the nonce of a certain account in the blockchain.
func (*SimulatedBackend) PendingBalanceAt ¶
func (*SimulatedBackend) PendingCodeAt ¶
func (b *SimulatedBackend) PendingCodeAt(ctx context.Context, contract common.Address) ([]byte, error)
PendingCodeAt returns the code associated with an account in the pending state.
func (*SimulatedBackend) PendingNonceAt ¶
func (b *SimulatedBackend) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
PendingNonceAt implements PendingStateReader.PendingNonceAt, retrieving the nonce currently pending for the account.
func (*SimulatedBackend) PendingStorageAt ¶
func (*SimulatedBackend) PendingTransactionCount ¶
func (b *SimulatedBackend) PendingTransactionCount(ctx context.Context) (uint, error)
func (*SimulatedBackend) Rollback ¶
func (b *SimulatedBackend) Rollback()
Rollback aborts all pending transactions, reverting to the last committed state.
func (*SimulatedBackend) SendTransaction ¶
func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction updates the pending block to include the given transaction.
func (*SimulatedBackend) StorageAt ¶
func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
StorageAt returns the value of key in the storage of an account in the blockchain.
func (*SimulatedBackend) SubscribeFilterLogs ¶
func (b *SimulatedBackend) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs creates a background log filtering operation, returning a subscription immediately, which can be used to stream the found events.
func (*SimulatedBackend) SubscribeNewHead ¶
func (b *SimulatedBackend) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
SubscribeNewHead returns an event subscription for a new header.
func (*SimulatedBackend) SuggestGasPrice ¶
SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated chain doesn't have miners, we just return a gas price of 1 for any call.
func (*SimulatedBackend) SuggestGasTipCap ¶
SuggestGasTipCap implements ContractTransactor.SuggestGasTipCap. Since the simulated chain doesn't have miners, we just return a gas tip of 1 for any call.
func (*SimulatedBackend) TransactionByHash ¶
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error)
TransactionByHash checks the pool of pending transactions in addition to the blockchain. The isPending return value indicates whether the transaction has been mined yet. Note that the transaction may not be part of the canonical chain even if it's not pending.
func (*SimulatedBackend) TransactionCount ¶
func (b *SimulatedBackend) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
TransactionCount returns the number of transactions in a given block.
func (*SimulatedBackend) TransactionInBlock ¶
func (b *SimulatedBackend) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
TransactionInBlock returns the transaction for a specific block at a specific index.
func (*SimulatedBackend) TransactionReceipt ¶
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt returns the receipt of a transaction.
type TickingSimulatedBackend ¶
type TickingSimulatedBackend struct { *SimulatedBackend // contains filtered or unexported fields }
func NewTickingSimulatedBackend ¶
func NewTickingSimulatedBackend(alloc types.GenesisAlloc, gasLimit uint64, concreteRegistry concrete.PrecompileRegistry) *TickingSimulatedBackend
NewTickingSimulatedBackend creates a new simulated blockchain, pre-funded with the given accounts and with the given gas limit. It will automatically send a transaction to the tickTarget address every block once it is started.
func (*TickingSimulatedBackend) Commit ¶
func (tsb *TickingSimulatedBackend) Commit()
func (*TickingSimulatedBackend) SendTransaction ¶
func (tsb *TickingSimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*TickingSimulatedBackend) Start ¶
func (tsb *TickingSimulatedBackend) Start(blockTime time.Duration, tickTarget common.Address)
func (*TickingSimulatedBackend) Stop ¶
func (tsb *TickingSimulatedBackend) Stop()