bitfield dist logging cleanup and enhancements (#5147)

* split metrics from bitfield signing

* cleanup all logging

* add a unit test for subset generation

* chore: add one more test to assert need is properly represented

* u8 as usize

* chore: overseer fixin

* fix test

* Update node/network/bitfield-distribution/src/metrics.rs

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

* Update node/network/bitfield-distribution/src/metrics.rs

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>

* fallout from suggested rename

* consistency

Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
Bernhard Schuster
2022-03-18 14:44:38 +01:00
committed by GitHub
parent 61a6004cf1
commit 6e3b5f1888
7 changed files with 272 additions and 158 deletions
+11
View File
@@ -245,3 +245,14 @@ fn tick_tack_metronome() {
)
});
}
#[test]
fn subset_generation_check() {
let values = (0_u8..=25).collect::<Vec<_>>();
// 12 even numbers exist
let mut chosen = choose_random_subset::<u8, _>(|v| v & 0x01 == 0, values, 12);
chosen.sort();
for (idx, v) in dbg!(chosen).into_iter().enumerate() {
assert_eq!(v as usize, idx * 2);
}
}