Documentation ¶
Index ¶
- 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) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (b *SimulatedBackend) Blockchain() *core.BlockChain
- func (b *SimulatedBackend) CallContract(ctx context.Context, call cpchain.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (b *SimulatedBackend) Campaign(ctx context.Context, terms uint64) error
- func (b *SimulatedBackend) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (b *SimulatedBackend) Commit()
- func (b *SimulatedBackend) EstimateGas(ctx context.Context, call cpchain.CallMsg) (uint64, error)
- func (b *SimulatedBackend) FilterLogs(ctx context.Context, query cpchain.FilterQuery) ([]types.Log, error)
- func (b *SimulatedBackend) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (b *SimulatedBackend) NonceAt(ctx context.Context, contract common.Address, blockNumber *big.Int) (uint64, error)
- func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call cpchain.CallMsg) ([]byte, 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) 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 cpchain.FilterQuery, ch chan<- types.Log) (cpchain.Subscription, error)
- func (b *SimulatedBackend) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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 easily testing contract bindings.
func NewDporSimulatedBackend ¶
func NewDporSimulatedBackend(alloc core.GenesisAlloc) *SimulatedBackend
NewDporSimulatedBackend creates a new binding backend using a simulated blockchain for testing purposes.
func NewDporSimulatedBackendWithExistsBlockchain ¶
func NewDporSimulatedBackendWithExistsBlockchain(db *database.MemDatabase, blockchain *core.BlockChain, config *configs.ChainConfig) *SimulatedBackend
NewDporSimulatedBackendWithExistsBlockchain creates a new binding backend with a exists blockchain for test purposes.
func (*SimulatedBackend) AdjustTime ¶
func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error
AdjustTime adds a time shift to the simulated clock.
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) BlockByNumber ¶
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 cpchain.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContract executes a contract call.
func (*SimulatedBackend) Campaign ¶
func (b *SimulatedBackend) Campaign(ctx context.Context, terms uint64) error
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) Commit ¶
func (b *SimulatedBackend) Commit()
Commit imports all the pending transactions as a single block and starts a fresh new state.
func (*SimulatedBackend) EstimateGas ¶
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 cpchain.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) HeaderByNumber ¶
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) PendingCallContract ¶
func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call cpchain.CallMsg) ([]byte, error)
PendingCallContract executes a contract call on the pending state.
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) 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. It panics if the transaction is invalid.
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 cpchain.FilterQuery, ch chan<- types.Log) (cpchain.Subscription, error)
SubscribeFilterLogs creates a background log filtering operation, returning a subscription immediately, which can be used to stream the found events.
func (*SimulatedBackend) SuggestGasPrice ¶
SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated chain doens't have miners, we just return a gas price of 1 for any call.
func (*SimulatedBackend) TransactionReceipt ¶
func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionReceipt returns the receipt of a transaction.