Skip to content

Commit

Permalink
WIP add *_survives_downstream_disconnect integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plebhash committed Feb 1, 2025
1 parent eb48675 commit ac0c979
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
14 changes: 14 additions & 0 deletions roles/tests-integration/tests/jd_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,17 @@ async fn jds_should_not_panic_if_jdc_shutsdown() {
let (_jdc, _jdc_addr) = start_jdc(pool_addr, tp_addr, sniffer_addr).await;
assert_common_message!(sniffer.next_message_from_downstream(), SetupConnection);
}

// This test makes sure that JDS will not stop listening after one
// downstream client disconnects
#[tokio::test]
async fn jds_survives_downstream_disconnect() {
todo!()
}

// This test makes sure that JDC will not stop listening after one
// downstream client disconnects
#[tokio::test]
async fn jdc_survives_downstream_disconnect() {
todo!()
}
27 changes: 27 additions & 0 deletions roles/tests-integration/tests/pool_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,30 @@ async fn header_timestamp_value_assertion_in_new_extended_mining_job() {
"The `minntime` field of the second NewExtendedMiningJob does not match the `header_timestamp`!"
);
}

// This test makes sure that Pool will not stop listening after one
// downstream client disconnects
#[tokio::test]
async fn pool_survives_downstream_disconnect() {
let (_tp, tp_addr) = start_template_provider(None).await;
let (pool, pool_addr) = start_pool(Some(tp_addr)).await;

// emulate first downstream
let downstream_a = std::net::TcpStream::connect(pool_addr).unwrap();

// emulate second downstream
let _downstream_b = std::net::TcpStream::connect(pool_addr).unwrap();

// wait a bit to make sure the TCP sockets are processed
tokio::time::sleep(std::time::Duration::from_secs(1)).await;

// kill downstream_a
downstream_a.shutdown(std::net::Shutdown::Both).unwrap();
drop(downstream_a);

// wait a bit to make sure the TCP sockets are processed
tokio::time::sleep(std::time::Duration::from_secs(1)).await;

// pool still listening
assert!(pool.is_listening());
}
28 changes: 28 additions & 0 deletions roles/tests-integration/tests/translator_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,31 @@ async fn translation_proxy() {
)
.await;
}

// This test makes sure that tProxy will not stop listening after one
// downstream client disconnects
#[tokio::test]
async fn tproxy_survives_downstream_disconnect() {
let (_tp, tp_addr) = start_template_provider(None).await;
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
let (tproxy, tproxy_addr) = start_sv2_translator(pool_addr).await;

// emulate first downstream
let downstream_a = std::net::TcpStream::connect(tproxy_addr).unwrap();

// emulate second downstream
let _downstream_b = std::net::TcpStream::connect(tproxy_addr).unwrap();

// wait a bit to make sure the TCP sockets are processed
tokio::time::sleep(std::time::Duration::from_secs(1)).await;

// kill downstream_a
downstream_a.shutdown(std::net::Shutdown::Both).unwrap();
drop(downstream_a);

// wait a bit to make sure the TCP sockets are processed
tokio::time::sleep(std::time::Duration::from_secs(1)).await;

// tproxy still listening
assert!(tproxy.is_listening());
}

0 comments on commit ac0c979

Please sign in to comment.