use reth_primitives::{
keccak256, trie::AccountProof, Account, Address, BlockNumber, Bytecode, Bytes, StorageKey,
B256, U256,
};
use reth_storage_api::{AccountReader, BlockHashReader, StateProvider, StateRootProvider};
use reth_storage_errors::provider::ProviderResult;
use reth_trie::updates::TrieUpdates;
use revm::db::BundleState;
use std::collections::HashMap;
/// Mock state for testing
#[derive(Debug, Default, Clone, Eq, PartialEq)]
pub struct StateProviderTest {
accounts: HashMap
, Account)>,
contracts: HashMap,
block_hash: HashMap,
}
impl StateProviderTest {
/// Insert account.
pub fn insert_account(
&mut self,
address: Address,
mut account: Account,
bytecode: Option,
storage: HashMap,
) {
if let Some(bytecode) = bytecode {
let hash = keccak256(&bytecode);
account.bytecode_hash = Some(hash);
self.contracts.insert(hash, Bytecode::new_raw(bytecode));
}
self.accounts.insert(address, (storage, account));
}
/// Insert a block hash.
pub fn insert_block_hash(&mut self, block_number: u64, block_hash: B256) {
self.block_hash.insert(block_number, block_hash);
}
}
impl AccountReader for StateProviderTest {
fn basic_account(&self, address: Address) -> ProviderResult