Skip to content

Commit b0801a5

Browse files
committed
Merge main into issue-638-core-consensus-harness
2 parents 925bd63 + 1a19470 commit b0801a5

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

code/crates/test/tests/it/equivocation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fn check_decided_impl<Ctx: Context>(evidence: &MisbehaviorEvidence<Ctx>) {
3131
// contains double proposals and double prevotes for the equivocator.
3232
// Node 3 checks for proposal equivocation evidence.
3333
#[tokio::test]
34+
#[ignore] // Flaky test
3435
pub async fn equivocation_two_vals_same_pk_proposal() {
3536
// Nodes 1 and 2 share a validator key to induce proposal equivocation
3637
let params = TestParams {
@@ -76,6 +77,7 @@ pub async fn equivocation_two_vals_same_pk_proposal() {
7677
// contains double proposals and double prevotes for the equivocator.
7778
// Node 3 checks for vote equivocation evidence.
7879
#[tokio::test]
80+
#[ignore] // Flaky test
7981
pub async fn equivocation_two_vals_same_pk_vote() {
8082
// Nodes 1 and 2 share a validator key to induce vote equivocation
8183
let params = TestParams {

code/crates/test/tests/it/main.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,43 @@ pub struct NodeInfo {
7171
config_modifier: ConfigModifier<Config>,
7272
}
7373

74+
fn global_slot() -> Option<usize> {
75+
if let Ok(slot_str) = std::env::var("NEXTEST_TEST_GLOBAL_SLOT") {
76+
Some(
77+
slot_str
78+
.parse::<usize>()
79+
.expect("NEXTEST_TEST_GLOBAL_SLOT must be a non-negative integer"),
80+
)
81+
} else {
82+
None
83+
}
84+
}
85+
86+
const BASE_PORT: usize = 5000;
87+
const PORTS_PER_NODE: usize = 10;
88+
const PORTS_PER_SLOT: usize = 200; // ample space for 20 nodes
89+
7490
#[async_trait]
7591
impl NodeRunner<TestContext> for TestRunner {
7692
type NodeHandle = Handle;
7793

7894
fn new<S>(id: usize, nodes: &[TestNode<TestContext, S>], params: TestParams) -> Self {
79-
let base_port = 20_000 + id * 1000;
95+
// Check if the NEXTEST_TEST_GLOBAL_SLOT environment variable is set.
96+
//
97+
// Global slot numbers are non-negative integers starting from 0 that
98+
// are unique within the run for the lifetime of the test,
99+
// but are reused after the test finishes.
100+
//
101+
// We use them to assign ports to nodes in a way that allows multiple tests
102+
// to run in parallel without port conflicts.
103+
let global_slot = global_slot().unwrap_or(0);
104+
105+
let port_offset = global_slot * PORTS_PER_SLOT + id * PORTS_PER_NODE;
106+
let base_port = BASE_PORT + port_offset;
107+
108+
if base_port > 60000 {
109+
panic!("Calculated port {base_port} is too high. Reduce concurrency or port spacing.");
110+
}
80111

81112
let (validators, private_keys) = make_validators(nodes, &params);
82113
let validator_set = ValidatorSet::new(validators);

0 commit comments

Comments
 (0)