forked from risechain/pevm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmall_blocks.rs
66 lines (60 loc) · 1.9 KB
/
small_blocks.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Test small blocks that we have specific handling for, like implicit fine-tuning
// the concurrency level, falling back to sequential processing, etc.
use alloy_primitives::{Address, U256};
use alloy_rpc_types::{Block, BlockTransactions, Transaction};
use pevm::{chain::PevmEthereum, InMemoryStorage};
use revm::primitives::{TransactTo, TxEnv};
pub mod common;
#[test]
fn empty_alloy_block() {
common::test_execute_alloy(
&InMemoryStorage::default(),
&PevmEthereum::mainnet(),
Block {
header: common::MOCK_ALLOY_BLOCK_HEADER.clone(),
transactions: BlockTransactions::Full(Vec::new()),
..Block::default()
},
false,
);
}
#[test]
fn empty_revm_block() {
common::test_execute_revm(InMemoryStorage::default(), Vec::new());
}
#[test]
fn one_tx_alloy_block() {
common::test_execute_alloy(
&InMemoryStorage::new([common::mock_account(0)], None, []),
&PevmEthereum::mainnet(),
Block {
// Legit header but with no transactions
header: common::MOCK_ALLOY_BLOCK_HEADER.clone(),
transactions: BlockTransactions::Full(vec![Transaction {
transaction_type: Some(2),
nonce: 1,
from: Address::ZERO,
to: Some(Address::ZERO),
value: U256::from(1),
max_fee_per_gas: Some(1),
gas: u64::MAX.into(),
..Transaction::default()
}]),
..Block::default()
},
false,
);
}
#[test]
fn one_tx_revm_block() {
common::test_execute_revm(
InMemoryStorage::new([common::mock_account(0)], None, []),
vec![TxEnv {
caller: Address::ZERO,
transact_to: TransactTo::Call(Address::ZERO),
value: U256::from(1),
gas_price: U256::from(1),
..TxEnv::default()
}],
);
}