Make sure the adder collator fails when something is wrong (#2450)

As futures most of the time are catching panics and we don't check this,
it could happen that we have some statement that isn't correct but the
test succeeds successfully.
This commit is contained in:
Bastian Köcher
2021-02-16 20:27:50 +01:00
committed by GitHub
parent a8d3aca13d
commit 27c7347b9b
3 changed files with 5 additions and 6 deletions
-1
View File
@@ -9217,7 +9217,6 @@ dependencies = [
name = "test-parachain-adder-collator"
version = "0.7.26"
dependencies = [
"assert_matches",
"futures 0.3.12",
"futures-timer 3.0.2",
"log",
@@ -15,7 +15,6 @@ futures = "0.3.12"
futures-timer = "3.0.2"
log = "0.4.13"
structopt = "0.3.21"
assert_matches = "1.4.0"
test-parachain-adder = { path = ".." }
polkadot-primitives = { path = "../../../../primitives" }
@@ -28,7 +28,6 @@ use std::{
};
use test_parachain_adder::{execute, hash_state, BlockData, HeadData};
use futures::channel::oneshot;
use assert_matches::assert_matches;
/// The amount we add when producing a new block.
///
@@ -180,11 +179,13 @@ impl Collator {
let seconded_collations = seconded_collations.clone();
spawner.spawn("adder-collator-seconded", async move {
if let Ok(res) = recv.await {
assert_matches!(
if !matches!(
res.payload(),
Statement::Seconded(s) if s.descriptor.pov_hash == pov.hash(),
"Seconded statement should match our collation!",
);
) {
log::error!("Seconded statement should match our collation: {:?}", res.payload());
std::process::exit(-1);
}
seconded_collations.fetch_add(1, Ordering::Relaxed);
}