Add longest chain tests and test vectors.

This commit is contained in:
Age Manning 2019-02-19 15:22:35 +11:00
parent bd66a02cb3
commit 2394f64329
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93
2 changed files with 61 additions and 0 deletions

View 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'

View File

@ -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,