Skip to content

Commit

Permalink
Merge pull request #1354 from jbesraa/2025-01-16-translator-jd-test
Browse files Browse the repository at this point in the history
Test Translator, JD and miner setup
  • Loading branch information
plebhash authored Feb 28, 2025
2 parents 637ed1e + 844fd05 commit 6dde6b9
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 637 deletions.
36 changes: 1 addition & 35 deletions .github/workflows/mg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ on:
- main

jobs:
interop-jd-translator:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run interop-jd-translator
run: sh ./test/message-generator/test/interop-jd-translator/interop-jd-translator.sh

interop-proxy-with-multi-ups:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -76,26 +68,6 @@ jobs:
- name: Run pool-sri-test-close-channel
run: sh ./test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.sh

pool-sri-test-extended_0:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Run pool-sri-test-extended_0
run: sh ./test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.sh

pool-sri-test-extended_1:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
- name: Run pool-sri-test-extended_1
run: sh ./test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.sh

sv1-test:
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down Expand Up @@ -126,33 +98,27 @@ jobs:
runs-on: ubuntu-latest
if: always()
needs: [
interop-jd-translator,
interop-proxy-with-multi-ups,
interop-proxy-with-multi-ups-extended,
jds-do-not-fail-on-wrong-tsdatasucc,
jds-do-not-stackoverflow-when-no-token,
jds-receive-solution-while-processing-declared-job,
pool-sri-test-1-standard,
pool-sri-test-close-channel,
pool-sri-test-extended_0,
pool-sri-test-extended_1,
sv1-test,
translation-proxy-broke-pool,
translation-proxy-old-share
]
steps:
- name: Aggregate Results
run: |
if [ "${{ needs.interop-jd-translator.result }}" != "success" ] ||
[ "${{ needs.interop-proxy-with-multi-ups.result }}" != "success" ] ||
if [ "${{ needs.interop-proxy-with-multi-ups.result }}" != "success" ] ||
[ "${{ needs.interop-proxy-with-multi-ups-extended.result }}" != "success" ] ||
[ "${{ needs.jds-do-not-fail-on-wrong-tsdatasucc.result }}" != "success" ] ||
[ "${{ needs.jds-do-not-stackoverflow-when-no-token.result }}" != "success" ] ||
[ "${{ needs.jds-receive-solution-while-processing-declared-job.result }}" != "success" ] ||
[ "${{ needs.pool-sri-test-1-standard.result }}" != "success" ] ||
[ "${{ needs.pool-sri-test-close-channel.result }}" != "success" ] ||
[ "${{ needs.pool-sri-test-extended_0.result }}" != "success" ] ||
[ "${{ needs.pool-sri-test-extended_1.result }}" != "success" ] ||
[ "${{ needs.sv1-test.result }}" != "success" ] ||
[ "${{ needs.translation-proxy-broke-pool.result }}" != "success" ] ||
[ "${{ needs.translation-proxy-old-share.result }}" != "success" ]; then
Expand Down
1 change: 1 addition & 0 deletions roles/tests-integration/tests/jd_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use sniffer::MessageDirection;
// starting a new jd-client that connects to the same jd-server successfully.
#[tokio::test]
async fn jds_should_not_panic_if_jdc_shutsdown() {
start_tracing();
let (tp, tp_addr) = start_template_provider(None);
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
let (_jds, jds_addr) = start_jds(tp.rpc_info()).await;
Expand Down
54 changes: 53 additions & 1 deletion roles/tests-integration/tests/translator_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
//
// Note that it is enough to call `start_tracing()` once in the test suite to enable tracing for
// all tests. This is because tracing is a global setting.
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, MESSAGE_TYPE_SUBMIT_SHARES_SUCCESS,
};
use integration_tests_sv2::{sniffer::*, *};
use roles_logic_sv2::parsers::{CommonMessages, Mining, PoolMessages};

Expand Down Expand Up @@ -51,3 +54,52 @@ async fn translate_sv1_to_sv2_successfully() {
)
.await;
}

// Test full flow with Translator and Job Declarator. An SV1 mining device is connected to
// Translator and is successfully submitting a share to the pool.
#[tokio::test]
async fn translation_proxy_and_jd() {
let (tp, tp_addr) = start_template_provider(None);
let (_pool, pool_addr) = start_pool(Some(tp_addr)).await;
let (jdc_pool_sniffer, jdc_pool_sniffer_addr) =
start_sniffer("0".to_string(), pool_addr, false, None).await;
let (_jds, jds_addr) = start_jds(tp.rpc_info()).await;
let (_jdc, jdc_addr) = start_jdc(jdc_pool_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, None).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_SUBMIT_SHARES_SUCCESS,
)
.await;
}
65 changes: 0 additions & 65 deletions test/config/interop-jd-translator/jdc-config.toml

This file was deleted.

20 changes: 0 additions & 20 deletions test/config/interop-jd-translator/jds-config.toml

This file was deleted.

34 changes: 0 additions & 34 deletions test/config/interop-jd-translator/proxy-config.toml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ coinbase_outputs = [
#{ output_script_type = "P2WPKH", output_script_value = "02e13cef1348924c49dd1f708bf38eb79ae4648c16f0301085f37547d1d25e33e0" },
#{ output_script_type = "P2TR", output_script_value = "02e13cef1348924c49dd1f708bf38eb79ae4648c16f0301085f37547d1d25e33e0" },
]
# Pool signature (string to be included in coinbase tx)
# Pool signature (string to be included in coinbase tx)
# e.g. "Foundry USA", "Antpool", "/ViaBTC/Mined by gitgab19", etc
pool_signature = "Stratum v2 SRI Pool - gitgab19"

# Template Provider config
# hosted testnet TP
# hosted testnet TP
tp_address = "75.119.150.111:8442"
Loading

0 comments on commit 6dde6b9

Please sign in to comment.