lighthouse: Block processing testing
Description
During the latest spec update and code restructure we lost a lot of our block processing testing.
The objective of this issue is:
implement regression testing that ensures block processing fails when supplied an invalid parameter.
Detail
Block processing lives in the state_processing crate, specifically in the per_block_processing.rs file and per_block_processing/ dir.
Tests should be implemented in a new file: ... state_processing/src/per_block_processing/tests.rs.
The task will primarily consist of:
- Devise some valid block and accompanying state and ensure it passes block validation.
- For each test, modify the valid block (or state?) to trigger some invalidity condition and assert that that condition was triggered by inspecting the error chain (i.e., ensure the returned
Resultis erroneous and theErroris correct).
We have a suite of “builders” in types/src/test_utils/ that are perfect for this task. For example, TestingBeaconBlockBuilder and TestingBeaconStateBuilder will produce valid blocks and states “from thin air”, without needing to build a whole chain.
The best resource for learning how to use these builders is in the “old” (circa last week, before a spec update) benching code, which is presently not compiling (sorry). Particularly the BlockBenchingBuilder. I would probably start by copying the BlockBenchingBuilder and modifying it into the BlockProcessingTestBuilder (or w/e, name not well thought out).
I’m imagining this sort of flow:
let spec = ChainSpec::foundation();
let builder = BlockProcessingTestBuilder::new(...);
let (mut block, mut state) = builder.build();
state.slot = 133713
block.slot = 424242;
let result = per_block_processing(&mut state, &block, &spec);
assert_eq!(result, Err(BlockProcessingError(Invalid(BlockInvalid::StateSlotMismatch))));
Note: this is pseudo-code. Won’t compile, may have errors.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (8 by maintainers)
This issue is complete! @gitcoinbot you can do your magic 😃
Hi @gitcoinbot I am still working on this.
Hi @gitcoinbot I am still working on this.
Hi @gitcoinbot - yes I am working on this task.
Hi @gitcoinbot - just groking and will submit a WIP PR shortly 😃
@darrenlangley I believe you’re interested in this issue 😃