Ensure project tests compile on v0.5.0

This commit is contained in:
Paul Hauner 2019-03-17 19:28:29 +11:00
parent 919a15de22
commit f71cab8ba2
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6

View File

@ -20,7 +20,7 @@ use ssz::TreeHash;
use std::sync::Arc; use std::sync::Arc;
use types::{ use types::{
beacon_state::BeaconStateBuilder, BeaconBlock, ChainSpec, Deposit, DepositData, DepositInput, beacon_state::BeaconStateBuilder, BeaconBlock, ChainSpec, Deposit, DepositData, DepositInput,
Domain, Eth1Data, Fork, Hash256, Keypair, Eth1Data, Fork, Hash256, Keypair,
}; };
fn main() { fn main() {
@ -103,35 +103,36 @@ fn main() {
let initial_validator_deposits: Vec<Deposit> = keypairs let initial_validator_deposits: Vec<Deposit> = keypairs
.iter() .iter()
.map(|keypair| Deposit { .map(|keypair| {
branch: vec![], // branch verification is not specified. let mut deposit_input = DepositInput {
index: 0, // index verification is not specified. pubkey: keypair.pk.clone(),
deposit_data: DepositData { withdrawal_credentials: Hash256::zero(),
amount: 32_000_000_000, // 32 ETH (in Gwei) proof_of_possession: spec.empty_signature.clone(),
timestamp: genesis_time - 1, };
deposit_input: DepositInput { deposit_input.proof_of_possession = deposit_input.create_proof_of_possession(
pubkey: keypair.pk.clone(), &keypair.sk,
withdrawal_credentials: Hash256::zero(), // Withdrawal not possible. spec.genesis_epoch,
proof_of_possession: DepositInput::create_proof_of_possession( &Fork::genesis(&spec),
&keypair, &spec,
&Hash256::zero(), );
spec.get_domain(
// Get domain from genesis fork_version Deposit {
spec.genesis_epoch, proof: vec![], // branch verification is not specified.
Domain::Deposit, index: 0, // index verification is not specified.
&Fork::genesis(&spec), deposit_data: DepositData {
), amount: 32_000_000_000, // 32 ETH (in Gwei)
), timestamp: genesis_time - 1,
deposit_input,
}, },
}, }
}) })
.collect(); .collect();
let mut state_builder = BeaconStateBuilder::new(genesis_time, latest_eth1_data, &spec); let mut state_builder = BeaconStateBuilder::new(genesis_time, latest_eth1_data, &spec);
state_builder.process_initial_deposits(&initial_validator_deposits, &spec); state_builder.process_initial_deposits(&initial_validator_deposits, &spec);
let genesis_state = state_builder.build(&spec).unwrap(); let genesis_state = state_builder.build(&spec).unwrap();
let state_root = Hash256::from_slice(&genesis_state.hash_tree_root()); let mut genesis_block = BeaconBlock::empty(&spec);
let genesis_block = BeaconBlock::genesis(state_root, &spec); genesis_block.state_root = Hash256::from_slice(&genesis_state.hash_tree_root());
// Genesis chain // Genesis chain
let _chain_result = BeaconChain::from_genesis( let _chain_result = BeaconChain::from_genesis(