Skip to content

Commit

Permalink
Test Translator, JD and miner setup
Browse files Browse the repository at this point in the history
.. Tests that when a miner submits shares to translator it is propagated
up to the pool by JD.
  • Loading branch information
jbesraa committed Feb 12, 2025
1 parent 76afdc5 commit 139b1f7
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions roles/tests-integration/tests/translator_integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use const_sv2::{MESSAGE_TYPE_SETUP_CONNECTION, MESSAGE_TYPE_SUBMIT_SHARES_EXTENDED};
use const_sv2::{
MESSAGE_TYPE_MINING_SET_NEW_PREV_HASH, MESSAGE_TYPE_SETUP_CONNECTION,
MESSAGE_TYPE_SUBMIT_SHARES_EXTENDED,
};
use integration_tests_sv2::{sniffer::*, *};
use roles_logic_sv2::parsers::{CommonMessages, Mining, PoolMessages};

Expand All @@ -13,7 +16,7 @@ async fn translation_proxy() {
let (pool_translator_sniffer, pool_translator_sniffer_addr) =
start_sniffer("0".to_string(), pool_addr, false, None).await;
let (_, tproxy_addr) = start_sv2_translator(pool_translator_sniffer_addr).await;
let _mining_device = start_mining_device_sv1(tproxy_addr).await;
let _mining_device = start_mining_device_sv1(tproxy_addr, false).await;
pool_translator_sniffer
.wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION)
.await;
Expand Down Expand Up @@ -44,3 +47,53 @@ async fn translation_proxy() {
)
.await;
}

// Test full flow with Translator and Job Declarator. An SV1 mining device is connected to
// Translator and is successfully submitting shares to the pool. It also asserts that Pool role
// sends a subsequent `SET_NEW_PREV_HASH`.
#[tokio::test]
async fn translation_proxy_and_jd() {
let (_tp, tp_addr) = start_template_provider(None).await;
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
let (jdc_pool_sniffer, pool_translator_sniffer_addr) =
start_sniffer("0".to_string(), pool_addr, false, None).await;
let (_jds, jds_addr) = start_jds(tp_addr).await;
let (_jdc, jdc_addr) = start_jdc(pool_translator_sniffer_addr, tp_addr, jds_addr).await;
let (_translator, tproxy_addr) = start_sv2_translator(jdc_addr).await;
let _mining_device = start_mining_device_sv1(tproxy_addr, true).await;
jdc_pool_sniffer
.wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION)
.await;
assert_common_message!(
&jdc_pool_sniffer.next_message_from_downstream(),
SetupConnection
);
assert_common_message!(
&jdc_pool_sniffer.next_message_from_upstream(),
SetupConnectionSuccess
);
assert_mining_message!(
&jdc_pool_sniffer.next_message_from_downstream(),
OpenExtendedMiningChannel
);
assert_mining_message!(
&jdc_pool_sniffer.next_message_from_upstream(),
OpenExtendedMiningChannelSuccess
);
assert_mining_message!(
&jdc_pool_sniffer.next_message_from_upstream(),
NewExtendedMiningJob
);
jdc_pool_sniffer
.wait_for_message_type(
MessageDirection::ToUpstream,
MESSAGE_TYPE_SUBMIT_SHARES_EXTENDED,
)
.await;
jdc_pool_sniffer
.wait_for_message_type(
MessageDirection::ToDownstream,
MESSAGE_TYPE_MINING_SET_NEW_PREV_HASH,
)
.await;
}

0 comments on commit 139b1f7

Please sign in to comment.