# Struct ethcore::client::TestBlockChainClient [−] [src]

    pub struct TestBlockChainClient {
        pub blocks: RwLock<HashMap<H256, Bytes>>,
        pub numbers: RwLock<HashMap<usize, H256>>,
        pub genesis_hash: H256,
        pub last_hash: RwLock<H256>,
        pub extra_data: Bytes,
        pub difficulty: RwLock<U256>,
        pub balances: RwLock<HashMap<Address, U256>>,
        pub nonces: RwLock<HashMap<Address, U256>>,
        pub storage: RwLock<HashMap<(Address, H256), H256>>,
        pub code: RwLock<HashMap<Address, Bytes>>,
        pub execution_result: RwLock<Option<Result<Executed, CallError>>>,
        pub receipts: RwLock<HashMap<TransactionId, LocalizedReceipt>>,
        pub logs: RwLock<Vec<LocalizedLogEntry>>,
        pub queue_size: AtomicUsize,
        pub miner: Arc<Miner>,
        pub spec: Spec,
        pub vm_factory: EvmFactory,
        pub latest_block_timestamp: RwLock<u64>,
        pub ancient_block: RwLock<Option<(H256, u64)>>,
        pub first_block: RwLock<Option<(H256, u64)>>,
        pub traces: RwLock<Option<Vec<LocalizedTrace>>>,
        pub history: RwLock<Option<u64>>,
    }

Test client.

## Fields

`blocks: RwLock<HashMap<H256, Bytes>>`

Blocks.

`numbers: RwLock<HashMap<usize, H256>>`

Mapping of numbers to hashes.

`genesis_hash: H256`

Genesis block hash.

`last_hash: RwLock<H256>`

Last block hash.

`extra_data: Bytes`

Extra data do set for each block

`difficulty: RwLock<U256>`

Difficulty.

`balances: RwLock<HashMap<Address, U256>>`

Balances.

`nonces: RwLock<HashMap<Address, U256>>`

Nonces.

`storage: RwLock<HashMap<(Address, H256), H256>>`

Storage.

`code: RwLock<HashMap<Address, Bytes>>`

Code.

`execution_result: RwLock<Option<Result<Executed, CallError>>>`

Execution result.

`receipts: RwLock<HashMap<TransactionId, LocalizedReceipt>>`

Transaction receipts.

`logs: RwLock<Vec<LocalizedLogEntry>>`

Logs

`queue_size: AtomicUsize`

Block queue size.

`miner: Arc<Miner>`

Miner

`spec: Spec`

Spec

`vm_factory: EvmFactory`

VM Factory

`latest_block_timestamp: RwLock<u64>`

Timestamp assigned to latest sealed block

`ancient_block: RwLock<Option<(H256, u64)>>`

Ancient block info.

`first_block: RwLock<Option<(H256, u64)>>`

First block info.

`traces: RwLock<Option<Vec<LocalizedTrace>>>`

Traces to return

`history: RwLock<Option<u64>>`

Pruning history size to report.

## Methods

### `impl TestBlockChainClient`
[src]

#### `fn new() -> Self`

Creates new test client.

#### `fn new_with_extra_data(extra_data: Bytes) -> Self`

Creates new test client with specified extra data for each block

#### `fn new_with_spec(spec: Spec) -> Self`

Create test client with custom spec.

#### `fn new_with_spec_and_extra(spec: Spec, extra_data: Bytes) -> Self`

Create test client with custom spec and extra data.

#### `fn set_transaction_receipt(&self, id: TransactionId, receipt: LocalizedReceipt)`

Set the transaction receipt result

#### `fn set_execution_result(&self, result: Result<Executed, CallError>)`

Set the execution result.

#### `fn set_balance(&self, address: Address, balance: U256)`

Set the balance of account `address` to `balance`.

#### `fn set_nonce(&self, address: Address, nonce: U256)`

Set nonce of account `address` to `nonce`.

#### `fn set_code(&self, address: Address, code: Bytes)`

Set `code` at `address`.

#### `fn set_storage(&self, address: Address, position: H256, value: H256)`

Set storage `position` to `value` for account `address`.

#### `fn set_queue_size(&self, size: usize)`

Set block queue size for testing

#### `fn set_latest_block_timestamp(&self, ts: u64)`

Set timestamp assigned to latest sealed block

#### `fn set_logs(&self, logs: Vec<LocalizedLogEntry>)`

Set logs to return for each logs call.

#### `fn add_blocks(&self, count: usize, with: EachBlockWith)`

Add blocks to test client.

#### `fn corrupt_block(&self, n: BlockNumber)`

Make a bad block by setting invalid extra data.

#### `fn corrupt_block_parent(&self, n: BlockNumber)`

Make a bad block by setting invalid parent hash.

#### `fn block_hash_delta_minus(&mut self, delta: usize) -> H256`

TODO:

#### `fn insert_transaction_with_gas_price_to_queue(&self, gas_price: U256) -> H256`

Inserts a transaction with given gas price to miners transactions queue.

#### `fn insert_transaction_to_queue(&self) -> H256`

Inserts a transaction to miners transactions queue.

