mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 04:31:51 +00:00
fake sig back, merge, and fixed up yml checkin issue
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
#![cfg(test)]
|
||||
#![cfg(all(test, not(feature = "fake_crypto")))]
|
||||
use super::block_processing_builder::BlockProcessingBuilder;
|
||||
use super::errors::*;
|
||||
use crate::per_block_processing;
|
||||
use ssz::SignedRoot;
|
||||
use types::{ChainSpec, Domain, Keypair, Signature, Slot};
|
||||
use tree_hash::SignedRoot;
|
||||
use types::*;
|
||||
|
||||
pub const VALIDATOR_COUNT: usize = 10;
|
||||
|
||||
#[test]
|
||||
fn valid_block_ok() {
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = FoundationEthSpec::spec();
|
||||
let builder = get_builder(&spec);
|
||||
let (block, mut state) = builder.build(None, &spec);
|
||||
let (block, mut state) = builder.build(None, None, &spec);
|
||||
|
||||
let result = per_block_processing(&mut state, &block, &spec);
|
||||
|
||||
@@ -20,9 +20,9 @@ fn valid_block_ok() {
|
||||
|
||||
#[test]
|
||||
fn invalid_block_header_state_slot() {
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = FoundationEthSpec::spec();
|
||||
let builder = get_builder(&spec);
|
||||
let (mut block, mut state) = builder.build(None, &spec);
|
||||
let (mut block, mut state) = builder.build(None, None, &spec);
|
||||
|
||||
state.slot = Slot::new(133713);
|
||||
block.slot = Slot::new(424242);
|
||||
@@ -38,16 +38,30 @@ fn invalid_block_header_state_slot() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn invalid_parent_block_root() {
|
||||
// this will be changed in spec 0.5.1 to use signed root
|
||||
let spec = FoundationEthSpec::spec();
|
||||
let builder = get_builder(&spec);
|
||||
let invalid_parent_root = Hash256::from([0xAA; 32]);
|
||||
let (block, mut state) = builder.build(None, Some(invalid_parent_root), &spec);
|
||||
|
||||
let result = per_block_processing(&mut state, &block, &spec);
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
Err(BlockProcessingError::Invalid(
|
||||
BlockInvalid::ParentBlockRootMismatch{
|
||||
state: Hash256::from_slice(&state.latest_block_header.signed_root()),
|
||||
block: block.previous_block_root
|
||||
}
|
||||
))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_block_signature() {
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = FoundationEthSpec::spec();
|
||||
let builder = get_builder(&spec);
|
||||
let (mut block, mut state) = builder.build(None, &spec);
|
||||
let (mut block, mut state) = builder.build(None, None, &spec);
|
||||
|
||||
// sign the block with a keypair that is not the expected proposer
|
||||
let keypair = Keypair::random();
|
||||
@@ -68,12 +82,12 @@ fn invalid_block_signature() {
|
||||
|
||||
#[test]
|
||||
fn invalid_randao_reveal_signature() {
|
||||
let spec = ChainSpec::foundation();
|
||||
let spec = FoundationEthSpec::spec();
|
||||
let builder = get_builder(&spec);
|
||||
|
||||
// sign randao reveal with random keypair
|
||||
let keypair = Keypair::random();
|
||||
let (block, mut state) = builder.build(Some(keypair.sk), &spec);
|
||||
let (block, mut state) = builder.build(Some(keypair.sk), None, &spec);
|
||||
|
||||
let result = per_block_processing(&mut state, &block, &spec);
|
||||
|
||||
@@ -84,7 +98,7 @@ fn invalid_randao_reveal_signature() {
|
||||
);
|
||||
}
|
||||
|
||||
fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder) {
|
||||
fn get_builder(spec: &ChainSpec) -> (BlockProcessingBuilder<FoundationEthSpec>) {
|
||||
let mut builder = BlockProcessingBuilder::new(VALIDATOR_COUNT, &spec);
|
||||
|
||||
// Set the state and block to be in the last slot of the 4th epoch.
|
||||
|
||||
Reference in New Issue
Block a user