Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate tproxy MG test in integration tests #1262

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion roles/tests-integration/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ pub async fn start_sv2_translator(upstream: SocketAddr) -> SocketAddr {
.expect("failed");
let listening_address = get_available_address();
let listening_port = listening_address.port();
let hashrate = measure_hashrate(3) as f32 / 100.0;
let hashrate = measure_hashrate(1) as f32 / 100.0;
plebhash marked this conversation as resolved.
Show resolved Hide resolved
let min_individual_miner_hashrate = hashrate;
let shares_per_minute = 60.0;
let channel_diff_update_interval = 60;
Expand Down
57 changes: 57 additions & 0 deletions roles/tests-integration/tests/translator_integration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
mod common;

use common::MessageDirection;
use const_sv2::{MESSAGE_TYPE_SETUP_CONNECTION, MESSAGE_TYPE_SUBMIT_SHARES_EXTENDED};
use roles_logic_sv2::parsers::{CommonMessages, Mining, PoolMessages};

// This test runs an sv2 translator between an sv1 mining device and a pool. the connection between
// the translator and the pool is intercepted by a sniffer. The test checks if the translator and
// the pool exchange the correct messages upon connection. And that the miner is able to submit
// shares.
#[tokio::test]
async fn translation_proxy() {
let pool_translator_sniffer_addr = common::get_available_address();
let tp_addr = common::get_available_address();
let pool_addr = common::get_available_address();
let pool_translator_sniffer = common::start_sniffer(
"0".to_string(),
pool_translator_sniffer_addr,
pool_addr,
false,
None,
)
.await;
let _tp = common::start_template_provider(tp_addr.port()).await;
let _pool = common::start_pool(Some(pool_addr), Some(tp_addr)).await;
let tproxy_addr = common::start_sv2_translator(pool_translator_sniffer_addr).await;
let _mining_device = common::start_mining_device_sv1(tproxy_addr).await;
pool_translator_sniffer
.wait_for_message_type(MessageDirection::ToUpstream, MESSAGE_TYPE_SETUP_CONNECTION)
.await;
assert_common_message!(
&pool_translator_sniffer.next_message_from_downstream(),
SetupConnection
);
assert_common_message!(
&pool_translator_sniffer.next_message_from_upstream(),
SetupConnectionSuccess
);
assert_mining_message!(
&pool_translator_sniffer.next_message_from_downstream(),
OpenExtendedMiningChannel
);
assert_mining_message!(
&pool_translator_sniffer.next_message_from_upstream(),
OpenExtendedMiningChannelSuccess
);
assert_mining_message!(
&pool_translator_sniffer.next_message_from_upstream(),
NewExtendedMiningJob
);
pool_translator_sniffer
.wait_for_message_type(
MessageDirection::ToUpstream,
MESSAGE_TYPE_SUBMIT_SHARES_EXTENDED,
)
.await;
}
Loading