Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

Commit

Permalink
Update consensus tests (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
vorot93 authored Sep 15, 2022
1 parent 5ce3847 commit 240fa0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
repository: ethereum/tests
submodules: recursive
path: ethereum-tests
ref: 'v10.4'
ref: 'v11.1'

- run: |
env RUST_LOG=error cargo run --release --bin consensus-tests -- --tests="./ethereum-tests"
32 changes: 14 additions & 18 deletions bin/consensus-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ enum Network {
BerlinToLondonAt5,
EIP2384,
ArrowGlacier,
ArrowGlacierToMergeAtDiffC0000,
Merge,
}

Expand All @@ -168,6 +169,7 @@ impl FromStr for Network {
"BerlinToLondonAt5" => Self::BerlinToLondonAt5,
"EIP2384" => Self::EIP2384,
"ArrowGlacier" => Self::ArrowGlacier,
"ArrowGlacierToMergeAtDiffC0000" => Self::ArrowGlacierToMergeAtDiffC0000,
"Merge" => Self::Merge,
_ => return Err(s.to_string()),
})
Expand All @@ -189,6 +191,9 @@ fn testconfig(name: Network, upgrades: Upgrades, dao_block: Option<BlockNumber>)
if let Some(block) = spec.upgrades.constantinople {
block_reward.insert(block, (2 * ETHER).as_u256());
}
if let Some(block) = spec.upgrades.paris {
block_reward.insert(block, U256::ZERO);
}

let mainnet_dao_fork_block_num = BlockNumber(1_920_000);
let dao_data = spec.balances.remove(&mainnet_dao_fork_block_num).unwrap();
Expand Down Expand Up @@ -406,22 +411,6 @@ static NETWORK_CONFIG: Lazy<HashMap<Network, ChainSpec>> = Lazy::new(|| {
},
None,
),
(
Network::Merge,
Upgrades {
homestead: Some(0.into()),
tangerine: Some(0.into()),
spurious: Some(0.into()),
byzantium: Some(0.into()),
constantinople: Some(0.into()),
petersburg: Some(0.into()),
istanbul: Some(0.into()),
berlin: Some(0.into()),
london: Some(0.into()),
paris: Some(0.into()),
},
None,
),
]
.into_iter()
.map(|(network, upgrades, dao_block)| (network, testconfig(network, upgrades, dao_block)))
Expand Down Expand Up @@ -630,7 +619,10 @@ fn blockchain_test(testdata: BlockchainTest) -> anyhow::Result<()> {
let genesis_block = <Block as Decodable>::decode(&mut &*testdata.genesis_rlp).unwrap();

let mut state = InMemoryState::default();
let config = NETWORK_CONFIG[&testdata.network].clone();
let Some(config) = NETWORK_CONFIG.get(&testdata.network).cloned() else {
warn!("Network config {:?} not found, skipping test", testdata.network);
return Ok(());
};

init_pre_state(&testdata.pre, &mut state);

Expand Down Expand Up @@ -693,7 +685,11 @@ fn transaction_test(testdata: TransactionTest) -> anyhow::Result<()> {
.context("Failed to decode valid transaction"));
}
(Ok(txn), t) => {
let config = &NETWORK_CONFIG[&key.parse().unwrap()];
let key = key.parse().unwrap();
let Some(config) = &NETWORK_CONFIG.get(&key) else {
warn!("Network config {key:?} not found, skipping test");
continue;
};

if let Err(e) = pre_validate_transaction(txn, config.params.chain_id, None) {
match t {
Expand Down

0 comments on commit 240fa0a

Please sign in to comment.