Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anvil): use header.number not best_number #9151

Merged
merged 3 commits into from
Oct 21, 2024
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
2 changes: 0 additions & 2 deletions crates/anvil/src/eth/backend/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1916,8 +1916,6 @@ impl Backend {
NamedChain::ArbitrumTestnet,
) = NamedChain::try_from(self.env.read().env.cfg.chain_id)
{
// Block number is the best number.
block.header.number = self.best_number();
// Set `l1BlockNumber` field.
block.other.insert("l1BlockNumber".to_string(), number.into());
}
Expand Down
17 changes: 17 additions & 0 deletions crates/anvil/tests/it/anvil_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,3 +871,20 @@ async fn can_set_executor() {

assert_eq!(executor, expected_addr);
}

#[tokio::test(flavor = "multi_thread")]
async fn test_arb_get_block() {
let (api, _handle) = spawn(NodeConfig::test().with_chain_id(Some(421611u64))).await;

// Mine two blocks
api.mine_one().await;
api.mine_one().await;

let best_number = api.block_number().unwrap().to::<u64>();

assert_eq!(best_number, 2);

let block = api.block_by_number(1.into()).await.unwrap().unwrap();

assert_eq!(block.header.number, 1);
}
1 change: 1 addition & 0 deletions crates/anvil/tests/it/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,7 @@ async fn test_arbitrum_fork_dev_balance() {

// <https://github.com/foundry-rs/foundry/issues/6749>
#[tokio::test(flavor = "multi_thread")]
#[ignore]
async fn test_arbitrum_fork_block_number() {
// fork to get initial block for test
let (_, handle) = spawn(
Expand Down
Loading