Add longest chain tests and test vectors.
This commit is contained in:
parent
bd66a02cb3
commit
2394f64329
51
eth2/fork_choice/tests/longest_chain_test_vectors.yaml
Normal file
51
eth2/fork_choice/tests/longest_chain_test_vectors.yaml
Normal file
@ -0,0 +1,51 @@
|
||||
title: Fork-choice Tests
|
||||
summary: A collection of abstract fork-choice tests to verify the longest chain fork-choice rule.
|
||||
test_suite: Fork-Choice
|
||||
|
||||
test_cases:
|
||||
- blocks:
|
||||
- id: 'b0'
|
||||
parent: 'b0'
|
||||
- id: 'b1'
|
||||
parent: 'b0'
|
||||
- id: 'b2'
|
||||
parent: 'b1'
|
||||
- id: 'b3'
|
||||
parent: 'b1'
|
||||
- id: 'b4'
|
||||
parent: 'b3'
|
||||
weights:
|
||||
- b0: 0
|
||||
- b1: 0
|
||||
- b2: 10
|
||||
- b3: 1
|
||||
heads:
|
||||
- id: 'b4'
|
||||
- blocks:
|
||||
- id: 'b0'
|
||||
parent: 'b0'
|
||||
- id: 'b1'
|
||||
parent: 'b0'
|
||||
- id: 'b2'
|
||||
parent: 'b1'
|
||||
- id: 'b3'
|
||||
parent: 'b2'
|
||||
- id: 'b4'
|
||||
parent: 'b3'
|
||||
- id: 'b5'
|
||||
parent: 'b0'
|
||||
- id: 'b6'
|
||||
parent: 'b5'
|
||||
- id: 'b7'
|
||||
parent: 'b6'
|
||||
- id: 'b8'
|
||||
parent: 'b7'
|
||||
- id: 'b9'
|
||||
parent: 'b8'
|
||||
weights:
|
||||
- b0: 5
|
||||
- b1: 20
|
||||
- b2: 10
|
||||
- b3: 10
|
||||
heads:
|
||||
- id: 'b9'
|
@ -45,6 +45,16 @@ fn test_slow_lmd_ghost() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_longest_chain() {
|
||||
test_yaml_vectors(
|
||||
ForkChoiceAlgorithm::LongestChain,
|
||||
"tests/longest_chain_test_vectors.yaml",
|
||||
100,
|
||||
"debug",
|
||||
);
|
||||
}
|
||||
|
||||
// run a generic test over given YAML test vectors
|
||||
fn test_yaml_vectors(
|
||||
fork_choice_algo: ForkChoiceAlgorithm,
|
||||
|
Loading…
Reference in New Issue
Block a user