Fix bug with invalid state root

This commit is contained in:
Paul Hauner 2019-09-04 12:04:15 +10:00
parent 7edc5f37b9
commit 009a7eb9c7
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
2 changed files with 22 additions and 3 deletions

View File

@ -243,6 +243,9 @@ fn interop_genesis_state<T: EthSpec>(
state.genesis_time = genesis_time;
// Invalid all the caches after all the manual state surgery.
state.drop_all_caches();
Ok(state)
}

View File

@ -465,12 +465,10 @@ fn free_attestations_added_to_fork_choice_all_updated() {
}
}
#[test]
fn produces_and_processes_with_genesis_skip_slots() {
fn run_skip_slot_test(skip_slots: u64) {
let num_validators = 8;
let harness_a = get_harness(num_validators);
let harness_b = get_harness(num_validators);
let skip_slots = 9;
for _ in 0..skip_slots {
harness_a.advance_slot();
@ -484,6 +482,12 @@ fn produces_and_processes_with_genesis_skip_slots() {
AttestationStrategy::SomeValidators(vec![]),
);
assert_eq!(
harness_a.chain.head().beacon_block.slot,
Slot::new(skip_slots + 1)
);
assert_eq!(harness_b.chain.head().beacon_block.slot, Slot::new(0));
assert_eq!(
harness_b
.chain
@ -492,4 +496,16 @@ fn produces_and_processes_with_genesis_skip_slots() {
block_root: harness_a.chain.head().beacon_block_root
})
);
assert_eq!(
harness_b.chain.head().beacon_block.slot,
Slot::new(skip_slots + 1)
);
}
#[test]
fn produces_and_processes_with_genesis_skip_slots() {
for i in 0..MinimalEthSpec::slots_per_epoch() * 4 {
run_skip_slot_test(i)
}
}