Skip to content

Commit

Permalink
Use a default mock version where possible
Browse files Browse the repository at this point in the history
Reduce noise when setting up the harness for tests that don't really
care about the remote peer version.
  • Loading branch information
jvff committed Dec 18, 2021
1 parent 68764f3 commit fea2247
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions zebra-network/src/peer/client/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
use zebra_test::service_extensions::IsReady;

use crate::{peer::ClientTestHarness, protocol::external::types::Version, PeerError};
use crate::{peer::ClientTestHarness, PeerError};

#[tokio::test]
async fn client_service_ready_ok() {
zebra_test::init();

let (mut client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (mut client, mut harness) = ClientTestHarness::build().finish();

assert!(client.is_ready().await);
assert!(harness.current_error().is_none());
Expand All @@ -20,7 +20,7 @@ async fn client_service_ready_ok() {
async fn client_service_ready_heartbeat_exit() {
zebra_test::init();

let (mut client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (mut client, mut harness) = ClientTestHarness::build().finish();

harness.set_error(PeerError::HeartbeatTaskExited);
harness.drop_heartbeat_shutdown_receiver();
Expand All @@ -34,7 +34,7 @@ async fn client_service_ready_heartbeat_exit() {
async fn client_service_ready_request_drop() {
zebra_test::init();

let (mut client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (mut client, mut harness) = ClientTestHarness::build().finish();

harness.set_error(PeerError::ConnectionDropped);
harness.drop_outbound_client_request_receiver();
Expand All @@ -48,7 +48,7 @@ async fn client_service_ready_request_drop() {
async fn client_service_ready_request_close() {
zebra_test::init();

let (mut client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (mut client, mut harness) = ClientTestHarness::build().finish();

harness.set_error(PeerError::ConnectionClosed);
harness.close_outbound_client_request_receiver();
Expand All @@ -63,7 +63,7 @@ async fn client_service_ready_request_close() {
async fn client_service_ready_error_in_slot() {
zebra_test::init();

let (mut client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (mut client, mut harness) = ClientTestHarness::build().finish();

harness.set_error(PeerError::Overloaded);

Expand All @@ -77,7 +77,7 @@ async fn client_service_ready_error_in_slot() {
async fn client_service_ready_multiple_errors() {
zebra_test::init();

let (mut client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (mut client, mut harness) = ClientTestHarness::build().finish();

harness.set_error(PeerError::DuplicateHandshake);
harness.drop_heartbeat_shutdown_receiver();
Expand All @@ -92,7 +92,7 @@ async fn client_service_ready_multiple_errors() {
async fn client_service_drop_cleanup() {
zebra_test::init();

let (client, mut harness) = ClientTestHarness::build(Version(0)).finish();
let (client, mut harness) = ClientTestHarness::build().finish();

std::mem::drop(client);

Expand Down
18 changes: 9 additions & 9 deletions zebra-network/src/peer_set/initialize/tests/vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::{
set::MorePeers,
ActiveConnectionCounter, CandidateSet,
},
protocol::{external::types::Version, types::PeerServices},
protocol::types::PeerServices,
AddressBook, BoxError, Config, Request, Response,
};

Expand Down Expand Up @@ -348,7 +348,7 @@ async fn crawler_peer_limit_one_connect_ok_then_drop() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Fake the connection closing.
std::mem::drop(connection_tracker);
Expand Down Expand Up @@ -412,7 +412,7 @@ async fn crawler_peer_limit_one_connect_ok_stay_open() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Make the connection staying open.
peer_tracker_tx
Expand Down Expand Up @@ -523,7 +523,7 @@ async fn crawler_peer_limit_default_connect_ok_then_drop() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Fake the connection closing.
std::mem::drop(connection_tracker);
Expand Down Expand Up @@ -589,7 +589,7 @@ async fn crawler_peer_limit_default_connect_ok_stay_open() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Make the connection staying open.
peer_tracker_tx
Expand Down Expand Up @@ -732,7 +732,7 @@ async fn listener_peer_limit_one_handshake_ok_then_drop() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Actually close the connection.
std::mem::drop(connection_tracker);
Expand Down Expand Up @@ -800,7 +800,7 @@ async fn listener_peer_limit_one_handshake_ok_stay_open() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Make the connection staying open.
peer_tracker_tx
Expand Down Expand Up @@ -920,7 +920,7 @@ async fn listener_peer_limit_default_handshake_ok_then_drop() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Actually close the connection.
std::mem::drop(connection_tracker);
Expand Down Expand Up @@ -988,7 +988,7 @@ async fn listener_peer_limit_default_handshake_ok_stay_open() {
connection_tracker,
} = req;

let (fake_client, _harness) = ClientTestHarness::build(Version(1)).finish();
let (fake_client, _harness) = ClientTestHarness::build().finish();

// Make the connection staying open.
peer_tracker_tx
Expand Down

0 comments on commit fea2247

Please sign in to comment.