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

[wip] feat(anvil): migrate tests to alloy #6960

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
use sol erc721/multicall for calls
  • Loading branch information
Evalir committed Feb 12, 2024
commit 2fd9045be73a8db925673b062f72973d3b9390da
29 changes: 9 additions & 20 deletions crates/anvil/tests/it/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,19 @@ async fn can_call_on_pending_block() {
for block_number in 1..(api.block_number().unwrap().to::<usize>() + 1) {
let block_number = alloy_rpc_types::BlockNumberOrTag::Number(block_number as u64);
let block = api.block_by_number(block_number).await.unwrap().unwrap();
let multicall = Multicall::new(pending_contract.address().to_alloy(), alloy_provider.clone());

let block_timestamp = multicall
.getCurrentBlockTimestamp()
.block(block_number.into())
.call()
.await
.unwrap();
let multicall =
Multicall::new(pending_contract.address().to_alloy(), alloy_provider.clone());

let block_timestamp =
multicall.getCurrentBlockTimestamp().block(block_number.into()).call().await.unwrap();
assert_eq!(block.header.timestamp, block_timestamp.timestamp);

let block_gas_limit = multicall
.getCurrentBlockGasLimit()
.block(block_number.into())
.call()
.await
.unwrap();
let block_gas_limit =
multicall.getCurrentBlockGasLimit().block(block_number.into()).call().await.unwrap();
assert_eq!(block.header.gas_limit, block_gas_limit.gaslimit);

let block_coinbase = multicall
.getCurrentBlockCoinbase()
.block(block_number.into())
.call()
.await
.unwrap();
let block_coinbase =
multicall.getCurrentBlockCoinbase().block(block_number.into()).call().await.unwrap();
assert_eq!(block.header.miner, block_coinbase.coinbase);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/tests/it/fork.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! various fork related test

use crate::{
abi::{Greeter, Erc721, SolGreeter, ERC721},
abi::{Erc721, Greeter, SolGreeter, ERC721},
utils::{self, ethers_http_provider},
};
use alloy_primitives::{Address as rAddress, U256 as rU256};
Expand Down