Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report unhappy blocks in happy path test #430

Merged
merged 16 commits into from
Sep 26, 2023
Merged
2 changes: 2 additions & 0 deletions tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ waku-bindings = { version = "0.1.1", optional = true }
reqwest = { version = "0.11", features = ["json"] }
nomos-libp2p = { path = "../nomos-libp2p" }
tempfile = "3.6"
serde = { version = "1", features = ["derive"] }
serde_yaml = "0.9"
serde_json = "1"
tokio = "1"
futures = "0.3"
async-trait = "0.1"
Expand Down
30 changes: 29 additions & 1 deletion tests/src/tests/happy.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use consensus_engine::View;
use consensus_engine::{Qc, View};
use fraction::{Fraction, One};
use futures::stream::{self, StreamExt};
use std::collections::HashSet;
Expand All @@ -7,6 +7,13 @@ use tests::{MixNode, Node, NomosNode, SpawnConfig};

const TARGET_VIEW: View = View::new(20);

#[derive(serde::Serialize)]
struct Info {
node_id: String,
block_id: String,
view: View,
}

async fn happy_test(nodes: Vec<NomosNode>) {
let timeout = std::time::Duration::from_secs(20);
let timeout = tokio::time::sleep(timeout);
Expand Down Expand Up @@ -43,6 +50,27 @@ async fn happy_test(nodes: Vec<NomosNode>) {
.unwrap()
})
.collect::<HashSet<_>>();

// try to see if we have invalid blocks
let invalid_blocks = infos
.iter()
.flat_map(|i| {
i.safe_blocks.values().filter_map(|b| match &b.parent_qc {
Qc::Standard(_) => None,
Qc::Aggregated(_) => Some(Info {
node_id: i.id.to_string(),
block_id: b.id.to_string(),
view: b.view,
}),
})
})
.collect::<Vec<_>>();

assert!(
invalid_blocks.is_empty(),
"{}",
serde_json::to_string_pretty(&invalid_blocks).unwrap()
);
assert_eq!(blocks.len(), 1);
}

Expand Down
Loading