feat: add GenesisAllocator for easier genesis alloc creation (#6021)

This commit is contained in:
Dan Cline
2024-01-12 06:43:28 -05:00
committed by GitHub
parent ee199bb5db
commit 00d6bffc0d
4 changed files with 210 additions and 16 deletions

View File

@ -2345,11 +2345,8 @@ mod tests {
mod new_payload {
use super::*;
use reth_interfaces::test_utils::{
generators,
generators::{generate_keys, random_block},
};
use reth_primitives::{public_key_to_address, Genesis, GenesisAccount, Hardfork, U256};
use reth_interfaces::test_utils::{generators, generators::random_block};
use reth_primitives::{Genesis, GenesisAllocator, Hardfork, U256};
use reth_provider::test_utils::blocks::BlockChainTestData;
#[tokio::test]
@ -2453,14 +2450,14 @@ mod tests {
#[tokio::test]
async fn simple_validate_block() {
let mut rng = generators::rng();
let genesis_keys = generate_keys(&mut rng, 16);
let amount = 1000000000000000000u64;
let alloc = genesis_keys.iter().map(|pair| {
(
public_key_to_address(pair.public_key()),
GenesisAccount::default().with_balance(U256::from(amount)),
)
});
let amount = U256::from(1000000000000000000u64);
let mut allocator = GenesisAllocator::default().with_rng(&mut rng);
for _ in 0..16 {
// add 16 new accounts
allocator.new_funded_account(amount);
}
let alloc = allocator.build();
let genesis = Genesis::default().extend_accounts(alloc);