diff --git a/roles/Cargo.lock b/roles/Cargo.lock index 5f834dd456..6b1bde15c4 100644 --- a/roles/Cargo.lock +++ b/roles/Cargo.lock @@ -271,7 +271,7 @@ checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -315,7 +315,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -686,7 +686,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1043,7 +1043,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1373,9 +1373,9 @@ checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "jd_client" @@ -1837,7 +1837,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1949,9 +1949,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" dependencies = [ "unicode-ident", ] @@ -2213,7 +2213,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2376,9 +2376,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -2434,7 +2434,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2483,7 +2483,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2558,7 +2558,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2647,9 +2647,9 @@ checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-segmentation" @@ -2734,7 +2734,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-shared", ] @@ -2768,7 +2768,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2960,7 +2960,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] diff --git a/roles/tests-integration/tests/common/mod.rs b/roles/tests-integration/tests/common/mod.rs index 782b56ad5e..1a3b8f39a9 100644 --- a/roles/tests-integration/tests/common/mod.rs +++ b/roles/tests-integration/tests/common/mod.rs @@ -405,9 +405,9 @@ 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(3) as f32 / 20.0; let min_individual_miner_hashrate = hashrate; - let shares_per_minute = 60.0; + let shares_per_minute = 100.0; let channel_diff_update_interval = 60; let channel_nominal_hashrate = hashrate; let downstream_difficulty_config = diff --git a/roles/tests-integration/tests/common/sniffer.rs b/roles/tests-integration/tests/common/sniffer.rs index 985f1ba92f..6b46a137f0 100644 --- a/roles/tests-integration/tests/common/sniffer.rs +++ b/roles/tests-integration/tests/common/sniffer.rs @@ -519,7 +519,7 @@ macro_rules! assert_mining_message { assert_message!(Mining, Mining, $msg, $expected_message_variant, $($expected_property, $expected_property_value),*); }; ($msg:expr, $expected_message_variant:ident) => { - assert_message!(Mining, Mining, $msg, $expected_message_variant); + assert_message!(Mining, Mining, $msg, $expected_message_variant); }; } diff --git a/roles/tests-integration/tests/pool_integration.rs b/roles/tests-integration/tests/pool_integration.rs index 6230d43249..09c33d3e18 100644 --- a/roles/tests-integration/tests/pool_integration.rs +++ b/roles/tests-integration/tests/pool_integration.rs @@ -1,13 +1,14 @@ mod common; -use std::convert::TryInto; +use std::{convert::TryInto, time::Duration}; use common::{InterceptMessage, MessageDirection}; use const_sv2::MESSAGE_TYPE_SETUP_CONNECTION_ERROR; use roles_logic_sv2::{ common_messages_sv2::{Protocol, SetupConnection, SetupConnectionError}, - parsers::{CommonMessages, PoolMessages, TemplateDistribution}, + parsers::{CommonMessages, Mining, PoolMessages, TemplateDistribution}, }; +use tokio::time::sleep; // This test starts a Template Provider and a Pool, and checks if they exchange the correct // messages upon connection. @@ -94,3 +95,61 @@ async fn test_sniffer_interrupter() { assert_common_message!(&sniffer.next_message_from_downstream(), SetupConnection); assert_common_message!(&sniffer.next_message_from_upstream(), SetupConnectionError); } + +// covers +// https://github.com/stratum-mining/stratum/blob/main/test/message-generator/test/translation-proxy/translation-proxy.json +#[tokio::test] +async fn translation_proxy() { + let pool_jdc_sniffer_addr = common::get_available_address(); + let tp_addr = common::get_available_address(); + let pool_addr = common::get_available_address(); + + let pool_jdc_sniffer = common::start_sniffer( + "0".to_string(), + pool_jdc_sniffer_addr, + pool_addr, + false, + None, + ) + .await; + let _tp = common::start_template_provider(tp_addr.port()).await; + let _pool_1 = common::start_pool(Some(pool_addr), Some(tp_addr)).await; + let jds_addr = common::start_jds(tp_addr).await; + let jdc_addr = common::start_jdc(pool_jdc_sniffer_addr, tp_addr, jds_addr).await; + let mining_proxy_addr = common::start_sv2_translator(jdc_addr).await; + let _ = common::start_mining_device_sv1(mining_proxy_addr).await; + sleep(Duration::from_secs(3)).await; + + assert_common_message!( + &pool_jdc_sniffer.next_message_from_downstream(), + SetupConnection + ); + assert_common_message!( + &pool_jdc_sniffer.next_message_from_upstream(), + SetupConnectionSuccess + ); + assert_mining_message!( + &pool_jdc_sniffer.next_message_from_downstream(), + OpenExtendedMiningChannel + ); + assert_mining_message!( + &pool_jdc_sniffer.next_message_from_upstream(), + OpenExtendedMiningChannelSuccess + ); + assert_mining_message!( + &pool_jdc_sniffer.next_message_from_upstream(), + NewExtendedMiningJob + ); + assert_mining_message!( + &pool_jdc_sniffer.next_message_from_downstream(), + SetCustomMiningJob + ); + assert_mining_message!( + &pool_jdc_sniffer.next_message_from_upstream(), + SetNewPrevHash + ); + assert_mining_message!( + &pool_jdc_sniffer.next_message_from_downstream(), + SubmitSharesExtended + ); +}