Skip to content

Commit 7bd9bdf

Browse files
committed
WIP add *_survives_downstream_disconnect integration tests
1 parent 6013b20 commit 7bd9bdf

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

roles/tests-integration/tests/jd_integration.rs

+14
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,17 @@ async fn jds_should_not_panic_if_jdc_shutsdown() {
3535
let (_jdc, _jdc_addr) = start_jdc(pool_addr, tp_addr, sniffer_addr).await;
3636
assert_common_message!(sniffer.next_message_from_downstream(), SetupConnection);
3737
}
38+
39+
// This test makes sure that JDS will not stop listening after one
40+
// downstream client disconnects
41+
#[tokio::test]
42+
async fn jds_survives_downstream_disconnect() {
43+
todo!()
44+
}
45+
46+
// This test makes sure that JDC will not stop listening after one
47+
// downstream client disconnects
48+
#[tokio::test]
49+
async fn jdc_survives_downstream_disconnect() {
50+
todo!()
51+
}

roles/tests-integration/tests/pool_integration.rs

+27
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,30 @@ async fn header_timestamp_value_assertion_in_new_extended_mining_job() {
122122
"The `minntime` field of the second NewExtendedMiningJob does not match the `header_timestamp`!"
123123
);
124124
}
125+
126+
// This test makes sure that Pool will not stop listening after one
127+
// downstream client disconnects
128+
#[tokio::test]
129+
async fn pool_survives_downstream_disconnect() {
130+
let (_tp, tp_addr) = start_template_provider(None).await;
131+
let (pool, pool_addr) = start_pool(Some(tp_addr)).await;
132+
133+
// emulate first downstream
134+
let downstream_a = std::net::TcpStream::connect(pool_addr).unwrap();
135+
136+
// emulate second downstream
137+
let _downstream_b = std::net::TcpStream::connect(pool_addr).unwrap();
138+
139+
// wait a bit to make sure the TCP sockets are processed
140+
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
141+
142+
// kill downstream_a
143+
downstream_a.shutdown(std::net::Shutdown::Both).unwrap();
144+
drop(downstream_a);
145+
146+
// wait a bit to make sure the TCP sockets are processed
147+
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
148+
149+
// pool still listening
150+
assert!(pool.is_listening());
151+
}

roles/tests-integration/tests/translator_integration.rs

+28
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,31 @@ async fn translation_proxy() {
4444
)
4545
.await;
4646
}
47+
48+
// This test makes sure that tProxy will not stop listening after one
49+
// downstream client disconnects
50+
#[tokio::test]
51+
async fn tproxy_survives_downstream_disconnect() {
52+
let (_tp, tp_addr) = start_template_provider(None).await;
53+
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
54+
let (tproxy, tproxy_addr) = start_sv2_translator(pool_addr).await;
55+
56+
// emulate first downstream
57+
let downstream_a = std::net::TcpStream::connect(tproxy_addr).unwrap();
58+
59+
// emulate second downstream
60+
let _downstream_b = std::net::TcpStream::connect(tproxy_addr).unwrap();
61+
62+
// wait a bit to make sure the TCP sockets are processed
63+
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
64+
65+
// kill downstream_a
66+
downstream_a.shutdown(std::net::Shutdown::Both).unwrap();
67+
drop(downstream_a);
68+
69+
// wait a bit to make sure the TCP sockets are processed
70+
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
71+
72+
// tproxy still listening
73+
assert!(tproxy.is_listening());
74+
}

0 commit comments

Comments
 (0)