#### `fn set_history(&self, h: Option<u64>)`

Set reported history size.

## Trait Implementations

### `impl Default for TestBlockChainClient`
[src]

#### `fn default() -> Self`

Returns the "default value" for a type. Read more

### `impl MiningBlockChainClient for TestBlockChainClient`
[src]

#### `fn latest_schedule(&self) -> Schedule`

Returns latest schedule.

#### `fn prepare_open_block(&self,
author: Address,
gas_range_target: (U256, U256),
extra_data: Bytes)
-> OpenBlock`

Returns OpenBlock prepared for closing.

#### `fn vm_factory(&self) -> &EvmFactory`

Returns EvmFactory.

#### `fn import_sealed_block(&self, _block: SealedBlock) -> ImportResult`

Import sealed block. Skips all verifications.

#### `fn broadcast_proposal_block(&self, _block: SealedBlock)`

Broadcast a block proposal.

### `impl BlockChainClient for TestBlockChainClient`
[src]

#### `fn call(&self,
_t: &SignedTransaction,
_block: BlockId,
_analytics: CallAnalytics)
-> Result<Executed, CallError>`

Makes a non-persistent transaction call.

#### `fn estimate_gas(&self,
_t: &SignedTransaction,
_block: BlockId)
-> Result<U256, CallError>`

Estimates how much gas will be necessary for a call.

#### `fn replay(&self,
_id: TransactionId,
_analytics: CallAnalytics)
-> Result<Executed, CallError>`

Replays a given transaction for inspection.

#### `fn block_total_difficulty(&self, _id: BlockId) -> Option<U256>`

Get block total difficulty.

#### `fn block_hash(&self, id: BlockId) -> Option<H256>`

Get block hash.

#### `fn nonce(&self, address: &Address, id: BlockId) -> Option<U256>`

Attempt to get address nonce at given block. May not fail on BlockId::Latest. Read more

#### `fn storage_root(&self, _address: &Address, _id: BlockId) -> Option<H256>`

Attempt to get address storage root at given block. May not fail on BlockId::Latest. Read more

#### `fn latest_nonce(&self, address: &Address) -> U256`

Get address nonce at the latest block's state.

#### `fn code(&self, address: &Address, id: BlockId) -> Option<Option<Bytes>>`

Get address code at given block's state.

#### `fn balance(&self, address: &Address, id: BlockId) -> Option<U256>`

Get address balance at the given block's state. Read more

#### `fn latest_balance(&self, address: &Address) -> U256`

Get address balance at the latest block's state.

#### `fn storage_at(&self,
address: &Address,
position: &H256,
id: BlockId)
-> Option<H256>`

Get value of the storage at given position at the given block's state. Read more

#### `fn list_accounts(&self,
_id: BlockId,
_after: Option<&Address>,
_count: u64)
-> Option<Vec<Address>>`

Get a list of all accounts in the block `id`, if fat DB is in operation, otherwise `None`. If `after` is set the list starts with the following item. Read more

#### `fn list_storage(&self,
_id: BlockId,
_account: &Address,
_after: Option<&H256>,
_count: u64)
-> Option<Vec<H256>>`

Get a list of all storage keys in the block `id`, if fat DB is in operation, otherwise `None`. If `after` is set the list starts with the following item. Read more

#### `fn transaction(&self, _id: TransactionId) -> Option<LocalizedTransaction>`

Get transaction with given hash.

#### `fn transaction_block(&self, _id: TransactionId) -> Option<H256>`

Get the hash of block that contains the transaction, if any.

#### `fn uncle(&self, _id: UncleId) -> Option<Header>`

Get uncle with given id.

#### `fn uncle_extra_info(&self, _id: UncleId) -> Option<BTreeMap<String, String>>`

Returns engine-related extra info for `UncleId`.

#### `fn transaction_receipt(&self, id: TransactionId) -> Option<LocalizedReceipt>`

Get transaction receipt with given hash.

#### `fn blocks_with_bloom(&self,
_bloom: &H2048,
_from_block: BlockId,
_to_block: BlockId)
-> Option<Vec<BlockNumber>>`

Returns numbers of blocks containing given bloom.

#### `fn logs(&self, filter: Filter) -> Vec<LocalizedLogEntry>`

Returns logs matching given filter.

#### `fn last_hashes(&self) -> LastHashes`

Get last hashes starting from best block.

#### `fn best_block_header(&self) -> Header`

Get the best block header.

#### `fn block_header(&self, id: BlockId) -> Option<Header>`

Get raw block header data by block id.

#### `fn block_number(&self, _id: BlockId) -> Option<BlockNumber>`

Look up the block number for the given block ID.

#### `fn block_body(&self, id: BlockId) -> Option<Body>`

Get raw block body data by block id. Block body is an RLP list of two items: uncles and transactions. Read more

#### `fn block(&self, id: BlockId) -> Option<Block>`

Get raw block data by block header hash.

#### `fn block_extra_info(&self, id: BlockId) -> Option<BTreeMap<String, String>>`

Returns engine-related extra info for `BlockId`.

#### `fn block_status(&self, id: BlockId) -> BlockStatus`

Get block status by block header hash.

#### `fn tree_route(&self, from: &H256, to: &H256) -> Option<TreeRoute>`

Get a tree route between `from` and `to`. See `BlockChain::tree_route`. Read more

#### `fn find_uncles(&self, _hash: &H256) -> Option<Vec<H256>>`

Get all possible uncle hashes for a block.

#### `fn state_data(&self, hash: &H256) -> Option<Bytes>`

Get latest state node

#### `fn block_receipts(&self, hash: &H256) -> Option<Bytes>`

Get raw block receipts data by block header hash.

#### `fn import_block(&self, b: Bytes) -> Result<H256, BlockImportError>`

Import a block into the blockchain.

#### `fn import_block_with_receipts(&self,
b: Bytes,
_r: Bytes)
-> Result<H256, BlockImportError>`

Import a block with transaction receipts. Does no sealing and transaction validation.

#### `fn queue_info(&self) -> QueueInfo`

Get block queue information.

#### `fn clear_queue(&self)`

Clear block queue and abort all import activity.

#### `fn additional_params(&self) -> BTreeMap<String, String>`

Get the registrar address, if it exists.

#### `fn chain_info(&self) -> BlockChainInfo`

Get blockchain information.

#### `fn filter_traces(&self, _filter: TraceFilter) -> Option<Vec<LocalizedTrace>>`

Returns traces matching given filter.

#### `fn trace(&self, _trace: TraceId) -> Option<LocalizedTrace>`

Returns trace with given id.

#### `fn transaction_traces(&self,
_trace: TransactionId)
-> Option<Vec<LocalizedTrace>>`

Returns traces created by transaction.

#### `fn block_traces(&self, _trace: BlockId) -> Option<Vec<LocalizedTrace>>`

Returns traces created by transaction from block.

#### `fn queue_transactions(&self, transactions: Vec<Bytes>, _peer_id: usize)`

Queue transactions for importing.

#### `fn queue_consensus_message(&self, message: Bytes)`

Queue conensus engine message.

#### `fn ready_transactions(&self) -> Vec<PendingTransaction>`

List all transactions that are allowed into the next block.

#### `fn signing_network_id(&self) -> Option<u64>`

Get the preferred network ID to sign on

#### `fn mode(&self) -> Mode`

Get the mode.

#### `fn set_mode(&self, _: Mode)`

Set the mode.

#### `fn disable(&self)`

Disable the client from importing blocks. This cannot be undone in this session and indicates that a subsystem has reason to believe this executable incapable of syncing the chain. Read more

#### `fn pruning_info(&self) -> PruningInfo`

Returns information about pruning/data availability.

#### `fn call_contract(&self,
_address: Address,
_data: Bytes)
-> Result<Bytes, String>`

Like `call`, but with various defaults. Designed to be used for calling contracts.

#### `fn transact_contract(&self,
address: Address,
data: Bytes)
-> Result<TransactionImportResult, EthcoreError>`

Import a transaction: used for misbehaviour reporting.

#### `fn registrar_address(&self) -> Option<Address>`

Get the address of the registry itself.

#### `fn registry_address(&self, _name: String) -> Option<Address>`

Get the address of a particular blockchain service, if available.

#### `fn keep_alive(&self)`

Should be called by any external-facing interface when actively using the client. To minimise chatter, there's no need to call more than once every 30s. Read more

#### `fn latest_code(&self, address: &Address) -> Option<Bytes>`

Get address code at the latest block's state.

#### `fn latest_storage_at(&self, address: &Address, position: &H256) -> H256`

Get value of the storage at given position at the latest block's state.

#### `fn gas_price_corpus(&self, sample_size: usize) -> Vec<U256>`

Sorted list of transaction gas prices from at least last sample_size blocks.

#### `fn gas_price_median(&self, sample_size: usize) -> Option<U256>`

Calculate median gas price from recent blocks if they have any transactions.

#### `fn gas_price_histogram(&self,
sample_size: usize,
bucket_number: usize)
-> Option<Histogram>`

Get the gas price distribution based on recent blocks if they have any transactions.

### `impl ProvingBlockChainClient for TestBlockChainClient`
[src]

#### `fn prove_storage(&self, _: H256, _: H256, _: u32, _: BlockId) -> Vec<Bytes>`

Prove account storage at a specific block id. Read more

#### `fn prove_account(&self, _: H256, _: u32, _: BlockId) -> Vec<Bytes>`

Prove account existence at a specific block id. The key is the keccak hash of the account's address. Returns a vector of raw trie nodes (in order from the root) proving the query. Nodes after `from_level` may be omitted. An empty vector indicates unservable query. Read more

#### `fn code_by_hash(&self, _: H256, _: BlockId) -> Bytes`

Get code by address hash.

### `impl EngineClient for TestBlockChainClient`
[src]

#### `fn update_sealing(&self)`

Make a new block and seal it.

#### `fn submit_seal(&self, block_hash: H256, seal: Vec<Bytes>)`

Submit a seal for a block in the mining queue.

#### `fn broadcast_consensus_message(&self, _message: Bytes)`

Broadcast a consensus message to the network.

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)