Skip to content

Commit

Permalink
feat: added faulty party test
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitaMasych committed Sep 9, 2024
1 parent 1448ec3 commit c17fd34
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/party.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,4 +1136,32 @@ pub(crate) mod tests {

analyze_ballot_result(values);
}

#[tokio::test]
async fn test_ballot_faulty_party() {
let cfg = BPConConfig::with_default_timeouts(vec![1, 1, 1, 1], 2);

let (mut parties, mut channels) = create_parties(cfg);

let leader = parties[0].leader;

assert_ne!(
parties[3].id, leader,
"Should not fail the leader for the test to pass"
);

// Simulate failure of `f` faulty participants:
let parties = parties.drain(..3).collect();
let channels = channels.drain(..3).collect();

let ballot_tasks = launch_parties(parties);

let p2p_task = propagate_messages_p2p(channels);

let values = extract_values_from_ballot_tasks(ballot_tasks).await;

p2p_task.abort();

analyze_ballot_result(values);
}
}

0 comments on commit c17fd34

Please sign in to comment.