Skip to content

Commit

Permalink
fix: tests in retrieving multiple blocks fail randomly (MystenLabs#141)
Browse files Browse the repository at this point in the history
This commit is fixing the bug of having ports clashing on block_waiter tests. This could lead to failures when running the servers between tests and eventually make tests fail.
  • Loading branch information
akichidis authored Apr 20, 2022
1 parent 7089c29 commit 2a795f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions narwhal/primary/src/tests/block_waiter_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async fn test_successfully_retrieve_multiple_blocks() {
let (_, certificate_store, _) = create_db_stores();

// AND the necessary keys
let (name, committee) = resolve_name_and_committee(13000);
let (name, committee) = resolve_name_and_committee(13001);

let key = keys().pop().unwrap();
let mut block_ids = Vec::new();
Expand Down Expand Up @@ -265,7 +265,7 @@ async fn test_one_pending_request_for_block_at_time() {
let (_, certificate_store, _) = create_db_stores();

// AND the necessary keys
let (name, committee) = resolve_name_and_committee(13000);
let (name, committee) = resolve_name_and_committee(13002);

// AND store certificate
let header = common::fixture_header_with_payload(2);
Expand Down Expand Up @@ -333,7 +333,7 @@ async fn test_unlocking_pending_get_block_request_after_response() {
let (_, certificate_store, _) = create_db_stores();

// AND the necessary keys
let (name, committee) = resolve_name_and_committee(13000);
let (name, committee) = resolve_name_and_committee(13003);

// AND store certificate
let header = common::fixture_header_with_payload(2);
Expand Down Expand Up @@ -392,7 +392,7 @@ async fn test_batch_timeout() {
let (_, certificate_store, _) = create_db_stores();

// AND the necessary keys
let (name, committee) = resolve_name_and_committee(13000);
let (name, committee) = resolve_name_and_committee(13004);

// AND store certificate
let header = common::fixture_header_with_payload(2);
Expand Down Expand Up @@ -448,7 +448,7 @@ async fn test_batch_timeout() {
async fn test_return_error_when_certificate_is_missing() {
// GIVEN
let (_, certificate_store, _) = create_db_stores();
let (name, committee) = resolve_name_and_committee(13000);
let (name, committee) = resolve_name_and_committee(13005);

// AND create a certificate but don't store it
let certificate = Certificate::<Ed25519PublicKey>::default();
Expand Down
4 changes: 3 additions & 1 deletion narwhal/primary/src/tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ pub fn create_db_stores() -> (
)
}

// helper method to get a name and a committee
// helper method to get a name and a committee. Special care should be given on
// the base_port parameter to not collide between tests. It is advisable to
// provide unique base_port numbers across the tests.
pub fn resolve_name_and_committee(
base_port: u16,
) -> (Ed25519PublicKey, Committee<Ed25519PublicKey>) {
Expand Down

0 comments on commit 2a795f9

Please sign in to comment.