-
Notifications
You must be signed in to change notification settings - Fork 53
/
main.rs
56 lines (50 loc) · 1.71 KB
/
main.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
//! Each cluster has one ERC20 contract and X families.
//! Each family has Y people.
//! Each person performs Z transfers to random people within the family.
#[path = "../common/mod.rs"]
pub mod common;
#[path = "./mod.rs"]
pub mod erc20;
use common::test_execute_revm;
use erc20::generate_cluster;
use pevm::chain::PevmEthereum;
use pevm::{Bytecodes, ChainState, EvmAccount, InMemoryStorage};
use revm::primitives::{Address, TxEnv};
use std::sync::Arc;
#[test]
fn erc20_independent() {
const N: usize = 37123;
let (mut state, bytecodes, txs) = generate_cluster(N, 1, 1);
state.insert(Address::ZERO, EvmAccount::default()); // Beneficiary
test_execute_revm(
&PevmEthereum::mainnet(),
InMemoryStorage::new(state, Arc::new(bytecodes), Default::default()),
txs,
);
}
#[test]
fn erc20_clusters() {
const NUM_CLUSTERS: usize = 10;
const NUM_FAMILIES_PER_CLUSTER: usize = 15;
const NUM_PEOPLE_PER_FAMILY: usize = 15;
const NUM_TRANSFERS_PER_PERSON: usize = 15;
let mut final_state = ChainState::default();
final_state.insert(Address::ZERO, EvmAccount::default()); // Beneficiary
let mut final_bytecodes = Bytecodes::default();
let mut final_txs = Vec::<TxEnv>::new();
for _ in 0..NUM_CLUSTERS {
let (state, bytecodes, txs) = generate_cluster(
NUM_FAMILIES_PER_CLUSTER,
NUM_PEOPLE_PER_FAMILY,
NUM_TRANSFERS_PER_PERSON,
);
final_state.extend(state);
final_bytecodes.extend(bytecodes);
final_txs.extend(txs);
}
common::test_execute_revm(
&PevmEthereum::mainnet(),
InMemoryStorage::new(final_state, Arc::new(final_bytecodes), Default::default()),
final_txs,
)
}