Skip to content

Commit b12e62c

Browse files
committed
Test JDC pool fallback functionality
1 parent 308e280 commit b12e62c

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use const_sv2::{MESSAGE_TYPE_SETUP_CONNECTION, MESSAGE_TYPE_SUBMIT_SHARES_SUCCESS};
2+
use integration_tests_sv2::*;
3+
use roles_logic_sv2::{
4+
mining_sv2::SubmitSharesError,
5+
parsers::{AnyMessage, CommonMessages, Mining},
6+
};
7+
use sniffer::{InterceptMessage, MessageDirection};
8+
use std::convert::TryInto;
9+
10+
// Start JDC with two pools in the pool list config. The test forces the first pool to send a share
11+
// submission rejection by altering a message(MINING_SET_NEW_PREV_HASH) sent by the pool. The test
12+
// verifies that the second pool will be used as a fallback.
13+
#[tokio::test]
14+
async fn test_jdc_pool_fallback_after_submit_rejection() {
15+
start_tracing();
16+
let (tp, tp_addr) = start_template_provider(None);
17+
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
18+
let (sniffer_1, sniffer_addr) = start_sniffer(
19+
"0".to_string(),
20+
pool_addr,
21+
false,
22+
Some(vec![InterceptMessage::new(
23+
MessageDirection::ToDownstream,
24+
MESSAGE_TYPE_SUBMIT_SHARES_SUCCESS,
25+
AnyMessage::Mining(Mining::SubmitSharesError(SubmitSharesError {
26+
channel_id: 0,
27+
sequence_number: 0,
28+
error_code: "invalid-nonce".to_string().into_bytes().try_into().unwrap(),
29+
})),
30+
)]),
31+
)
32+
.await;
33+
let (_pool_2, pool_addr_2) = start_pool(Some(tp_addr)).await;
34+
let (sniffer_2, sniffer_addr_2) =
35+
start_sniffer("1".to_string(), pool_addr_2, false, None).await;
36+
let (_jds, jds_addr) = start_jds(tp.rpc_info()).await;
37+
let (_jdc, jdc_addr) = start_jdc(&[sniffer_addr, sniffer_addr_2], tp_addr, jds_addr).await;
38+
assert_common_message!(&sniffer_1.next_message_from_downstream(), SetupConnection);
39+
let (_translator, sv2_translator_addr) = start_sv2_translator(jdc_addr).await;
40+
let _ = start_mining_device_sv1(sv2_translator_addr, true, None).await;
41+
sniffer_2
42+
.wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION)
43+
.await;
44+
}

0 commit comments

Comments
 (0)