Run cargo fmt --all
This commit is contained in:
parent
f7519096a6
commit
39c3526884
@ -1,6 +1,6 @@
|
|||||||
|
use tree_hash::SignedRoot;
|
||||||
use types::test_utils::{TestingBeaconBlockBuilder, TestingBeaconStateBuilder};
|
use types::test_utils::{TestingBeaconBlockBuilder, TestingBeaconStateBuilder};
|
||||||
use types::*;
|
use types::*;
|
||||||
use tree_hash::SignedRoot;
|
|
||||||
|
|
||||||
pub struct BlockProcessingBuilder<T: EthSpec> {
|
pub struct BlockProcessingBuilder<T: EthSpec> {
|
||||||
pub state_builder: TestingBeaconStateBuilder<T>,
|
pub state_builder: TestingBeaconStateBuilder<T>,
|
||||||
@ -31,7 +31,12 @@ impl<T: EthSpec> BlockProcessingBuilder<T> {
|
|||||||
self.state_builder.build_caches(&spec).unwrap();
|
self.state_builder.build_caches(&spec).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build(mut self, randao_sk: Option<SecretKey>, previous_block_root: Option<Hash256>, spec: &ChainSpec) -> (BeaconBlock, BeaconState<T>) {
|
pub fn build(
|
||||||
|
mut self,
|
||||||
|
randao_sk: Option<SecretKey>,
|
||||||
|
previous_block_root: Option<Hash256>,
|
||||||
|
spec: &ChainSpec,
|
||||||
|
) -> (BeaconBlock, BeaconState<T>) {
|
||||||
let (state, keypairs) = self.state_builder.build();
|
let (state, keypairs) = self.state_builder.build();
|
||||||
let builder = &mut self.block_builder;
|
let builder = &mut self.block_builder;
|
||||||
|
|
||||||
@ -39,7 +44,9 @@ impl<T: EthSpec> BlockProcessingBuilder<T> {
|
|||||||
|
|
||||||
match previous_block_root {
|
match previous_block_root {
|
||||||
Some(root) => builder.set_previous_block_root(root),
|
Some(root) => builder.set_previous_block_root(root),
|
||||||
None => builder.set_previous_block_root(Hash256::from_slice(&state.latest_block_header.signed_root())),
|
None => builder.set_previous_block_root(Hash256::from_slice(
|
||||||
|
&state.latest_block_header.signed_root(),
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
|
|
||||||
let proposer_index = state
|
let proposer_index = state
|
||||||
@ -56,5 +63,4 @@ impl<T: EthSpec> BlockProcessingBuilder<T> {
|
|||||||
|
|
||||||
(block, state)
|
(block, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ fn invalid_parent_block_root() {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
result,
|
result,
|
||||||
Err(BlockProcessingError::Invalid(
|
Err(BlockProcessingError::Invalid(
|
||||||
BlockInvalid::ParentBlockRootMismatch{
|
BlockInvalid::ParentBlockRootMismatch {
|
||||||
state: Hash256::from_slice(&state.latest_block_header.signed_root()),
|
state: Hash256::from_slice(&state.latest_block_header.signed_root()),
|
||||||
block: block.previous_block_root
|
block: block.previous_block_root
|
||||||
}
|
}
|
||||||
@ -94,7 +94,9 @@ fn invalid_randao_reveal_signature() {
|
|||||||
// should get a BadRandaoSignature error
|
// should get a BadRandaoSignature error
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result,
|
result,
|
||||||
Err(BlockProcessingError::Invalid(BlockInvalid::BadRandaoSignature))
|
Err(BlockProcessingError::Invalid(
|
||||||
|
BlockInvalid::BadRandaoSignature
|
||||||
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user