Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ use anvil_rpc::{error::RpcError, response::ResponseResult};
use foundry_common::provider::ProviderBuilder;
use foundry_evm::decode::RevertDecoder;
use futures::{
StreamExt,
StreamExt, TryFutureExt,
channel::{mpsc::Receiver, oneshot},
};
use parking_lot::RwLock;
Expand Down Expand Up @@ -774,8 +774,8 @@ impl EthApi {
{
// if this predates the fork we need to fetch balance, nonce, code individually
// because the provider might not support this endpoint
let balance = self.balance(address, Some(number.into()));
let code = self.get_code(address, Some(number.into()));
let balance = fork.get_balance(address, number).map_err(BlockchainError::from);
let code = fork.get_code(address, number).map_err(BlockchainError::from);
let nonce = self.get_transaction_count(address, Some(number.into()));
let (balance, code, nonce) = try_join!(balance, code, nonce)?;

Expand Down
23 changes: 22 additions & 1 deletion crates/anvil/tests/it/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use alloy_network::{EthereumWallet, ReceiptResponse, TransactionBuilder, Transac
use alloy_primitives::{Address, Bytes, TxHash, TxKind, U64, U256, address, b256, bytes, uint};
use alloy_provider::Provider;
use alloy_rpc_types::{
BlockId, BlockNumberOrTag,
AccountInfo, BlockId, BlockNumberOrTag,
anvil::Forking,
request::{TransactionInput, TransactionRequest},
state::EvmOverrides,
Expand Down Expand Up @@ -1619,6 +1619,27 @@ async fn test_fork_get_account() {
assert_eq!(alice_acc_init, alice_acc_prev_block);
}

#[tokio::test(flavor = "multi_thread")]
async fn test_fork_get_account_info() {
let (_api, handle) = spawn(fork_config()).await;
let provider = handle.http_provider();

let info = provider
.get_account_info(address!("0x19e53a7397bE5AA7908fE9eA991B03710bdC74Fd"))
// predates fork
.number(BLOCK_NUMBER - 1)
.await
.unwrap();
assert_eq!(
info,
AccountInfo {
balance: U256::from(14353753764795095694u64),
nonce: 6689,
code: Default::default(),
}
);
}

fn assert_hardfork_config(
config: &EthConfig,
expected_blob_params: &BlobParams,
Expand Down
Loading