diff --git a/.github/workflows/auto-rebase.yaml b/.github/workflows/auto-rebase.yaml deleted file mode 100644 index 6e635ffbac..0000000000 --- a/.github/workflows/auto-rebase.yaml +++ /dev/null @@ -1,77 +0,0 @@ -name: Auto Rebase - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - rebase-outdated-prs: - runs-on: ubuntu-latest - steps: - - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.PAT }} - fetch-depth: 0 # Fetch full history to have the entire commit history - - - name: Fetch open pull requests with label - run: | - gh auth setup-git - gh pr list --state open --label "ready-to-be-merged" --json number,headRepositoryOwner,headRefName --jq '.[] | "\(.number) \(.headRepositoryOwner.login) \(.headRefName)"' > pr_details.txt - env: - GITHUB_TOKEN: ${{ secrets.PAT }} - - - name: Rebase pull requests - run: | - while read pr_number pr_owner pr_branch; do - echo "Processing PR #$pr_number" - - # Add the contributor's fork as a remote - git remote add contributor https://github.com/$pr_owner/$(gh repo view --json name -q '.name').git - - # Fetch the contributor's branches - git fetch contributor - - # Create a unique branch name for this PR - unique_branch_name="contributor-branch-$pr_number" - - # Checkout the branch from the contributor's fork - git checkout -b $unique_branch_name contributor/$pr_branch - - # Set the committer name and email to match the PR author - PR_AUTHOR_NAME=$(gh pr view $pr_number --json author --jq '.author.login') - PR_AUTHOR_EMAIL="${PR_AUTHOR_NAME}@users.noreply.github.com" - - git config --global user.name "$PR_AUTHOR_NAME" - git config --global user.email "$PR_AUTHOR_EMAIL" - - # Rebase the branch on top of the main branch - git fetch origin main - if ! git rebase origin/main; then - echo "Conflict detected. Aborting rebase and continuing." - git rebase --abort - - # Post a comment on the PR to notify the author about the conflict - gh pr comment $pr_number --body "Hey @$PR_AUTHOR_NAME, your PR cannot be rebased due to conflicts. Could you resolve them, please?" - - continue - fi - - # Push the rebased branch back to the contributor's fork - git push --force-with-lease contributor $unique_branch_name:$pr_branch - - # Remove the remote - git remote remove contributor - - # Ensure we are not on the branch to be deleted - git checkout main - - # Delete the local unique branch - git branch -D $unique_branch_name - - done < pr_details.txt - env: - GITHUB_TOKEN: ${{ secrets.PAT }} \ No newline at end of file diff --git a/.github/workflows/clippy-lint.yaml b/.github/workflows/clippy-lint.yaml deleted file mode 100644 index 32fe5cf829..0000000000 --- a/.github/workflows/clippy-lint.yaml +++ /dev/null @@ -1,37 +0,0 @@ -on: - pull_request: - branches: - - main - -name: Clippy Lint - -jobs: - clippy-check: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - include: - - os: macos-latest - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: 1.75.0 - override: true - components: clippy - - name: Run Clippy on different workspaces and crates - run: | - cargo clippy --manifest-path=benches/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=common/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=protocols/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=roles/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=utils/Cargo.toml -- -D warnings -A dead-code - cargo clippy --manifest-path=utils/message-generator/Cargo.toml -- -D warnings -A dead-code diff --git a/.github/workflows/coverage-protocols.yaml b/.github/workflows/coverage-protocols.yaml deleted file mode 100644 index bb4e1e02ac..0000000000 --- a/.github/workflows/coverage-protocols.yaml +++ /dev/null @@ -1,135 +0,0 @@ -name: Protocol test Coverage - -on: - pull_request: - branches: - - main - -jobs: - protocols-coverage: - - name: tarpaulin Test - runs-on: ubuntu-latest - container: - image: xd009642/tarpaulin:0.27.1-nightly - options: --security-opt seccomp=unconfined - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Generate code coverage - run: | - ./scripts/coverage-protocols.sh - - - name: Upload protocols coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports - file: ./protocols/target/tarpaulin-reports/cobertura.xml - flags: protocols - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload binary_codec_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/codec-coverage - file: ./protocols/target/tarpaulin-reports/codec-coverage/cobertura.xml - flags: binary_codec_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload binary_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/binary-sv2-coverage - file: ./protocols/target/tarpaulin-reports/binary-sv2-coverage/cobertura.xml - flags: binary_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload codec_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/codec-sv2-coverage - file: ./protocols/target/tarpaulin-reports/codec-sv2-coverage/cobertura.xml - flags: codec_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload common_messages_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/common-messages-coverage - file: ./protocols/target/tarpaulin-reports/common-messages-coverage/cobertura.xml - flags: common_messages_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload const_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/const-sv2-coverage - file: ./protocols/target/tarpaulin-reports/const-sv2-coverage/cobertura.xml - flags: const_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload framing_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/framing-sv2-coverage - file: ./protocols/target/tarpaulin-reports/framing-sv2-coverage/cobertura.xml - flags: framing_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload job_declaration_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/job-declaration-coverage - file: ./protocols/target/tarpaulin-reports/job-declaration-coverage/cobertura.xml - flags: job_declaration_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - - name: Upload noise_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/noise-sv2-coverage - file: ./protocols/target/tarpaulin-reports/noise-sv2-coverage/cobertura.xml - flags: noise_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload roles_logic_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/roles-logic-sv2-coverage - file: ./protocols/target/tarpaulin-reports/roles-logic-sv2-coverage/cobertura.xml - flags: roles_logic_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload v1-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/v1-coverage - file: ./protocols/target/tarpaulin-reports/v1-coverage/cobertura.xml - flags: v1-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload sv2_ffi-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/sv2-ffi-coverage - file: ./protocols/target/tarpaulin-reports/sv2-ffi-coverage/cobertura.xml - flags: sv2_ffi-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload template_distribution_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/template-distribution-coverage - file: ./protocols/target/tarpaulin-reports/template-distribution-coverage/cobertura.xml - flags: template_distribution_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload mining-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./protocols/target/tarpaulin-reports/mining-coverage - file: ./protocols/target/tarpaulin-reports/mining-coverage/cobertura.xml - flags: mining-coverage - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/coverage-roles.yaml b/.github/workflows/coverage-roles.yaml deleted file mode 100644 index 33e7497bb6..0000000000 --- a/.github/workflows/coverage-roles.yaml +++ /dev/null @@ -1,86 +0,0 @@ -name: Roles test Coverage - -on: - pull_request: - branches: - - main - -jobs: - roles-coverage: - - name: tarpaulin Test - runs-on: ubuntu-latest - container: - image: xd009642/tarpaulin:0.27.1-nightly - options: --security-opt seccomp=unconfined - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Generate code coverage - run: | - ./scripts/coverage-roles.sh - - - name: Upload roles coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports - file: ./roles/target/tarpaulin-reports/cobertura.xml - flags: roles - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload jd_client-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/jd-client-coverage - file: ./roles/target/tarpaulin-reports/jd-client-coverage/cobertura.xml - flags: jd_client-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload jd_server-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/jd-server-coverage - file: ./roles/target/tarpaulin-reports/jd-server-coverage/cobertura.xml - flags: jd_server-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload mining_device-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/mining-device-coverage - file: ./rroles/target/tarpaulin-reports/mining-device-coverage/cobertura.xml - flags: mining_device-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload mining_proxy_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/mining-proxy-coverage - file: ./roles/target/tarpaulin-reports/mining-proxy-coverage/cobertura.xml - flags: mining_proxy_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload pool_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/pool-coverage - file: ./roles/target/tarpaulin-reports/pool-coverage/cobertura.xml - flags: pool_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload sv1-mining-device-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/sv1-mining-device-coverage - file: ./roles/target/tarpaulin-reports/sv1-mining-device-coverage/cobertura.xml - flags: sv1-mining-device-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload translator_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./roles/target/tarpaulin-reports/translator-coverage - file: ./roles/target/tarpaulin-reports/translator-coverage/cobertura.xml - flags: translator_sv2-coverage - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/coverage-utils.yaml b/.github/workflows/coverage-utils.yaml deleted file mode 100644 index 1b6c0156d0..0000000000 --- a/.github/workflows/coverage-utils.yaml +++ /dev/null @@ -1,63 +0,0 @@ -name: Util Test Coverage - -on: - pull_request: - branches: - - main - -jobs: - utils-coverage: - - name: tarpaulin Test - runs-on: ubuntu-latest - container: - image: xd009642/tarpaulin:0.27.1-nightly - options: --security-opt seccomp=unconfined - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Generate code coverage - run: | - ./scripts/coverage-utils.sh - - - name: Upload utils coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./utils/target/tarpaulin-reports - file: ./utils/target/tarpaulin-reports/cobertura.xml - flags: utils - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload bip32_derivation-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./utils/target/tarpaulin-reports/bip32-key-derivation-coverage - file: ./utils/target/tarpaulin-reports/bip32-key-derivation-coverage/cobertura.xml - flags: bip32_derivation-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload buffer_sv2-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./utils/target/tarpaulin-reports/buffer-coverage - file: ./utils/target/tarpaulin-reports/buffer-coverage/cobertura.xml - flags: buffer_sv2-coverage - - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload error_handling-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./utils/target/tarpaulin-reports/error-handling-coverage - file: ./utils/target/tarpaulin-reports/error-handling-coverage/cobertura.xml - flags: error_handling-coverage - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Upload key-utils-coverage to codecov.io - uses: codecov/codecov-action@v4 - with: - directory: ./utils/target/tarpaulin-reports/key-utils-coverage - file: ./utils/target/tarpaulin-reports/key-utils-coverage/cobertura.xml - flags: key-utils-coverage - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml deleted file mode 100644 index 67ff3f146d..0000000000 --- a/.github/workflows/docs.yaml +++ /dev/null @@ -1,106 +0,0 @@ -# Enforces Rust Docs sanity (protocols crates only) -# If `cargo doc --all-features` fails for one crate, the entire workflow fails - -name: Rust Docs - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - cargo-doc-all-features: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Rust Docs crate common - run: | - cd common - cargo doc - - - name: Rust Docs crate buffer_sv2 - run: | - cd utils/buffer - cargo doc - - - name: Rust Docs crate binary_sv2 derive_codec - run: | - cd protocols/v2/binary-sv2/derive_codec - cargo doc - - - name: Rust Docs crate binary_sv2 codec - run: | - cd protocols/v2/binary-sv2/codec - cargo doc --features with_buffer_pool - - - name: Rust Docs crate binary_sv2 - run: | - cd protocols/v2/binary-sv2 - cargo doc --features with_buffer_pool - - - name: Rust Docs crate const_sv2 - run: | - cd protocols/v2/const-sv2 - cargo doc - - - name: Rust Docs crate framing_sv2 - run: | - cd protocols/v2/framing-sv2 - cargo doc --features with_buffer_pool - - - name: Rust Docs crate noise_sv2 - run: | - cd protocols/v2/noise-sv2 - cargo doc --features std - - - name: Rust Docs crate codec_sv2 - run: | - cd protocols/v2/codec-sv2 - cargo doc --features with_buffer_pool,noise_sv2 - - - name: Rust Docs crate common_messages - run: | - cd protocols/v2/subprotocols/common-messages - cargo doc - - - name: Rust Docs crate job_declaration - run: | - cd protocols/v2/subprotocols/job-declaration - cargo doc --all-features - - - name: Rust Docs crate mining - run: | - cd protocols/v2/subprotocols/mining - cargo doc --all-features - - - name: Rust Docs crate template_distribution - run: | - cd protocols/v2/subprotocols/template-distribution - cargo doc - - - name: Rust Docs crate sv2_ffi - run: | - cd protocols/v2/sv2-ffi - cargo doc - - - name: Rust Docs crate roles_logic_sv2 - - run: | - cd protocols/v2/roles-logic-sv2 - cargo doc - - - name: Rust Docs crate sv1_api - run: | - cd protocols/v1 - cargo doc \ No newline at end of file diff --git a/.github/workflows/fmt.yaml b/.github/workflows/fmt.yaml deleted file mode 100644 index e037492c9e..0000000000 --- a/.github/workflows/fmt.yaml +++ /dev/null @@ -1,37 +0,0 @@ -on: - pull_request: - branches: - - main - -name: Rustfmt - -jobs: - fmt: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - include: - - os: macos-latest - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - override: true - components: rustfmt - - name: Run fmt in different workspaces and crates - run: | - cargo fmt --all --manifest-path=benches/Cargo.toml -- --check - cargo fmt --all --manifest-path=common/Cargo.toml -- --check - cargo fmt --all --manifest-path=protocols/Cargo.toml -- --check - cargo fmt --all --manifest-path=roles/Cargo.toml -- --check - cargo fmt --all --manifest-path=utils/Cargo.toml -- --check - cargo fmt --all --manifest-path=utils/message-generator/Cargo.toml -- --check diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml deleted file mode 100644 index 44f98e2e9e..0000000000 --- a/.github/workflows/integration-tests.yaml +++ /dev/null @@ -1,29 +0,0 @@ -on: - pull_request: - branches: - - main - -name: Integration Tests - -jobs: - ci: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - steps: - - name: Use stable toolchain - uses: actions/checkout@v4 - with: - profile: minimal - toolchain: stable - override: true - - - name: Roles Integration Tests - run: | - RUST_LOG=debug cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture diff --git a/.github/workflows/lockfiles.yaml b/.github/workflows/lockfiles.yaml deleted file mode 100644 index e1451ec88d..0000000000 --- a/.github/workflows/lockfiles.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Lockfiles - -# Trigger the workflow on pull request events for the main branch -on: - pull_request: - branches: - - main - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Build with locked dependencies - run: | - cargo build --manifest-path=roles/Cargo.toml --locked - cargo build --manifest-path=utils/Cargo.toml --locked \ No newline at end of file diff --git a/.github/workflows/mg.yaml b/.github/workflows/mg.yaml deleted file mode 100644 index 13c37f4865..0000000000 --- a/.github/workflows/mg.yaml +++ /dev/null @@ -1,163 +0,0 @@ -# Runs all Message Generator tests in separate jobs - -name: MG Test - -on: - pull_request: - branches: - - 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: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run interop-proxy-with-multi-ups - run: sh ./test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.sh - - interop-proxy-with-multi-ups-extended: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run interop-proxy-with-multi-ups-extended - run: sh ./test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.sh - - jds-do-not-fail-on-wrong-tsdatasucc: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run jds-do-not-fail-on-wrong-tsdatasucc - run: sh ./test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.sh - - jds-do-not-stackoverflow-when-no-token: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run jds-do-not-stackoverflow-when-no-token - run: sh ./test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.sh - - jds-receive-solution-while-processing-declared-job: - 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 jds-receive-solution-while-processing-declared-job - run: sh ./test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.sh - - pool-sri-test-1-standard: - 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-1-standard - run: sh ./test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.sh - - pool-sri-test-close-channel: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - 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 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run sv1-test - run: sh ./test/message-generator/test/sv1-test/sv1-test.sh - - translation-proxy-broke-pool: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run translation-proxy-broke-pool - run: sh ./test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.sh - - translation-proxy-old-share: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Run translation-proxy-old-share - run: sh ./test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.sh - - mg-aggregate-results: - name: "Aggregate MG Test Results" - 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" ] || - [ "${{ 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 - echo "One or more jobs failed." - exit 1 - else - echo "All MG tests completed successfully" - fi diff --git a/.github/workflows/release-libs.yaml b/.github/workflows/release-libs.yaml deleted file mode 100644 index 48f5a27e96..0000000000 --- a/.github/workflows/release-libs.yaml +++ /dev/null @@ -1,114 +0,0 @@ -# This workflow is used to publish SV2 crates to crates.io -# the workflow tries to publish all the library crates by running scripts/release-libs.sh -# in case the `cargo publish` command fails, the script returns 1 and the entire workflow fails -# the only exception is when the `cargo publish` command fails because the crate has already -# been published, in which case the workflow continues - -name: Release Libs - -on: - # Manually run by going to "Actions/Release" in Github and running the workflow - workflow_dispatch: - # every time a new release tag is created - push: - tags: - - "v*.*.*" - -jobs: - libs_publish: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.75.0 - override: true - - name: Login - run: cargo login ${{ secrets.CRATES_IO_DEPLOY_KEY }} - - - name: Publish crate common - run: | - ./scripts/release-libs.sh common - - - name: Publish crate buffer_sv2 - run: | - ./scripts/release-libs.sh utils/buffer - - - name: Publish crate binary_sv2 derive_codec - run: | - ./scripts/release-libs.sh protocols/v2/binary-sv2/derive_codec - - - name: Publish crate binary_sv2 codec - run: | - ./scripts/release-libs.sh protocols/v2/binary-sv2/codec - - - name: Publish crate binary_sv2 - run: | - ./scripts/release-libs.sh protocols/v2/binary-sv2 - - - name: Publish crate const_sv2 - run: | - ./scripts/release-libs.sh protocols/v2/const-sv2 - - - name: Publish crate framing_sv2 - run: | - ./scripts/release-libs.sh protocols/v2/framing-sv2 - - - name: Publish crate noise_sv2 - run: | - ./scripts/release-libs.sh protocols/v2/noise-sv2 - - - name: Publish crate codec_sv2 - run: | - ./scripts/release-libs.sh protocols/v2/codec-sv2 - - - name: Publish crate common_messages - run: | - ./scripts/release-libs.sh protocols/v2/subprotocols/common-messages - - - name: Publish crate job_declaration - run: | - ./scripts/release-libs.sh protocols/v2/subprotocols/job-declaration - - - name: Publish crate mining - run: | - ./scripts/release-libs.sh protocols/v2/subprotocols/mining - - - name: Publish crate template_distribution - run: | - ./scripts/release-libs.sh protocols/v2/subprotocols/template-distribution - - - name: Publish crate sv2_ffi - run: | - ./scripts/release-libs.sh protocols/v2/sv2-ffi - - - name: Publish crate roles_logic_sv2 - run: | - ./scripts/release-libs.sh protocols/v2/roles-logic-sv2 - - - name: Publish crate v1 - run: | - ./scripts/release-libs.sh protocols/v1 - - - name: Publish crate bip32-key-derivation - run: | - ./scripts/release-libs.sh utils/bip32-key-derivation - - - name: Publish crate error-handling - run: | - ./scripts/release-libs.sh utils/error-handling - - - name: Publish crate key-utils - run: | - ./scripts/release-libs.sh utils/key-utils - - - name: Publish crate network_helpers_sv2 - run: | - ./scripts/release-libs.sh roles/roles-utils/network-helpers - - - name: Publish crate rpc_sv2 - run: | - ./scripts/release-libs.sh roles/roles-utils/rpc \ No newline at end of file diff --git a/.github/workflows/rust-msrv.yaml b/.github/workflows/rust-msrv.yaml deleted file mode 100644 index 2f9a93deb2..0000000000 --- a/.github/workflows/rust-msrv.yaml +++ /dev/null @@ -1,32 +0,0 @@ -on: - pull_request: - branches: - - main - -name: MSRV 1.75 Check - -jobs: - - build: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - rust: - - 1.75.0 # MSRV - - steps: - - uses: actions/checkout@v2 - - uses: Swatinem/rust-cache@v1.2.0 - - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.rust }} - override: true - - name: Build Benches - run: cargo build --manifest-path=benches/Cargo.toml - - name: Build Protocols - run: cargo build --manifest-path=protocols/Cargo.toml - - name: Build Roles - run: cargo build --manifest-path=roles/Cargo.toml - - name: Build Utils - run: cargo build --manifest-path=utils/Cargo.toml diff --git a/.github/workflows/semver-check.yaml b/.github/workflows/semver-check.yaml deleted file mode 100644 index d087ec70e3..0000000000 --- a/.github/workflows/semver-check.yaml +++ /dev/null @@ -1,122 +0,0 @@ -name: Semver Check - -on: - pull_request: - branches: - - "main" - -jobs: - semver-check: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Install Rust stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - - name: Cache Cargo registry - uses: actions/cache@v2 - with: - path: ~/.cargo/registry - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-registry- - - - name: Cache Cargo index - uses: actions/cache@v2 - with: - path: ~/.cargo/git - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.os }}-cargo-index- - - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y cmake - - - name: Install cargo-semver-checks - run: cargo install cargo-semver-checks --version 0.37.0 --locked - - - name: Run semver checks for common - working-directory: common - run: cargo semver-checks - - - name: Run semver checks for utils/buffer - working-directory: utils/buffer - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2/codec - working-directory: protocols/v2/binary-sv2/codec - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/binary-sv2 - working-directory: protocols/v2/binary-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/const-sv2 - working-directory: protocols/v2/const-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/framing-sv2 - working-directory: protocols/v2/framing-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/noise-sv2 - working-directory: protocols/v2/noise-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/codec-sv2 - working-directory: protocols/v2/codec-sv2 - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/common-messages - working-directory: protocols/v2/subprotocols/common-messages - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/job-declaration - working-directory: protocols/v2/subprotocols/job-declaration - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/mining - working-directory: protocols/v2/subprotocols/mining - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/subprotocols/template-distribution - working-directory: protocols/v2/subprotocols/template-distribution - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/sv2-ffi - working-directory: protocols/v2/sv2-ffi - run: cargo semver-checks - - - name: Run semver checks for protocols/v2/roles-logic-sv2 - working-directory: protocols/v2/roles-logic-sv2 - run: cargo semver-checks --default-features - - - name: Run semver checks for protocols/v1 - working-directory: protocols/v1 - run: cargo semver-checks - - - name: Run semver checks for utils/bip32-key-derivation - working-directory: utils/bip32-key-derivation - run: cargo semver-checks - - - name: Run semver checks for utils/error-handling - working-directory: utils/error-handling - run: cargo semver-checks - - - name: Run semver checks for utils/key-utils - working-directory: utils/key-utils - run: cargo semver-checks - - - name: Run semver checks for roles/roles-utils/network-helpers - working-directory: roles/roles-utils/network-helpers - run: cargo semver-checks - - - name: Run semver checks for roles/roles-utils/rpc - working-directory: roles/roles-utils/rpc - run: cargo semver-checks \ No newline at end of file diff --git a/.github/workflows/sv2-header-check.yaml b/.github/workflows/sv2-header-check.yaml deleted file mode 100644 index 42d552ef44..0000000000 --- a/.github/workflows/sv2-header-check.yaml +++ /dev/null @@ -1,31 +0,0 @@ -on: - pull_request: - branches: - - main - -# Check sv2.h file is up to date with commit -name: sv2.h Header Check - -jobs: - sv2_header_check: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - ubuntu-latest - include: - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - - with: - profile: minimal - toolchain: 1.75.0 - override: true - - name: Check sv2 header file is up to date with commit - run: | - echo Check sv2 header file is up to date with commit - sh ./scripts/sv2-header-check.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 00eab6b6c4..0000000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,88 +0,0 @@ -on: - pull_request: - branches: - - main - -name: Test, Prop Tests, Example Tests - -jobs: - ci: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - macos-13 - - ubuntu-latest - include: - - os: macos-13 - target: x86_64-apple-darwin - - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - steps: - - name: Install stable toolchain & components - uses: actions/checkout@v4 - with: - profile: minimal - toolchain: nightly - override: true - - - name: Build - run: | - cargo build --manifest-path=benches/Cargo.toml - cargo build --manifest-path=common/Cargo.toml - cargo build --manifest-path=protocols/Cargo.toml - cargo build --manifest-path=roles/Cargo.toml - cargo build --manifest-path=utils/Cargo.toml - - - name: Run sv1-client-and-server example - run: | - cargo run --manifest-path=protocols/v1/Cargo.toml --example client_and_server 30 - - - name: interop-test - run: | - if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - ./run.sh 30 - else - echo "Skipping interop-test on ${{ matrix.os }} - not supported" - fi - working-directory: examples/interop-cpp/ - - # TODO this is only usefull if we want to build c bindings with guix - #- name: interop-no-cargo-test - # run: | - # if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - # ./run.sh 30 - # else - # echo "Skipping interop-test on ${{ matrix.os }} - not supported" - # fi - # working-directory: examples/interop-cpp-no-cargo/ - - - name: fuzz tests - run: | - if [ ${{ matrix.os }} == "ubuntu-latest" ]; then - ./run.sh 30 - else - echo "Skipping fuzz test on ${{ matrix.os }} - not supported" - fi - working-directory: utils/buffer/fuzz - - - name: Test - run: | - cargo test --manifest-path=benches/Cargo.toml - cargo test --manifest-path=common/Cargo.toml - cargo test --manifest-path=protocols/Cargo.toml - cargo test --manifest-path=roles/Cargo.toml - cargo test --manifest-path=utils/Cargo.toml - - - name: Property based testing - run: | - cargo test --manifest-path=protocols/Cargo.toml --features prop_test - - - name: Run ping-pong-encrypted example - run: | - cargo run --manifest-path=examples/ping-pong-encrypted/Cargo.toml - - - name: Run ping-pong example - run: | - cargo run --manifest-path=examples/ping-pong/Cargo.toml diff --git a/.gitignore b/.gitignore index 5e2070438f..f402c584c7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ /ignore /vendor/ed25519-dalek/target /utils/buffer/target -/utils/message-generator/Cargo.lock /sv2.h /test/bitcoin_data/regtest lcov.info @@ -18,4 +17,4 @@ cobertura.xml /roles/*/*-config.toml /examples/*/Cargo.lock /scripts/sv2.h -/roles/tests-integration/template-provider \ No newline at end of file +/roles/tests-integration/template-provider diff --git a/scripts/code-coverage-report.sh b/scripts/code-coverage-report.sh deleted file mode 100755 index e996221952..0000000000 --- a/scripts/code-coverage-report.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /bin/sh - -cd roles -RUST_LOG=debug cargo +1.75.0 llvm-cov --ignore-filename-regex "utils/message-generator/|experimental/|protocols/" --cobertura --output-path "target/mg_coverage.xml" report diff --git a/scripts/coverage-protocols.sh b/scripts/coverage-protocols.sh deleted file mode 100755 index 9879bd3b59..0000000000 --- a/scripts/coverage-protocols.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -tarpaulin() { - crate_name=$1 - output_dir="target/tarpaulin-reports/$crate_name" - mkdir -p "$output_dir" - cargo +nightly tarpaulin --verbose --out Xml --output-dir "$output_dir" -} - -cd protocols -tarpaulin - -crates=( - "v1" - "v2/binary-sv2/codec" - "v2/binary-sv2/derive_codec" - "v2/binary-sv2" - "v2/noise-sv2" - "v2/framing-sv2" - "v2/codec-sv2" - "v2/const-sv2" - "v2/subprotocols/common-messages" - "v2/subprotocols/template-distribution" - "v2/subprotocols/mining" - "v2/subprotocols/job-declaration" - "v2/sv2-ffi" - "v2/roles-logic-sv2" -) - -for crate in "${crates[@]}"; do - echo "Running Tarpaulin for $crate..." - crate_name=$(basename "$crate") - cd "$crate" || exit 1 - tarpaulin "$crate_name-coverage" - cd - || exit 1 -done \ No newline at end of file diff --git a/scripts/coverage-roles.sh b/scripts/coverage-roles.sh deleted file mode 100755 index 6ba4df60c6..0000000000 --- a/scripts/coverage-roles.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -tarpaulin() { - crate_name=$1 - output_dir="target/tarpaulin-reports/$crate_name" - mkdir -p "$output_dir" - cargo +nightly tarpaulin --verbose --out Xml --output-dir "$output_dir" --all-features -} - -cd roles -tarpaulin - -crates=( - "mining-proxy" - "pool" - "test-utils/mining-device" - "test-utils/mining-device-sv1" - "translator" - "jd-client" - "jd-server" -) - -for crate in "${crates[@]}"; do - echo "Running Tarpaulin for $crate..." - crate_name=$(basename "$crate") - cd "$crate" || exit 1 - tarpaulin "$crate_name-coverage" - cd - || exit 1 -done diff --git a/scripts/coverage-utils.sh b/scripts/coverage-utils.sh deleted file mode 100755 index 6f32742984..0000000000 --- a/scripts/coverage-utils.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -tarpaulin() { - crate_name=$1 - output_dir="target/tarpaulin-reports/$crate_name" - mkdir -p "$output_dir" - cargo +nightly tarpaulin --verbose --out Xml --output-dir "$output_dir" --all-features -} - -cd utils -tarpaulin - -crates=( - "buffer" - "error-handling" - "key-utils" - "bip32-key-derivation" -) - -for crate in "${crates[@]}"; do - echo "Running Tarpaulin for $crate..." - crate_name=$(basename "$crate") - cd "$crate" || exit 1 - tarpaulin "$crate_name-coverage" - cd - || exit 1 -done diff --git a/scripts/message-generator-tests.sh b/scripts/message-generator-tests.sh deleted file mode 100755 index a7897a07d5..0000000000 --- a/scripts/message-generator-tests.sh +++ /dev/null @@ -1,17 +0,0 @@ -#! /bin/sh - -search_dir="test/message-generator/test/" - -for entry in `ls $search_dir`; do - if [ "$entry" = "interop-jdc-change-upstream" ]; then - echo "Skipping $entry" - continue - fi - - echo $entry - $search_dir$entry/$entry.sh -done - -cd roles -RUST_LOG=debug cargo +1.75.0 llvm-cov --ignore-filename-regex "utils/message-generator/|experimental/|protocols/" --cobertura --output-path "target/mg_coverage.xml" report - diff --git a/scripts/mg-codecov-tests.sh b/scripts/mg-codecov-tests.sh deleted file mode 100755 index 3ec41bf21b..0000000000 --- a/scripts/mg-codecov-tests.sh +++ /dev/null @@ -1,5 +0,0 @@ -message_generator_dir="./utils/message-generator/" - -cd $message_generator_dir - -cargo run -- ../../test/message-generator/cov/cov_test.json diff --git a/test/message-generator/it_open_test.json b/test/message-generator/it_open_test.json deleted file mode 100644 index 0fd8088d74..0000000000 --- a/test/message-generator/it_open_test.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "version":"2", - "doc": [ - "Just test that the message_generato.sh can run tests in this direcotry", - "1) start listen as a server for plain connections", - "2) run mining-device", - "3) check that first message received is SetupConnection" - ], - "frame_builders": [], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ] - } - ], - "setup_commands": [ - ], - "execution_commands": [ - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining-device" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "start", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 240, - "warn_no_panic": false - } - } - } - ], - "cleanup_commands": [ - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 34255 - } -} diff --git a/test/message-generator/messages/common_messages.json b/test/message-generator/messages/common_messages.json deleted file mode 100644 index 65cc32a9a9..0000000000 --- a/test/message-generator/messages/common_messages.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "common_messages": [ - { - "message": { - "type": "SetupConnection", - "protocol": 0, - "min_version": 2, - "max_version": 2, - "flags": 1, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "id": "setup_connection_mining_hom" - }, - { - "message": { - "type": "SetupConnection", - "protocol": 0, - "min_version": 2, - "max_version": 2, - "flags": 0, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "id": "setup_connection_flag_0" - }, - { - "message": { - "type": "SetupConnection", - "protocol": 1, - "min_version": 2, - "max_version": 2, - "flags": 1, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "id": "setup_connection_job_declarator" - }, - { - "message": { - "type": "SetupConnection", - "protocol": 1, - "min_version": 2, - "max_version": 2, - "flags": 0, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "id": "setup_connection_job_declarator_with_no_async_flag" - }, - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 0, - "used_version": 2 - }, - "id": "setup_connection_success_flag_0" - }, - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 2, - "used_version": 2 - }, - "id": "setup_connection_success_template_distribution" - }, - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 0, - "used_version": 2 - }, - "id": "setup_connection_success_tproxy" - } - - ] -} diff --git a/test/message-generator/messages/mining_messages.json b/test/message-generator/messages/mining_messages.json deleted file mode 100644 index 79da299c5b..0000000000 --- a/test/message-generator/messages/mining_messages.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "mining_messages": [ - { - "message": { - "type": "NewExtendedMiningJob", - "job_id": 1, - "channel_id": 0, - "min_ntime": [], - "version": 536870912, - "version_rolling_allowed": true, - "merkle_path": [], - "coinbase_tx_prefix": [2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 36, 2, 3, 15, 0], - "coinbase_tx_suffix": [255, 255, 255, 255, 2, 149, 0, 0, 0, 0, 0, 0, 0, 67, 65, 4, 70, 109, 127, 202, 229, 99, 229, 203, 9, 160, 209, 135, 11, 181, 128, 52, 72, 4, 97, 120, 121, 161, 73, 73, 207, 34, 40, 95, 27, 174, 63, 39, 103, 40, 23, 108, 60, 100, 49, 248, 238, 218, 69, 56, 220, 55, 200, 101, 226, 120, 79, 58, 158, 119, 208, 68, 243, 62, 64, 119, 151, 225, 39, 138, 172, 0, 0, 0, 0, 0, 0, 0, 0, 38, 106, 36, 170, 33, 169, 237, 226, 246, 28, 63, 113, 209, 222, 253, 63, 169, 153, 223, 163, 105, 83, 117, 92, 105, 6, 137, 121, 153, 98, 180, 139, 235, 216, 54, 151, 78, 140, 249, 1, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - }, - "id": "new_extended_mining_job" - }, - { - "message":{ - "type": "SetNewPrevHash", - "channel_id": 0, - "job_id": 1, - "prev_hash": [91, 30, 84, 205, 18, 124, 218, 102, 28, 163, 155, 204, 173, 55, 119, 61, 224, 199, 68, 229, 144, 22, 92, 0, 53, 44, 15, 204, 200, 245, 149, 0], - "min_ntime": 1679128496, - "nbits": 545259519 - }, - "id": "set_new_prev_hash" - }, - { - "message": { - "type": "OpenExtendedMiningChannelSuccess", - "request_id": 1, - "channel_id": 1, - "target": [88, 190, 74, 45, 212, 33, 248, 47, 32, 222, 23, 112, 230, 43, 18, 139, 144, 135, 104, 178, 135, 218, 190, 102, 83, 235, 9, 81, 14, 0, 0, 0], - "extranonce_prefix": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2], - "extranonce_size": 44 - }, - "id": "openEMC_success_tproxy_bad_extranonce" - }, - { - "message": { - "type": "OpenExtendedMiningChannelSuccess", - "request_id": 0, - "channel_id": 1, - "target": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255], - "extranonce_size": 16, - "extranonce_prefix": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] - }, - "id": "open_extended_mining_channel_success" - }, - { - "message": { - "type": "SubmitSharesError", - "channel_id": 1, - "sequence_number": 1, - "error_code": "invalid-channel-id" - }, - "id": "submit_shares_error" - }, - { - "message": { - "type": "SetCustomMiningJobSuccess", - "channel_id": 1, - "request_id": 1, - "job_id": 1 - }, - "replace_fields": [["request_id", "custom_job_req_id"]], - "id": "set_custom_mining_job_success" - } - ] -} diff --git a/test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json b/test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json deleted file mode 100644 index e80141297f..0000000000 --- a/test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mock of JDC", - "Connect to JDS (where it doesn't matter if it supports async jobs or not)", - "Send SetupConnection with flag 0 (no async jobs) and expect SetupConnection.Success with flag 0" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator_with_no_async_flag" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_job_declarator_with_no_async_flag"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "CommonMessages", - "SetupConnectionSuccess", - [ - [ - "flags", - { "U32": 0 } - ] - ] - ] - } - ], - "actiondoc": "This action sends SetupConnection and expects SetupConnection.Success with flag 0" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-with-async-support.json b/test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-with-async-support.json deleted file mode 100644 index edbd83e13e..0000000000 --- a/test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-with-async-support.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mock of JDC", - "Connect to JDS (that supports async jobs)", - "Send SetupConnection with flag 1 (async jobs) and expect SetupConnection.Success with flag 1" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_job_declarator"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "CommonMessages", - "SetupConnectionSuccess", - [ - [ - "flags", - { "U32": 1 } - ] - ] - ] - } - ], - "actiondoc": "This action sends SetupConnection and expects SetupConnection.Success with flag 1" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-without-async-support.json b/test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-without-async-support.json deleted file mode 100644 index eeaf19ca59..0000000000 --- a/test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-without-async-support.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mock of JDC", - "Connect to JDS (that does not support async jobs)", - "Send SetupConnection with flag 1 (async jobs) and expect SetupConnection.Error" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_job_declarator"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x02" - }, - { - "type": "close_connection" - } - ], - "actiondoc": "This action sends SetupConnection and expects SetupConnection.Error" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/mock/jdc-mock-jds-receive-solution-while-processing-declared-job.json b/test/message-generator/mock/jdc-mock-jds-receive-solution-while-processing-declared-job.json deleted file mode 100644 index 67148be877..0000000000 --- a/test/message-generator/mock/jdc-mock-jds-receive-solution-while-processing-declared-job.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Mock JDC", - "Send SetupConnection and await for SetupConnection.Success", - "Send AllocateMiningJobToken0 and await for AllocateMiningJobToken.Success0", - "Send AllocateMiningJobToken1 and await for AllocateMiningJobToken.Success1", - "Send DeclareMiningJob and await for ProvideMissingTransactions", - "Send SubmitSolution and assert that connection was sustained" - ], - "job_declaration_messages": [ - { - "message": { - "type": "AllocateMiningJobToken", - "user_identifier": "", - "request_id": 0, - "coinbase_tx_outputs": [] - }, - "id": "allocate_mining_job_token0" - }, - { - "message": { - "type": "AllocateMiningJobToken", - "user_identifier": "", - "request_id": 1, - "coinbase_tx_outputs": [] - }, - "id": "allocate_mining_job_token1" - }, - { - "message": { - "type": "DeclareMiningJob", - "request_id": 0, - "mining_job_token": [1, 0, 0, 0], - "version": 0, - "coinbase_prefix": [2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 55, 2, 128, 121, 0, 83, 116, 114, 97, 116, 117, 109, 32, 118, 50, 32, 83, 82, 73, 32, 80, 111, 111, 108], - "coinbase_suffix": [255, 255, 255, 255, 2, 168, 247, 5, 42, 1, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252, 0, 0, 0, 0, 0, 0, 0, 0, 38, 106, 36, 170, 33, 169, 237, 226, 201, 13, 62, 213, 94, 164, 53, 216, 76, 246, 14, 110, 125, 255, 48, 66, 12, 220, 90, 217, 209, 75, 129, 37, 185, 117, 116, 254, 30, 81, 159, 1, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - "tx_short_hash_nonce": 0, - "tx_short_hash_list": [[95, 135, 113, 8, 147, 179]], - "tx_hash_list_hash": [133, 189, 184, 91, 252, 203, 225, 42, 233, 16, 77, 119, 76, 134, 93, 189, 192, 159, 221, 130, 150, 196, 18, 32, 54, 212, 138, 255, 57, 63, 118, 74], - "excess_data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - }, - "id": "declare_mining_job" - }, - { - "message": { - "type": "SubmitSolution", - "extranonce": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0], - "prev_hash": [184, 103, 138, 88, 153, 105, 236, 29, 123, 246, 107, 203, 1, 33, 10, 122, 188, 139, 218, 141, 62, 177, 158, 101, 125, 92, 214, 150, 199, 220, 29, 8], - "ntime": 0, - "nonce": 0, - "nbits": 0, - "version": 0 - }, - "id": "submit_solution" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator" - }, - { - "type": "automatic", - "message_id": "allocate_mining_job_token0" - }, - { - "type": "automatic", - "message_id": "allocate_mining_job_token1" - }, - { - "type": "automatic", - "message_id": "declare_mining_job" - }, - { - "type": "automatic", - "message_id": "submit_solution" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_job_declarator"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - } - ], - "actiondoc": "This action sends SetupConnection and awaits for a SetupConnection.Success" - }, - { - "message_ids": ["allocate_mining_job_token0"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x51" - } - ], - "actiondoc": "This action sends AllocateMiningJobToken0 and awaits for a AllocateMiningJobToken.Success0" - }, - { - "message_ids": ["allocate_mining_job_token1"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x51" - } - ], - "actiondoc": "This action sends AllocateMiningJobToken1 and awaits for a AllocateMiningJobToken.Success1" - }, - { - "message_ids": ["declare_mining_job"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x55" - } - ], - "actiondoc": "This action sends DeclareMiningJob and awaits for a ProvideMissingTransactions" - }, - { - "message_ids": ["submit_solution"], - "role": "client", - "results": [ - { - "type": "sustain_connection" - } - ], - "actiondoc": "This action sends SubmitSolution and asserts that connection was sustained" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/mock/jds-mock-no-token.json b/test/message-generator/mock/jds-mock-no-token.json deleted file mode 100644 index ff39d5c333..0000000000 --- a/test/message-generator/mock/jds-mock-no-token.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Mock a JDS", - "Start listen to the port 34264", - "Receive setup_connection", - "Sends setup_connection_success", - "Receive new token", - "Hand leaving the connection opened" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - } - ], - "setup_commands": [ - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "sleep", - "args": ["10000000"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/mock/job-declarator-mock-send-invalid-txdatasucc.json b/test/message-generator/mock/job-declarator-mock-send-invalid-txdatasucc.json deleted file mode 100644 index 5bc6fbc8dd..0000000000 --- a/test/message-generator/mock/job-declarator-mock-send-invalid-txdatasucc.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mock of JD", - "Connect to JDS", - "Sends wrong provide_missing_txs to JDS", - "Expect the JDS to close connection" - ], - "job_declaration_messages": [ - { - "message": { - "type": "ProvideMissingTransactionsSuccess", - "request_id": 1, - "transaction_list": [[1000]] - }, - "id": "provide_missing_txs_success" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator" - }, - { - "type": "automatic", - "message_id": "provide_missing_txs_success" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_job_declarator"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - } - - ], - "actiondoc": "This action sends SetupConnection and checks that .Success" - }, - { - "message_ids": ["provide_missing_txs_success"], - "role": "client", - "results": [ - { - "type": "close_connection" - } - ], - "actiondoc": "This action sends ProvideMissingTxsSuccess and checks that JDS close the connection" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/mock/job-declarator-mock.json b/test/message-generator/mock/job-declarator-mock.json deleted file mode 100644 index 8a88ab9b88..0000000000 --- a/test/message-generator/mock/job-declarator-mock.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mock of JD", - "Sends SetupConnection to the pool and waits for .Success", - "Waits that SetCoinbase is received", - "Waits that one more SetCoinbase is received" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_job_declarator" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_job_declarator"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - }, - { - "type": "match_message_type", - "value": "0x50" - } - - ], - "actiondoc": "This action sends SetupConnection and checks that .Success and SetCoinbase is received" - }, - { - "message_ids": [], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x50" - } - - ], - "actiondoc": "This action sends SetupConnection and checks that SetCoinbase is received" - } - - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34264, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/mock/pool-mock-invalid-share.json b/test/message-generator/mock/pool-mock-invalid-share.json deleted file mode 100644 index 43e378b948..0000000000 --- a/test/message-generator/mock/pool-mock-invalid-share.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Mock a pool", - "Start listen to the port 44254", - "Receive setup_connection", - "Sends setup_connection_success", - "Receive open extended channel", - "Send open extended channel success", - "Receive new custom mining job", - "Send set custom mining job success", - "Receive submit share", - "Send submit share error" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::open_extended_mining_channel_success" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::set_custom_mining_job_success" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::submit_shares_error" - } - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x13" - } - ], - "actiondoc": "This action sends SetupConnection.Success and check that a open_extended_mining_channel is received" - }, - { - "message_ids": ["open_extended_mining_channel_success"], - "role": "server", - "results": [ - { - "type": "get_message_field", - "value": [ - "MiningProtocol", - "SetCustomMiningJob", - [ - [ - "request_id", - "custom_job_req_id" - ] - ] - ] - } - ], - "actiondoc": "This action sends open_extended_mining_channel_success, and a wait for a SetCustomMiningJoband get the req id" - }, - { - "message_ids": ["set_custom_mining_job_success"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x1b" - } - ], - "actiondoc": "This action sends a SetCustomMiningJob.Success and check that a ssubmit_shares is received" - }, - { - "message_ids": ["submit_shares_error"], - "role": "server", - "results": [], - "actiondoc": "This action a submit_shares_error" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [ - { - "command": "sleep", - "args": ["10000"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 44254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/mock/template-provider-mock0.json b/test/message-generator/mock/template-provider-mock0.json deleted file mode 100644 index d0079b4383..0000000000 --- a/test/message-generator/mock/template-provider-mock0.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mocking of template provider", - "Start listen to the port 8442 that a messate 0x00 of type match_message_type arrives", - "Sends setup_connection_success", - "Start listen that message 0x00 arrives, without dieing" - ], - "template_distribution_messages": [ - { - "message": { - "type": "NewTemplate", - "template_id": 29, - "future_template": true, - "version": 536870912, - "coinbase_tx_version": 2, - "coinbase_prefix": [3, 76, 163, 38, 0], - "coinbase_tx_input_sequence": 4294967295, - "coinbase_tx_value_remaining": 625000000, - "coinbase_tx_outputs_count": 0, - "coinbase_tx_outputs": [], - "coinbase_tx_locktime": 0, - "merkle_path": [] - }, - "id": "new_template" - }, - { - "message": { - "type": "SetNewPrevHash", - "template_id": 29, - "prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0], - "header_timestamp": 1671039088, - "n_bits": 545259519, - "target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127] - }, - "id": "set_new_prev_hash" - }, - { - "message": { - "type": "NewTemplate", - "template_id": 30, - "future_template": true, - "version": 536870912, - "coinbase_tx_version": 2, - "coinbase_prefix": [3, 76, 163, 38, 0], - "coinbase_tx_input_sequence": 4294967295, - "coinbase_tx_value_remaining": 625000000, - "coinbase_tx_outputs_count": 0, - "coinbase_tx_outputs": [], - "coinbase_tx_locktime": 0, - "merkle_path": [] - }, - "id": "new_template2" - }, - { - "message": { - "type": "SetNewPrevHash", - "template_id": 30, - "prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0], - "header_timestamp": 1671039088, - "n_bits": 545259519, - "target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127] - }, - "id": "set_new_prev_hash2" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_template_distribution" - }, - { - "type": "automatic", - "message_id": "new_template" - }, - { - "type": "automatic", - "message_id": "set_new_prev_hash" - }, - { - "type": "automatic", - "message_id": "new_template2" - }, - { - "type": "automatic", - "message_id": "set_new_prev_hash2" - } - - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_template_distribution"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x70" - } - ], - "actiondoc": "This action sends SetupConnection.Success with flag 2 (TD protocol) and checks that a message SetCoinbaseDataSize is received" - }, - { - "message_ids": ["new_template","set_new_prev_hash"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x76" - } - ], - "actiondoc": "This action sends NewTemplate and SetNewPrevHash, and checks that SubmitSolution is received" - }, - { - "message_ids": ["new_template2","set_new_prev_hash2"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x76" - } - ], - "actiondoc": "This action checks that new template2 and new prev hash2 is received" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [ - { - "command": "sleep", - "args": ["10"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 8442, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/mock/template-provider-mock1.json b/test/message-generator/mock/template-provider-mock1.json deleted file mode 100644 index 0815c7d9cf..0000000000 --- a/test/message-generator/mock/template-provider-mock1.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Soft mocking of template provider", - "Start listen to the port 8442 that a messate 0x00 of type match_message_type arrives", - "Sends setup_connection_success", - "Start listen that message 0x00 arrives, without dieing" - ], - "template_distribution_messages": [ - { - "message": { - "type": "NewTemplate", - "template_id": 29, - "future_template": true, - "version": 536870912, - "coinbase_tx_version": 2, - "coinbase_prefix": [1,16,0], - "coinbase_tx_input_sequence": 4294967295, - "coinbase_tx_value_remaining": 625000000, - "coinbase_tx_outputs_count": 0, - "coinbase_tx_outputs": [], - "coinbase_tx_locktime": 0, - "merkle_path": [] - }, - "id": "new_template" - }, - { - "message": { - "type": "SetNewPrevHash", - "template_id": 29, - "prev_hash": [145, 77, 225, 26, 186, 5, 16, 125, 174, 40, 238, 200, 210, 191, 188, 87, 191, 246, 242, 221, 8, 20, 202, 200, 97, 139, 241, 73, 137, 201, 28, 0], - "header_timestamp": 1671039088, - "n_bits": 545259519, - "target": [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127] - }, - "id": "set_new_prev_hash" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_template_distribution" - }, - { - "type": "automatic", - "message_id": "new_template" - }, - { - "type": "automatic", - "message_id": "set_new_prev_hash" - } - - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_template_distribution"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x70" - } - ], - "actiondoc": "This action sends SetupConnection.Success with flag 2 (TD protocol) and checks that a message SetCoinbaseDataSize is received" - }, - { - "message_ids": ["new_template","set_new_prev_hash"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x76" - } - ], - "actiondoc": "This action sends NewTemplate and SetNewPrevHash, and checks that SubmitSolution is received" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [ - { - "command": "sleep", - "args": ["10"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 8442, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/mock/upstream-mock.json b/test/message-generator/mock/upstream-mock.json deleted file mode 100644 index 094d2dc673..0000000000 --- a/test/message-generator/mock/upstream-mock.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Mock an Upstream", - "Start listening on port 34254", - "Receive SetupConnection", - "Sends SetupConnection.Success", - "Receive OpenExtendedMiningChannel", - "Send OpenExtendedMiningChannel.Success", - "Send NewExtendedMiningJob" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::open_extended_mining_channel_success" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::set_custom_mining_job_success" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::submit_shares_error" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::new_extended_mining_job" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::set_new_prev_hash" - } - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "Checks that a SetupConnection message is received from Downstream" - }, - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x13" - } - ], - "actiondoc": "Sends SetupConnection.Success to Downstream, then checks that a OpenExtendedMiningChannel is sent from Downstream" - }, - { - "message_ids": ["open_extended_mining_channel_success"], - "role": "server", - "results": [], - "actiondoc": "Sends OpenExtendedMiningChannel.Success to Downstream" - }, - { - "message_ids": ["new_extended_mining_job"], - "role": "server", - "results": [], - "actiondoc": "Sends NewExtendedMiningJob to Downstream" - }, - { - "message_ids": ["set_new_prev_hash"], - "role": "server", - "results": [], - "actiondoc": "Sends SetNewPrevHash to Downstream" - } - ], - "setup_commands": [], - "execution_commands": [], - "cleanup_commands": [ - { - "command": "sleep", - "args": ["10000"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/test/interop-jd-translator/interop-jd-translator.json b/test/message-generator/test/interop-jd-translator/interop-jd-translator.json deleted file mode 100644 index a530ed00f9..0000000000 --- a/test/message-generator/test/interop-jd-translator/interop-jd-translator.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch the pool", - "Launch the jd-client", - "Launch the jd-server", - "Launch tproxy", - "Launch mining_device_sv1", - "Found a share" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/interop-jd-translator/pool-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 0.0.0.0:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_server", - "--", - "-c", - "../test/config/interop-jd-translator/jds-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "JD INITIALIZED", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_client", - "--", - "-c", - "../test/config/interop-jd-translator/jdc-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on 0.0.0.0:34265", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "translator_sv2", - "--", - "-c", - "../test/config/interop-jd-translator/proxy-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Received SetNewPrevHash", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining_device_sv1" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Found share with nonce:", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "mining_device_sv1", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "translator_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "jd_client", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/interop-jd-translator/interop-jd-translator.sh b/test/message-generator/test/interop-jd-translator/interop-jd-translator.sh deleted file mode 100755 index b1d476bd65..0000000000 --- a/test/message-generator/test/interop-jd-translator/interop-jd-translator.sh +++ /dev/null @@ -1,13 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 -cargo llvm-cov --no-report -p jd_server -cargo llvm-cov --no-report -p jd_client -cargo llvm-cov --no-report -p translator_sv2 -cargo build -p mining_device_sv1 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/interop-jd-translator/interop-jd-translator.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.json b/test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.json deleted file mode 100644 index 344b8d6ce7..0000000000 --- a/test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.json +++ /dev/null @@ -1,214 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch a pool mocks", - "Launch jds", - "Launch jdc", - "Launch mining-proxy", - "Launch a mining device", - "Act like a pool", - "Connect jdc to the first pool", - "Receive an submit share error from first pool", - "Close jdc connection with first pool", - "Connect jdc the pool mocked by this test" - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - } - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x13" - } - ], - "actiondoc": "This action sends SetupConnection.Success and check that a open_extended_mining_channel is received" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/pool-mock-invalid-share.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Running `target/debug/message_generator_sv2 ../../test/message-generator/mock/pool-mock-invalid-share.json`", - "output_location": "StdErr", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "sleep", - "args": ["10000"], - "conditions": "None" - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_server", - "--", - "-c", - "../test/config/interop-jd-change-upstream/jds-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "JD INITIALIZED", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_client", - "--", - "-c", - "../test/config/interop-jd-change-upstream/jdc-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "mining_proxy_sv2", - "--", - "-c", - "../test/config/interop-jd-change-upstream/proxy-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on 127.0.0.1:34255", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "sleep", - "args": ["10000"], - "conditions": "None" - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining-device" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "SUCCESS SubmitSharesSuccess", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "mining_device", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "jd_client", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "mining_proxy_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none", - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 44255, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.sh b/test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.sh deleted file mode 100755 index 514b2e79e1..0000000000 --- a/test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.sh +++ /dev/null @@ -1,12 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p jd_server -cargo llvm-cov --no-report -p jd_client -cargo llvm-cov --no-report -p mining_proxy_sv2 -cargo build -p --no-report mining-device - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/interop-jdc-change-upstream/interop-jdc-change-upstream.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.json b/test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.json deleted file mode 100644 index 90c084f489..0000000000 --- a/test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.json +++ /dev/null @@ -1,181 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch 2 pool on differnet address", - "Launch mining-proxy", - "Connect proxy to the 2 above pool", - "Try connect proxy to non exsistent pool proxy must not panic", - "Launch MD and connect to proxy", - "Kill the pool that the proxy is using for the above MD, proxy must not panic", - "Kill the MD, proxy must not panic", - "Launch MD and connect to proxy, MD must start mine with the other avaiable pool", - "Generates code coverage report for the pool and mining-proxy" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-config-sri-tp.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-config-sri-tp-different-port.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:44254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "mining_proxy_sv2", - "--", - "-c", - "../test/config/proxy-config-test-multiple-upstreams-extended.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on 127.0.0.1:34255", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining-device" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "SUCCESS SubmitSharesSuccess", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "kill", - "args": ["0"], - "conditions": "None" - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining-device" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "SUCCESS SubmitSharesSuccess", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "kill", - "args": ["1"], - "conditions": "None" - }, - { - "command": "kill", - "args": ["2"], - "conditions": "None" - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "mining_proxy_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "mining-device", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.sh b/test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.sh deleted file mode 100755 index 4173ac30cb..0000000000 --- a/test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.sh +++ /dev/null @@ -1,11 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 -cargo llvm-cov --no-report -p mining_proxy_sv2 -cargo build --no-report -p mining-device - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/interop-proxy-with-multi-ups-extended/interop-proxy-with-multi-ups-extended.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.json b/test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.json deleted file mode 100644 index 3a7dc4da0a..0000000000 --- a/test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.json +++ /dev/null @@ -1,186 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch 2 pool on differnet address", - "Launch mining-proxy", - "Connect proxy to the 2 above pool", - "Try connect proxy to non exsistent pool proxy must not panic", - "Launch MD and connect to proxy", - "Kill the pool that the proxy is using for the above MD, proxy must not panic", - "Kill the MD, proxy must not panic", - "Launch MD and connect to proxy, MD must start mine with the other avaiable pool", - "Generates code coverage report for the pool and mining-proxy" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-config-sri-tp.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-config-sri-tp-different-port.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:44254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "mining_proxy_sv2", - "--", - "-c", - "../test/config/proxy-config-test-multiple-upstreams.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on 127.0.0.1:34255", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining-device" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "SUCCESS SubmitSharesSuccess", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "sleep", - "args": ["1000"], - "conditions": "None" - }, - { - "command": "kill", - "args": ["0"], - "conditions": "None" - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining-device" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "SUCCESS SubmitSharesSuccess", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "kill", - "args": ["1"], - "conditions": "None" - }, - { - "command": "kill", - "args": ["2"], - "conditions": "None" - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "mining_proxy_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "mining-device", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.sh b/test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.sh deleted file mode 100755 index 080224419c..0000000000 --- a/test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.sh +++ /dev/null @@ -1,11 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 -cargo llvm-cov --no-report -p mining_proxy_sv2 -cargo build -p mining-device - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/interop-proxy-with-multi-ups/interop-proxy-with-multi-ups.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.json b/test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.json deleted file mode 100644 index 60d82db139..0000000000 --- a/test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch the jd-server", - "Send a random provide_missing_transaction_success", - "Rexecute the last 2 step, if they pass it means that jds is still up" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_server", - "--", - "-c", - "../test/config/jds-do-not-fail-on-wrong-txdatasucc/jds-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "JD INITIALIZED", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/job-declarator-mock-send-invalid-txdatasucc.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "MATCHED MESSAGE TYPE 1", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/job-declarator-mock-send-invalid-txdatasucc.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "MATCHED MESSAGE TYPE 1", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.sh b/test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.sh deleted file mode 100755 index 4957309d96..0000000000 --- a/test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p jd_server - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/jds-do-not-fail-on-wrong-tsdatasucc/jds-do-not-fail-on-wrong-tsdatasucc.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.json b/test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.json deleted file mode 100644 index 56c3a6db04..0000000000 --- a/test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.json +++ /dev/null @@ -1,158 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch a jds mock on 34264", - "Launch a pool on 34254", - "Launch jdc on 34265", - "Launch a mining proxy", - "Run a mining device", - "Wait 10 seconds and verify that jdc do not panic" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/jds-mock-no-token.json" - ], - - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Running `target/debug/message_generator_sv2 ../../test/message-generator/mock/jds-mock-no-token.json`", - "output_location": "StdErr", - "condition": true, - "late_condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/jds-stack-overflow/pool-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on:", - "output_location": "StdOut", - "condition": true, - "late_condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_client", - "--", - "-c", - "../test/config/jds-stack-overflow/jdc-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on", - "output_location": "StdOut", - "condition": true, - "late_condition": false - }, - { - "output_string": "thread 'tokio-runtime-worker' has overflowed its stack", - "output_location": "StdErr", - "condition": false, - "late_condition": true - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "mining_proxy_sv2", - "--", - "-c", - "../test/config/jds-stack-overflow/mining-proxy-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for downstream mining connections on 127.0.0.1:34255", - "output_location": "StdOut", - "condition": true, - "late_condition": false - } - ], - "timer_secs": 30, - "warn_no_panic": false - } - } - }, - { - "command": "sleep", - "args": ["10000"], - "conditions": "None" - } - - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "jd_client", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "mining_proxy_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.sh b/test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.sh deleted file mode 100755 index b3a253b517..0000000000 --- a/test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.sh +++ /dev/null @@ -1,11 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 -cargo llvm-cov --no-report -p jd_client -cargo llvm-cov --no-report -p mining_proxy_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/jds-do-not-stackoverflow-when-no-token/jds-do-not-stackoverflow-when-no-token.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.json b/test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.json deleted file mode 100644 index 27807bb82c..0000000000 --- a/test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch real JDS", - "Mock a JDC that sends SubmitSolution before ProvideMissingTransactionsSuccess" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_server", - "--", - "-c", - "../test/config/jds-receive-solution-while-processing-declared-job/jds-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "JD INITIALIZED", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/jdc-mock-jds-receive-solution-while-processing-declared-job.json" - ], - - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "TEST FAIL", - "output_location": "StdErr", - "condition": false, - "late_condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": true - } - } - }, - { - "command": "sleep", - "args": ["1000"], - "conditions": "None" - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "late_condition": false, - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.sh b/test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.sh deleted file mode 100755 index 39c8559ef6..0000000000 --- a/test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p jd_server - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/jds-receive-solution-while-processing-declared-job/jds-receive-solution-while-processing-declared-job.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.json b/test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.json deleted file mode 100644 index c0d781d69c..0000000000 --- a/test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch the jd-server" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_server", - "--", - "-c", - "../test/config/jds-setupconnection-flag-test/jds-config-with-async-support.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "JD INITIALIZED", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "TEST FAILED", - "output_location": "StdErr", - "late_condition": false, - "condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-with-async-support.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "TEST FAILED", - "output_location": "StdErr", - "late_condition": false, - "condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.sh b/test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.sh deleted file mode 100755 index 87dcf97e9d..0000000000 --- a/test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/jds-setupconnection-with-async-support/jds-setupconnection-with-async-support.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.json b/test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.json deleted file mode 100644 index 15eb2e978a..0000000000 --- a/test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.json +++ /dev/null @@ -1,92 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Launch the jd-server" - ], - "frame_builders": [ - ], - "actions": [ - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "jd_server", - "--", - "-c", - "../test/config/jds-setupconnection-flag-test/jds-config-without-async-support.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "JD INITIALIZED", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 300, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/jdc-mock-flag-0-for-jds-setupconnection-tests.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "TEST FAILED", - "output_location": "StdErr", - "late_condition": false, - "condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/jdc-mock-flag-1-for-jds-setupconnection-without-async-support.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "TEST FAILED", - "output_location": "StdErr", - "late_condition": false, - "condition": false - } - ], - "timer_secs": 600, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "jd_server", "-SIGINT"], - "conditions": "None" - } - ], - "role": "none" -} diff --git a/test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.sh b/test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.sh deleted file mode 100755 index 151cec4ff2..0000000000 --- a/test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/jds-setupconnection-without-async-support/jds-setupconnection-without-async-support.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.json b/test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.json deleted file mode 100644 index 85cfd0b429..0000000000 --- a/test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.json +++ /dev/null @@ -1,211 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Runs a mocked Template Provider", - "Runs the pool with a custom config file", - "Runs a mocked Job Declarator", - "Mocks a mining device (without mining) that connects to a pool", - "Opens a standard channel with the pool", - "Checks that a NewMiningJob and a NewPrevHash are received", - "These last two messages are built in base of the NewTemplate and NewPrevHash provided by the mocked TP", - "Successfully submits a share that is a solution for the template supplied by the mocked TP", - "Checks that a second SetNewPrevHash is provided by the pool for the next round of mining", - "Generates code coverage report for the pool" - ], - "common_messages": [ - { - "message": { - "type": "SetupConnection", - "protocol": 0, - "min_version": 2, - "max_version": 2, - "flags": 1, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "replace_fields": [["endpoint_port", "ARBITRARY"]], - "id": "setup_connection_mining_hom" - } - ], - "mining_messages": [ - { - "message": { - "type": "OpenStandardMiningChannel", - "request_id": 89, - "user_identity": "", - "nominal_hash_rate": 10, - "max_target": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] - }, - "id": "open_standard_mining_channel" - }, - { - "message": { - "type": "SubmitSharesStandard", - "channel_id": 1, - "sequence_number": 0, - "job_id": 1, - "nonce": 4035255480, - "ntime": 1698941362, - "version": 536870912 - }, - "id": "submit_shares" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "setup_connection_mining_hom" - }, - { - "type": "automatic", - "message_id": "open_standard_mining_channel" - }, - { - "type": "automatic", - "message_id": "submit_shares" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_mining_hom"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - } - ], - "actiondoc": "This action sends a SetupConnection and check that receives a message type 0x01, that is SetupConnectionSuccess" - }, - { - "message_ids": ["open_standard_mining_channel"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "MiningProtocol", - "OpenStandardMiningChannelSuccess", - [ - [ - "request_id", - {"U32": 89} - ] - ] - ] - }, - { - "type": "match_message_type", - "value": "0x15" - }, - { - "type": "match_message_type", - "value": "0x20" - } - ], - "actiondoc": "This action sends OpenStandardMiningChannel to the pool and checks that the reply is OpenStandardMiningChannelSuccess, NewMiningJob, and SetNewPrevHash" - }, - { - "message_ids": ["submit_shares"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x1c" - } - ], - "actiondoc": "This action sends the message SubmitSharesStandard to the pool and checks that the pool replies with SubmitSharesStandard.Success2" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/template-provider-mock0.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Running `target/debug/message_generator_sv2 ../../test/message-generator/mock/template-provider-mock0.json`", - "output_location": "StdErr", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-mock-tp.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/job-declarator-mock.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Running `target/debug/message_generator_sv2 ../../test/message-generator/mock/job-declarator-mock.json`", - "output_location": "StdErr", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.sh b/test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.sh deleted file mode 100755 index ca9ad35589..0000000000 --- a/test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/pool-sri-test-1-standard/pool-sri-test-1-standard.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.json b/test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.json deleted file mode 100644 index 8529af950d..0000000000 --- a/test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test runs a tproxy and a mock pool. The mock pool responds with SetupConnectionSuccess", - "And then a OpenExtendedMiningChannelSuccess. The pool then sends a CloseChannel message", - "This will cause the tproxy to exit. This test just validates that the tproxy closes" - ], - "common_messages": [ - ], - "mining_messages": [ - { - "message": { - "type": "CloseChannel", - "channel_id": 1, - "reason_code": "You are a bad friend!" - }, - "id": "close_channel" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::open_extended_mining_channel_success" - }, - { - "type": "automatic", - "message_id": "close_channel" - } - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - ] - }, - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x13" - } - ], - "actiondoc": "Checks that OpenExtendedMiningChannel is received" - }, - { - "message_ids": ["open_extended_mining_channel_success"], - "role": "server", - "results": [], - "actiondoc": "This action responds with OpenExtendedMiningChannelSuccess" - }, - { - "message_ids": ["close_channel"], - "role": "server", - "results": [ - {"type": "close_connection"} - ], - "actiondoc": "This action sends a CloseChannel message and validates that the connection is closed" - } - - ], - "setup_commands": [], - "execution_commands": [ - { - "command": "cargo", - "args": [ - "run", - "-p", - "translator_sv2", - "--", - "-c", - "../test/config/tproxy-config-no-jd-sv1-cpu-md.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "PROXY SERVER - ACCEPTING FROM UPSTREAM:", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 420, - "warn_no_panic": false - } - } - } - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "translator_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.sh b/test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.sh deleted file mode 100755 index 0b13c3c9bd..0000000000 --- a/test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo build -p translator_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/pool-sri-test-close-channel/pool-sri-test-close-channel.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.json b/test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.json deleted file mode 100644 index 0cbe477ba4..0000000000 --- a/test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Opens extended channel with the pool", - "Checks that NewMiningJob and SetNewPrevHash is sent by the pool", - "Generates code coverage report for the pool" - ], - "mining_messages": [ - { - "message": { - "type": "OpenExtendedMiningChannel", - "request_id": 90, - "user_identity": "", - "nominal_hash_rate": 10, - "max_target": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], - "min_extranonce_size": 8 - }, - "replace_fields": [["request_id", "ARBITRARY"]], - "id": "open_extended_mining_channel" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_flag_0" - }, - { - "type": "automatic", - "message_id": "open_extended_mining_channel" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_flag_0"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - } - ], - "actiondoc": "This action sends a SetupConnection and checks that receives a message type 0x01, that is SetupConnectionSuccess" - }, - { - "message_ids": ["open_extended_mining_channel"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "MiningProtocol", - "OpenExtendedMiningChannelSuccess", - [ - [ - "extranonce_size", - {"U16": 8} - ] - ] - ] - }, - { - "type": "match_message_type", - "value": "0x1f" - }, - { - "type": "match_message_type", - "value": "0x20" - } - ], - "actiondoc": "This action opens an ExtendedMiningChannel and checks that are received a .Success, NewExtendedMiningJob and SetNewPrevHash" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-config-sri-tp.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.sh b/test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.sh deleted file mode 100755 index a5f3d77230..0000000000 --- a/test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.sh +++ /dev/null @@ -1,7 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/pool-sri-test-extended_0/pool-sri-test-extended_0.json || { echo 'mg test failed' ; exit 1; } diff --git a/test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.json b/test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.json deleted file mode 100644 index ecd4fa743b..0000000000 --- a/test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.json +++ /dev/null @@ -1,153 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Opens extended channel with the pool", - "Checks that NewMiningJob and SetNewPrevHash is sent by the pool", - "Generates code coverage report for the pool" - ], - "mining_messages": [ - { - "message": { - "type": "OpenExtendedMiningChannel", - "request_id": 90, - "user_identity": "", - "nominal_hash_rate": 10, - "max_target": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], - "min_extranonce_size": 3 - }, - "id": "open_extended_mining_channel" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_flag_0" - }, - { - "type": "automatic", - "message_id": "open_extended_mining_channel" - } - ], - "actions": [ - { - "message_ids": ["setup_connection_flag_0"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - } - ], - "actiondoc": "This action sends a SetupConnection and checks that receives a message type 0x01, that is SetupConnectionSuccess" - }, - { - "message_ids": ["open_extended_mining_channel"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "MiningProtocol", - "OpenExtendedMiningChannelSuccess", - [ - [ - "request_id", - {"U32": 90} - ] - ] - ] - }, - { - "type": "match_message_field", - "value": [ - "MiningProtocol", - "NewExtendedMiningJob", - [ - [ - "coinbase_tx_prefix", - {"B064K": [2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 32, 3, 76, 163, 38, 0]} - ], - - [ - "coinbase_tx_suffix", - {"B064K": [255, 255, 255, 255, 1, 64, 190, 64, 37, 0, 0, 0, 0, 22, 0, 20, 235, 225, 183, 220, 194, 147, 204, 170, 14, 231, 67, 168, 111, 137, 223, 130, 88, 194, 8, 252, 1, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} - ] - ] - ] - }, - { - "type": "match_message_type", - "value": "0x20" - } - ], - "actiondoc": "This action opens an ExtendedMiningChannel and checks that are received a .Success, SetNewPrevHash and NewExtendedMiningJob" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/template-provider-mock0.json" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Running `target/debug/message_generator_sv2 ../../test/message-generator/mock/template-provider-mock0.json`", - "output_location": "StdErr", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/pool-mock-tp.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 127.0.0.1:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "late_condition": false, - "conditions": "None" - } - ], - "role": "client", - "downstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.sh b/test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.sh deleted file mode 100755 index 5a53a75090..0000000000 --- a/test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo llvm-cov --no-report -p pool_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/pool-sri-test-extended_1/pool-sri-test-extended_1.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/sv1-test/sv1-test.json b/test/message-generator/test/sv1-test/sv1-test.json deleted file mode 100644 index bd38929b34..0000000000 --- a/test/message-generator/test/sv1-test/sv1-test.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "version": "1", - "doc": [ - "This test does", - "Runs a Sv2 pool", - "Runs the translator proxy", - "Sends sv1 messages to the translator proxy", - "Checks that the correct responses are received" - ], - "sv1_messages": [ - { - "message": { - "id":1, - "method":"mining.configure", - "params":[[],{}] - }, - "id": "mining.configure" - }, - { - "message": { - "id": 2, - "method": "mining.subscribe", - "params": ["cpuminer"] - }, - "id": "mining.subscribe" - }, - { - "message": { - "id": 3, - "method": "mining.authorize", - "params": ["username", "password"] - }, - "id": "mining.authorize" - } - ], - "actions": [ - { - "message_ids": ["mining.configure"], - "results": [ - { - "type": "match_message_id", - "value": 1 - } - ], - "actiondoc": "This action checks that the request and the response have the same id" - }, - { - "message_ids": ["mining.subscribe"], - "results": [ - { - "type": "match_message_id", - "value": 2 - } - ], - "actiondoc": "This action checks that the request and the response have the same id" - }, - { - "message_ids": ["mining.authorize"], - "results": [ - { - "type": "match_message_id", - "value": 3 - } - ], - "actiondoc": "This action checks that the request and the response have the same id" - }, - { - "message_ids": ["mining.authorize"], - "results": [ - { - "type": "match_message_field", - "value": [ - "mining.authorize", - [ - [ - "result", - true - ] - ] - ] - } - ], - "actiondoc": "This action checks that the response returns true as a result" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "-p", - "pool_sv2", - "--", - "-c", - "../test/config/interop-jd-translator/pool-config.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 0.0.0.0:34254", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "translator_sv2", - "--", - "-c", - "../test/config/tproxy-config-no-jd-sv1-cpu-md.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "PROXY SERVER - ACCEPTING FROM UPSTREAM:", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - { - "command": "pkill", - "args": ["-f", "translator_sv2", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "pool_sv2", "-SIGINT"], - "conditions": "None" - } - - ], - "cleanup_commands": [ - ], - "role": "client", - "downstream": { - "ip": "0.0.0.0", - "port": 34255, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72" - } -} diff --git a/test/message-generator/test/sv1-test/sv1-test.sh b/test/message-generator/test/sv1-test/sv1-test.sh deleted file mode 100755 index 99ce8a4c7f..0000000000 --- a/test/message-generator/test/sv1-test/sv1-test.sh +++ /dev/null @@ -1,10 +0,0 @@ -cd roles -cargo build -p pool_sv2 -cargo build -p translator_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/sv1-test/sv1-test.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.json b/test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.json deleted file mode 100644 index caa1330b0f..0000000000 --- a/test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test runs a tproxy and a mock pool. The mock pool responds with SetupConnectionSuccess", - "And then a OpenExtendedMiningChannelSuccess but this message has a bad extranonce size which is way too big.", - "This will cause the tproxy to exit with a good message. This test just validates that the tproxy closes", - "the communication channel with the pool." - ], - "common_messages": [ - ], - "mining_messages": [ - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - }, - { - "type": "automatic", - "message_id": "test/message-generator/messages/mining_messages.json::openEMC_success_tproxy_bad_extranonce" - } - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x00" - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - ] - }, - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x13" - } - ], - "actiondoc": "Checks that OpenExtendedMiningChannel is received" - }, - { - "message_ids": ["openEMC_success_tproxy_bad_extranonce"], - "role": "server", - "results": [ - { - "type": "close_connection" - } - ], - "actiondoc": "Checks that the bad extranonce OEMC.Success fails" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "-p", - "translator_sv2", - "--", - "-c", - "../test/config/tproxy-config-no-jd-sv1-cpu-md.toml" - - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "2mtranslator_sv2", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 260, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "translator_sv2", "-SIGINT"], - "conditions": "None" - } - - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.sh b/test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.sh deleted file mode 100755 index a2a9077c4f..0000000000 --- a/test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.sh +++ /dev/null @@ -1,9 +0,0 @@ -cd roles -cargo build -p translator_sv2 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/translation-proxy-broke-pool/translation-proxy-broke-pool.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.json b/test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.json deleted file mode 100644 index 52ada3a763..0000000000 --- a/test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "version": "1", - "doc": [ - "This test does", - "Mock an Upstream", - "Run tProxy", - "tProxy receives NewExtendedMiningJob (with job_id = 1)", - "tProxy receives mining.authorize", - "tProxy sends mining.notify", - "tProxy receives mining.submit (old/invalid share with job_id=0)" - ], - "sv1_messages": [ - { - "message": { - "id": 1, - "method": "mining.authorize", - "params": ["username", "password"] - }, - "id": "mining.authorize" - }, - { - "message": { - "id": 0, - "method": "mining.submit", - "params": ["username", "0", "0000000000", "641577b0", "7a600640"] - }, - "id": "mining.submit" - } - ], - "frame_builders": [ - ], - "actions": [ - { - "message_ids": ["mining.authorize"], - "results": [ - { - "type": "match_message_id", - "value": 1 - } - ] - }, - { - "message_ids": ["mining.submit"], - "results": [ - { - "type": "match_message_field", - "value": [ - "mining.submit", - [ - [ - "result", - false - ] - ] - ] - } - ], - "actiondoc": "Checks that the mining.submit request (with wrong job_id) generates a response with false, indicating that the share was rejected" - } - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "../../test/message-generator/mock/upstream-mock.json" - ], - "conditions": "None" - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "translator_sv2", - "--", - "-c", - "../test/config/tproxy-config-no-jd-sv1-cpu-md.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 260, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - ], - "role": "client", - "downstream": { - "ip": "0.0.0.0", - "port": 34255 - } -} diff --git a/test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.sh b/test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.sh deleted file mode 100755 index 30149552d9..0000000000 --- a/test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.sh +++ /dev/null @@ -1,11 +0,0 @@ -cd roles - -cargo build -p translator_sv2 -cargo build -p - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/translation-proxy-old-share/translation-proxy-old-share.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/test/message-generator/test/translation-proxy/translation-proxy.json b/test/message-generator/test/translation-proxy/translation-proxy.json deleted file mode 100644 index fb0271b5d8..0000000000 --- a/test/message-generator/test/translation-proxy/translation-proxy.json +++ /dev/null @@ -1,213 +0,0 @@ -{ - "version": "2", - "doc": [ - "This test does", - "Runs a translator proxy", - "Runs mining_device_sv1", - "Waits that receives SetupConnection message", - "Reply with .Success", - "Waits that the tproxy sends OpenExtendedMiningChannel", - "Responds with OpenExtendedMiningChannelSuccess", - "Sends NewExtendedMiningJob and SetNewPrevHash to the tproxy", - "Waits a SubmitsSolutionExtended", - "You can use any miner you want, by changing the execution command or by launching it separately" - ], - "common_messages": [ - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 300, - "used_version": 180 - }, - "replace_fields": [["flags", "setup_connection_success_flag"],["used_version", "setup_connection_success_used_version"]], - "id": "setup_connection_success_tproxy" - } - ], - "mining_messages": [ - { - "message": { - "type": "OpenExtendedMiningChannelSuccess", - "request_id": 666, - "channel_id": 1, - "target": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 55, 55, 55, 25, 25, 0, 0], - "extranonce_size": 16, - "extranonce_prefix": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] - }, - "replace_fields": [["channel_id", "ARBITRARY"], ["request_id","open_extended_mining_channel_success_request_id"], ["target", "open_extended_mining_channel_success_target"]], - "id": "open_extended_mining_channel_success" - }, - { - "message": { - "type": "NewExtendedMiningJob", - "job_id": 1, - "channel_id": 0, - "min_ntime": [], - "version": 536870912, - "version_rolling_allowed": true, - "merkle_path": [], - "coinbase_tx_prefix": [2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 36, 2, 3, 15, 0], - "coinbase_tx_suffix": [255, 255, 255, 255, 2, 149, 0, 0, 0, 0, 0, 0, 0, 67, 65, 4, 70, 109, 127, 202, 229, 99, 229, 203, 9, 160, 209, 135, 11, 181, 128, 52, 72, 4, 97, 120, 121, 161, 73, 73, 207, 34, 40, 95, 27, 174, 63, 39, 103, 40, 23, 108, 60, 100, 49, 248, 238, 218, 69, 56, 220, 55, 200, 101, 226, 120, 79, 58, 158, 119, 208, 68, 243, 62, 64, 119, 151, 225, 39, 138, 172, 0, 0, 0, 0, 0, 0, 0, 0, 38, 106, 36, 170, 33, 169, 237, 226, 246, 28, 63, 113, 209, 222, 253, 63, 169, 153, 223, 163, 105, 83, 117, 92, 105, 6, 137, 121, 153, 98, 180, 139, 235, 216, 54, 151, 78, 140, 249, 1, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - }, - "id": "new_extended_mining_job" - }, - { - "message":{ - "type": "SetNewPrevHash", - "channel_id": 0, - "job_id": 1, - "prev_hash": [91, 30, 84, 205, 18, 124, 218, 102, 28, 163, 155, 204, 173, 55, 119, 61, 224, 199, 68, 229, 144, 22, 92, 0, 53, 44, 15, 204, 200, 245, 149, 0], - "min_ntime": 1679128496, - "nbits": 545259519 - }, - "id": "set_new_prev_hash" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_tproxy" - }, - { - "type": "automatic", - "message_id": "open_extended_mining_channel_success" - }, - { - "type": "automatic", - "message_id": "new_extended_mining_job" - }, - { - "type": "automatic", - "message_id": "set_new_prev_hash" - } - ], - "actions": [ - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "get_message_field", - "value": [ - "CommonMessages", - "SetupConnection", - [ - [ - "flags", - "setup_connection_success_flag" - ], - [ - "min_version", - "setup_connection_success_used_version" - ] - ] - ] - } - ], - "actiondoc": "This action checks that a Setupconnection message is received" - }, - { - "message_ids": ["setup_connection_success_tproxy"], - "role": "server", - "results": [ - ] - }, - { - "message_ids": [], - "role": "server", - "results": [ - { - "type": "get_message_field", - "value": [ - "MiningProtocol", - "OpenExtendedMiningChannel", - [ - [ - "request_id", - "open_extended_mining_channel_success_request_id" - ], - [ - "max_target", - "open_extended_mining_channel_success_target" - ] - ] - ] - } - ], - "actiondoc": "Checks that OpenExtendedMiningChannel is received" - }, - { - "message_ids": ["open_extended_mining_channel_success"], - "role": "server", - "results": [], - "actiondoc": "This action responds with OpenExtendedMiningChannelSuccess" - }, - { - "message_ids": ["new_extended_mining_job", "set_new_prev_hash"], - "role": "server", - "results": [ - { - "type": "match_message_type", - "value": "0x1b" - } - ], - "actiondoc": "Sends NewExtendedMiningJob and SetNewPrevHash and waits that a SubmitsShareExtended is submitted" - } - ], - "setup_commands": [ - ], - "execution_commands": [ - { - "command": "cargo", - "args": [ - "run", - "-p", - "translator_sv2", - "--", - "-c", - "../test/config/tproxy-config-no-jd-sv1-cpu-md.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "PROXY SERVER - ACCEPTING FROM UPSTREAM:", - "output_location": "StdOut", - "late_condition": false, - "condition": true - } - ], - "timer_secs": 320, - "warn_no_panic": false - } - } - }, - { - "command": "cargo", - "args": [ - "run", - "-p", - "mining_device_sv1" - ], - "conditions": "None" - } - ], - "cleanup_commands": [ - { - "command": "pkill", - "args": ["-f", "mining_device_sv1", "-SIGINT"], - "conditions": "None" - }, - { - "command": "pkill", - "args": ["-f", "translator_sv2", "-SIGINT"], - "conditions": "None" - } - ], - "role": "server", - "upstream": { - "ip": "127.0.0.1", - "port": 34254, - "pub_key": "9auqWEzQDVyd2oe1JVGFLMLHZtCo2FFqZwtKA5gd9xbuEu7PH72", - "secret_key": "mkDLTBBRxdBv998612qipDYoTK3YUrqLe8uWw7gu3iXbSrn2n" - } -} diff --git a/test/message-generator/test/translation-proxy/translation-proxy.sh b/test/message-generator/test/translation-proxy/translation-proxy.sh deleted file mode 100755 index 6456a39afa..0000000000 --- a/test/message-generator/test/translation-proxy/translation-proxy.sh +++ /dev/null @@ -1,10 +0,0 @@ -cd roles -cargo build -p translator_sv2 -cargo build -p mining_device_sv1 - -cd ../utils/message-generator/ -cargo build - -RUST_LOG=debug cargo run ../../test/message-generator/test/translation-proxy/translation-proxy.json || { echo 'mg test failed' ; exit 1; } - -sleep 10 diff --git a/utils/Cargo.toml b/utils/Cargo.toml index 43e3c95fe8..c46544a043 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -8,6 +8,4 @@ members = [ "bip32-key-derivation", ] -exclude = [ - "message-generator", -] +exclude = [ ] diff --git a/utils/message-generator/.gitignore b/utils/message-generator/.gitignore deleted file mode 100644 index ea8c4bf7f3..0000000000 --- a/utils/message-generator/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/utils/message-generator/Cargo.toml b/utils/message-generator/Cargo.toml deleted file mode 100644 index bf543a43ee..0000000000 --- a/utils/message-generator/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -[package] -name = "message_generator_sv2" -version = "1.0.3" -authors = ["The Stratum V2 Developers"] -edition = "2021" -description = "message generator" -documentation = "https://github.com/stratum-mining/stratum" -readme = "README.md" -homepage = "https://stratumprotocol.org" -repository = "https://github.com/stratum-mining/stratum" -license = "MIT OR Apache-2.0" -keywords = ["stratum", "mining", "bitcoin", "protocol"] - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -async-channel = "1.8.0" -load_file = "1.0.1" -v1 = { version = "^1.0.0", package="sv1_api" } -serde = { version = "*", features = ["derive", "alloc"], default-features = false } -serde_json = { version = "1.0", default-features = false, features = ["alloc"] } -tokio = { version = "1", features = ["full"] } -arbitrary = { version = "1", features = ["derive"] } -rand = "0.8.5" -secp256k1 = "0.28.2" -tracing = { version = "0.1" } -tracing-subscriber = {version = "0.3", features = ["env-filter"]} -tracing-core = "*" -binary_sv2 = { version = "1.2.1", features = ["with_serde"] } -codec_sv2 = { version = "1.3.1", features = ["noise_sv2","with_buffer_pool","with_serde"] } -const_sv2 = "3.0.0" -network_helpers_sv2 = { version = "2.0.1", features = ["with_tokio","with_serde"] } -roles_logic_sv2 = { version = "1.2.3", features = ["with_serde"] } -key-utils = "1.1.0" diff --git a/utils/message-generator/README.md b/utils/message-generator/README.md deleted file mode 100644 index e4d797ee26..0000000000 --- a/utils/message-generator/README.md +++ /dev/null @@ -1,402 +0,0 @@ -# Message Generator - - -Little utility to execute interoperability tests between SRI and other Sv2 complaint software. - -## Try it -1. Stop any `bitcoind` regtest processes running (the `message-generator` starts it for you). -2. In `test.json` specify `bitcoind`, `bitcoin-cli`, and `datadir` paths: -``` -... - "setup_commands": [ - { - "command": "PATH TO bitcoind", - "args": ["--regtest", "--datadir=PATH TO bitcoin datadir"], - -... - - { - "command": "PATH TO bitcoin-cli", - "args": [ - "--regtest", - "--datadir=PATH TO bitcoin datadir", -... -``` -3. `% cargo run test.json` -4. If the test is in the `/test/message-geneator` directory, you have to lauch it from the MG - directory using relative path. For example, -``` -cargo run ../../test/message-generator/test/pool-sri-test-1-standard.json -``` - -## Test execution - -The message generator executes a test with the following steps: -1. Setup Commands: Executes shell commands or bash scripts to be run on start up, e.g. a `bitcoind` a node. -2. Role Connection: Setups up one or two TCP connections, both plain and noise are supported, e.g. a connection to an Upstream role. -3. Execution Commands: Executes shell commands or bash scripts to be run after a connection has been opened between two roles, e.g. a mocked Pool to a test Proxy. -4. Actions: Executes the actions using the previously opened connection. If a SV2 test is executing, each action - sends zero or more `Sv2Frames` and checks if the received frame satisfies the conditions (defined - in the action). If a SV1 test is executing, each action sends one or more JSON-RPC Requests and checks if the received Response satisfies the conditions. More than one condition can be defined if more than one message is expected to be - received. -5. Cleanup Commands: Executes shell commands or bash scripts to be run on test completion, e.g. remove a `bitcoind` `datadir`. - -## True tests, mocks and modules -The true tests are located in `test/message-generator/test`. Some files have the structure of a -test but in fact they are not. -For example, the file in -`test/message-generator/mock` are mocks of application, namely they are tests whose purpose is -to pretend to be an SV2 role. Currently only the TemplateProvider and the JobDeclarator are the -only roles mocked. These mocks are usually used in the true tests. For example, in the test -`test/message-generator/test/pool-sri-test-standard-1.json` -the pool has a mocked environment, i.e. the JD and TP mocks. -The files in `test/message-generator/messages` also are not true tests, but the are intended to be -modules. For example, the `common_messages.json` is the module that contains the frame builders of -the common messages for the true tests and the mocks. - -True tests are made to be run and produce positive outcome. -Mocks and common messages are meant to work as a part of a true test and they are not supposed to -be run as standalone. - - -## Test format - -Tests are written in json and must follow the below format: - -### version - -`version` is a string that indicates if the test is a SV1 test or a SV2 test. It can be either `"1"` or `"2"`. - -### doc - -`doc` is an array of strings that explain what the test do. This field is optional. - -```json -{ - "doc": [ - "This test do:", - "1) launch bitcoind in regtest and wait for TP initialization", - "2) create a bunch of block using bictoin-cli", - "..." - ] -} -``` - -### common_messages - -`common_messages` is an array of messages (defined below) belonging to the common (sub)protocol, -where the common subprotocol is composed by: `SetupConnection` and `SetupConnectionSuccees` and `SetupConnectionError`. -This field is optional. - -### mining_messages - -`mining_messages` is an array of messages (defined below) belonging to the mining (sub)protocol. This field is optional. - -### job_declaration_messages - -`job_declaration_messages` is an array of messages (defined below) that belongs to the job declaration (sub)protocol. This field is optional. - -### template_distribution_messages - -`template_distribution_messages` is an array of messages (defined below) that belongs to the template distribution (sub)protocol. This field is optional. - -### sv1_messages - -`sv1_messages` is an array of messages that belongs to the SV1 protocol. If `version` is `"2"` this field should be empty. - -**Definition of messages mentioned above** - -A message is an object with two field `message` and `id`. -The `message` field contains the actual message. The `id` field contains a unique id -used to refer to the message in other part of the test. -For SV2 messages, the `message` field is an object composed by: -1. type: message type name as defined in the Sv2 spec is a string eg `SetupConnection` -2. all the other field of that specific message as defined in the Sv2 spec with the only exception - of the field `protocol` that is a string and not a number eg instead of `0` we have - `MiningProtocol` - - -```json -{ - "common_messages": [ - { - "message": { - "type": "SetupConnection", - "protocol": "MiningProtocol", - "min_version": 2, - "max_version": 2, - "flags": 0, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "id": "setup_connection" - } - ] -} -``` - -For SV1 messages, the `message` field is a JSON-RPC StandardRequest, composed by the fields `id`, `method` and `params`. - - -```json -{ - "sv1_messages": [ - { - "message": { - "id": 1, - "method": "mining.subscribe", - "params": ["cpuminer"] - }, - "id": "mining.subscribe" - }, - { - "message": { - "id": 2, - "method": "mining.authorize", - "params": ["username", "password"] - }, - "id": "mining.authorize" - } - ] -} -``` - - -### frame_builders - -Objects in `frame_builders` are used by the message generator to construct Sv2 frames in order to send the message -to the tested software. Objects in `frame_builders` can be either **automatic** (where the sv2 frame header is -constructed by the SRI libs and is supposed to be correct) or **manual** (if we want to test a software -against an incorrect frame). - -`frame_builders` is an array of objects. Every object in `frame_builders` must contain `message_id`, that is a -string with the id of the previously defined message. In the example below, the message id refers to -the item `setup_connection` of `common_messages`. Every object in `frames` must have the -field `type`, a string that can be either `automatic` or `manual` with meaning of the paragraph -above. - -If `type` == `manual` the object must contain 3 additional fields: -1. `message_type`: a string the must start with `0x` followed by an hex encoded integer not bigger - than `0xff` -2. `extension_type`: a string composed by 16 elements, each element must be either `0` or `1`, the - elements can be separated by `_` that is not counted as element so we can have as many - separator as we want eg: `0000_0000_0000_0000` - Separator are there only to human readability and are removed when the test is parsed. -3. `channel_msg`: a `bool` - -```json -{ - "frame_builders": [ - { - "type": "automatic", - "message_id": "setup_connection" - }, - { - "type": "manual", - "message_id": "close_channel", - "message_type": "0x18", - "extension_type": "0000_0000_0000_0000", - "channel_msg": true - } - ] -} -``` -If the frame relative to common messages is defined is a different file (for example, some -common_messages frames are defined in `/test/message-geneator/messages/common_messages.json`), to -use it you have to use the syntax ``. For example, in the test -`/test/message/generator/test`, the following message -``` - { - "type": "automatic", - "message_id": "test/message-generator/messages/common_messages.json::setup_connection_success_template_distribution" - } -``` -calls the id `setup_connection_success_template_distribution` that appears in the file -`test/message-generator/messages/common_messages.json`. In the main file, the id of this -message will be the abbreviated with `setup_connection_success_template_distribution`. - - - -### actions - -`actions` is an array of objects. If the test version is "2", each object is composed by: -1. `role`: can be either `client` or `server`. This because the message generator can act at the - same time as a client and as a server for example when we are mocking a proxy. -2. `messages_ids`: an array of strings, that are ids of messages previously defined. -3. `results`: is an array of objects, used by the message generator to test if certain property of - the received frames are true or not. Accepts values: - - "type": String - match option - match_message_type, match_message_field, match_message_len, or match_extension_type - - "value": Array - varries depending on "type" - -```json -{ - "actions": [ - { - "message_ids": ["open_standard_mining_channel"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "MiningProtocol", - "OpenStandardMiningChannelSuccess", - [ - "request_id", - {"U32": 89} - ] - ] - } - ] - } - ] -} -``` - -If the test version is "1", each object is composed by: -1. `messages_ids`: an array of strings, that are ids of sv1_messages previously defined. -2. `results`: is an array of objects, used by the message generator to test if certain property of - the received Responses are true or not. Accepts values: - - "type": String - match option - match_message_id, match_message_field - - "value": Array - varries depending on "type" - -### setup commands - -An array of commands (defined below) that are executed before that the message generator open one -ore more connection with the tested software. - -### excution commands - -An array of commands (defined below) that are executed after that the message generator open one -ore more connection with the tested software. - -### cleanup_commands commands - -An array of commands (defined below) that are executed after that all the actions have been executed. -TODO this commands should be executed not only if all the action pass but also if something fail - -**Definition of commands mentioned above** - -A command is an object with the following fields: -1. `command`: the bash command that we want to execute -2. `args`: the command's args -3. `condition`: can be either `WithConditions` or `None` in the first case the command executor - will wait for some condition before return in the latter it just launch the command and return - -`WithConditions` is an object composed by the following fields: -1. `conditions`: an array of object that must be true or false on order for the executor to - return -2. `timer_secs`: number of seconds after then the command is considered stuck and the test fail -3. `warn_no_panic`: `bool` if true the test do not fail with panic if timer secs terminate but it - just exit (passing) and emit a warning - -The objects contained in conditions are structured in the following way: -1. `output_string`: a string that we need to check in the StdOut or StdErr -2. `output_location`: say if the string is expected in StdOut or StdErr -3. `condition`: a `bool` if true and we have `output_string` in `output_location` the executor return - and keep going, if false the executor fail. - -In the below example we launch `bitcoind` we wait for `"sv2 thread start"` in StdOut and we fail if -anything is written in StdErr -```json -{ - "setup_commands": [ - { - "command": "./test/bitcoind", - "args": ["--regtest", "--datadir=./test/bitcoin_data/"], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "sv2 thread start", - "output_location": "StdOut", - "condition": true - }, - { - "output_string": "", - "output_location": "StdErr", - "condition": false - } - ], - "timer_secs": 10, - "warn_no_panic": false - } - } - } - ] -} -``` - -### role - -`role` is a string and can be on of the three: client server proxy -1. If we have client we expect to have a `downstream` field -2. If we have server we expect to have an `upstream` field -3. If we have proxy we expect to have both - -### downstream - -`downstream` is an object the contain the info need to open a connection as a downstream is composed by: -1. `ip`: a string with the upstream ip address -2. `port`: a string with the port address -3. `pub_key`: optional if present we open a noise connection if no we open a plain connection, is a - string with the server public key - -### upstream - -`upstream` is an object the contain the info need to start listening: -1. `ip`: a string with the ip where we will accept connection -2. `port`: a string with the port address -3. `pub_key`: optional if present accept noise connection if no plain connection -3. `secret_key`: optional if present accept noise connection if no plain connection - -## Using Message Generator to produce test coverage with llvm-cov - -Information on installation and use of llvm-cov found here: https://crates.io/crates/cargo-llvm-cov/0.1.13 -More information on underlying dependancies here: https://doc.rust-lang.org/rustc/instrument-coverage.html - -### Including code coverage in command - -Example of llvm-cov code coverage run with pool setup_command -llvm-cov requires a minimum of rustc 1.60.0 and LLVM 13.0.0 - -```json - { - "command": "cargo", - "args": [ - "llvm-cov", - "--no-report", - "run", - "-p", - "pool", - "--", - "-c", - "./roles/v2/pool/pool-config.toml" - ], - "conditions": {...} - }, -``` - -`"--no-report"` caches the results in the background until the end of the test. It also allows you collect coverage data from other processes in parallel by adding `"llv-cov --no-report"`, and all report data is reflected in the final report. - -To generate the report, execute the `llvm-cov report` command in the cleanup_commands. This example adds an output file path(from project root), the output file name and type, and paths to ignore in the report. - -```json - "cleanup_commands": [ - { - "command": "cargo", - "args": [ - "llvm-cov", - "--ignore-filename-regex", - "utils/|experimental/|protocols/", - "--output-path", - "target/tmp/pool_translator_cov.txt", - "report" - ], - "conditions": "None" - } - ] -``` diff --git a/utils/message-generator/src/executor.rs b/utils/message-generator/src/executor.rs deleted file mode 100644 index 64123475c0..0000000000 --- a/utils/message-generator/src/executor.rs +++ /dev/null @@ -1,1237 +0,0 @@ -use crate::{ - external_commands::os_command, - into_static::into_static, - net::{setup_as_downstream, setup_as_upstream}, - parser::sv2_messages::ReplaceField, - Action, ActionResult, Command, Role, SaveField, Sv2Type, Test, -}; -use async_channel::{Receiver, Sender}; -use binary_sv2::Serialize; -use codec_sv2::{StandardEitherFrame as EitherFrame, Sv2Frame}; -use roles_logic_sv2::parsers::{self, AnyMessage}; -use std::{collections::HashMap, convert::TryInto, sync::Arc}; - -use tracing::{debug, error, info}; - -pub struct Executor { - #[allow(dead_code)] - name: Arc, - send_to_down: Option>>>, - recv_from_down: Option>>>, - send_to_up: Option>>>, - recv_from_up: Option>>>, - actions: Vec>, - cleanup_commmands: Vec, - process: Vec>, - save: HashMap, -} - -impl Executor { - pub async fn new(test: Test<'static>, test_name: String) -> Executor { - let save: HashMap = HashMap::new(); - let mut process: Vec> = vec![]; - for command in test.setup_commmands { - if command.command == "kill" { - let index: usize = command.args[0].parse().unwrap(); - let p = process[index].as_mut(); - let mut pid = p.as_ref().unwrap().id(); - // Kill process - p.unwrap().kill().await.expect("Failed to kill process"); - // Wait until the process is killed to move on - while pid.is_some() { - let p = process[index].as_mut(); - pid = p.as_ref().unwrap().id(); - if p.unwrap().kill().await.is_err() { - error!("Process already dead"); - }; - tokio::time::sleep(std::time::Duration::from_millis(1000)).await; - } - let _p = process[index].as_mut(); - } else if command.command == "sleep" { - let ms: u64 = command.args[0].parse().unwrap(); - tokio::time::sleep(std::time::Duration::from_millis(ms)).await; - } else { - let p = os_command( - &command.command, - command.args.iter().map(String::as_str).collect(), - command.conditions, - ) - .await; - process.push(p); - } - } - match (test.as_dowstream, test.as_upstream) { - (Some(as_down), Some(as_up)) => { - let (recv_from_down, send_to_down) = setup_as_upstream( - as_up.addr, - as_up.keys, - test.execution_commands, - &mut process, - ) - .await; - let (recv_from_up, send_to_up) = - setup_as_downstream(as_down.addr, as_down.key).await; - Self { - name: Arc::new(test_name.clone()), - send_to_down: Some(send_to_down), - recv_from_down: Some(recv_from_down), - send_to_up: Some(send_to_up), - recv_from_up: Some(recv_from_up), - actions: test.actions.unwrap(), - cleanup_commmands: test.cleanup_commmands, - process, - save, - } - } - (None, Some(as_up)) => { - let (recv_from_down, send_to_down) = setup_as_upstream( - as_up.addr, - as_up.keys, - test.execution_commands, - &mut process, - ) - .await; - Self { - name: Arc::new(test_name.clone()), - send_to_down: Some(send_to_down), - recv_from_down: Some(recv_from_down), - send_to_up: None, - recv_from_up: None, - actions: test.actions.unwrap(), - cleanup_commmands: test.cleanup_commmands, - process, - save, - } - } - (Some(as_down), None) => { - let (recv_from_up, send_to_up) = - setup_as_downstream(as_down.addr, as_down.key).await; - Self { - name: Arc::new(test_name.clone()), - send_to_down: None, - recv_from_down: None, - send_to_up: Some(send_to_up), - recv_from_up: Some(recv_from_up), - actions: test.actions.unwrap(), - cleanup_commmands: test.cleanup_commmands, - process, - save, - } - } - (None, None) => Self { - name: Arc::new(test_name.clone()), - send_to_down: None, - recv_from_down: None, - send_to_up: None, - recv_from_up: None, - actions: test.actions.unwrap(), - cleanup_commmands: test.cleanup_commmands, - process, - save, - }, - } - } - - pub async fn execute(mut self) { - let mut success = true; - for action in self.actions { - if let Some(doc) = action.actiondoc { - info!("actiondoc: {}", doc); - } - let (sender, recv) = match action.role { - Role::Upstream => ( - self.send_to_down - .as_ref() - .expect("Action require executor to act as upstream"), - self.recv_from_down - .as_ref() - .expect("Action require executor to act as upstream"), - ), - Role::Downstream => ( - self.send_to_up - .as_ref() - .expect("Action require executor to act as downstream"), - self.recv_from_up - .as_ref() - .expect("Action require executor to act as downstream"), - ), - Role::Proxy => panic!("Action can be either executed as Downstream or Upstream"), - }; - for message_ in action.messages { - let replace_fields = message_.2.clone(); - let message = message_.1.clone(); - let arbitrary_fields: Vec = replace_fields - .clone() - .into_iter() - .filter(|s| s.keyword == "ARBITRARY") - .collect(); - let replace_fields: Vec = replace_fields - .clone() - .into_iter() - .filter(|s| s.keyword != "ARBITRARY") - .collect(); - - let message = if !arbitrary_fields.is_empty() { - let message = change_fields_with_arbitrary_value(message, arbitrary_fields); - message - } else { - message - }; - let message = if !replace_fields.is_empty() { - change_fields(message.clone(), replace_fields, self.save.clone()) - } else { - message - }; - let frame = EitherFrame::Sv2(message.clone().try_into().unwrap()); - debug!("SEND {:#?}", message); - match sender.send(frame).await { - Ok(_) => (), - Err(_) => panic!(), - }; - } - let mut rs = 0; - for result in &action.result { - rs += 1; - info!( - "Working on result {}/{}: {}", - rs, - action.result.len(), - result - ); - - match result { - ActionResult::MatchMessageType(message_type) => { - let message = match recv.recv().await { - Ok(message) => message, - Err(_) => { - success = false; - error!("Connection closed before receiving the message"); - break; - } - }; - - let message: Sv2Frame, _> = message.try_into().unwrap(); - debug!("RECV {:#?}", message); - let header = message.get_header().unwrap(); - - if header.msg_type() != *message_type { - error!( - "WRONG MESSAGE TYPE expected: {} received: {}", - message_type, - header.msg_type() - ); - success = false; - break; - } else { - info!("MATCHED MESSAGE TYPE {}", message_type); - } - } - ActionResult::MatchMessageField(( - subprotocol, - message_type, - field_data, // Vec<(String, Sv2Type)> - )) => { - let message = match recv.recv().await { - Ok(message) => message, - Err(_) => { - success = false; - error!("Connection closed before receiving the message"); - break; - } - }; - - let mut message: Sv2Frame, _> = - message.try_into().unwrap(); - debug!("RECV {:#?}", message); - let header = message.get_header().unwrap(); - let payload = message.payload(); - if subprotocol.as_str() == "CommonMessages" { - match (header.msg_type(), payload).try_into() { - Ok(roles_logic_sv2::parsers::CommonMessages::SetupConnection(m)) => { - if message_type.as_str() == "SetupConnection" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::CommonMessages::SetupConnectionError(m)) => { - if message_type.as_str() == "SetupConnectionError" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::CommonMessages::SetupConnectionSuccess(m)) => { - if message_type.as_str() == "SetupConnectionSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::CommonMessages::ChannelEndpointChanged(m)) => { - if message_type.as_str() == "ChannelEndpointChanged" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Err(e) => panic!("{:?}", e), - } - } else if subprotocol.as_str() == "MiningProtocol" { - match (header.msg_type(), payload).try_into() { - Ok(roles_logic_sv2::parsers::Mining::OpenExtendedMiningChannel(m)) => { - if message_type.as_str() == "OpenExtendedMiningChannel" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::OpenStandardMiningChannel(m)) => { - if message_type.as_str() == "OpenStandardMiningChannel" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::OpenStandardMiningChannelSuccess(m)) => { - if message_type.as_str() == "OpenStandardMiningChannelSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::CloseChannel(m)) => { - if message_type.as_str() == "CloseChannel" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::NewMiningJob(m)) => { - if message_type.as_str() == "NewMiningJob" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::NewExtendedMiningJob(m)) => { - if message_type.as_str() == "NewExtendedMiningJob" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetTarget(m)) => { - if message_type.as_str() == "SetTarget" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SubmitSharesError(m)) => { - if message_type.as_str() == "SubmitSharesError" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SubmitSharesStandard(m)) => { - if message_type.as_str() == "SubmitSharesStandard" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SubmitSharesSuccess(m)) => { - if message_type.as_str() == "SubmitSharesSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SubmitSharesExtended(m)) => { - if message_type.as_str() == "SubmitSharesExtended" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetCustomMiningJob(m)) => { - if message_type.as_str() == "SetCustomMiningJob" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetCustomMiningJobError(m)) => { - if message_type.as_str() == "SetCustomMiningJobError" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::OpenExtendedMiningChannelSuccess(m)) => { - if message_type.as_str() == "OpenExtendedMiningChannelSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::OpenMiningChannelError(m)) => { - if message_type.as_str() == "OpenMiningChannelError" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::Reconnect(m)) => { - if message_type.as_str() == "Reconnect" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetCustomMiningJobSuccess(m)) => { - if message_type.as_str() == "SetCustomMiningJobSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetExtranoncePrefix(m)) => { - if message_type.as_str() == "SetExtranoncePrefix" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetGroupChannel(m)) => { - if message_type.as_str() == "SetGroupChannel" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::SetNewPrevHash(m)) => { - if message_type.as_str() == "SetNewPrevHash" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::UpdateChannel(m)) => { - if message_type.as_str() == "UpdateChannel" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::Mining::UpdateChannelError(m)) => { - if message_type.as_str() == "UpdateChannelError" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Err(e) => panic!("err {:?}", e), - } - } else if subprotocol.as_str() == "JobDeclarationProtocol" { - match (header.msg_type(), payload).try_into() { - Ok(roles_logic_sv2::parsers::JobDeclaration::AllocateMiningJobTokenSuccess(m)) => { - if message_type.as_str() == "AllocateMiningJobTokenSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::AllocateMiningJobToken(m)) => { - if message_type.as_str() == "AllocateMiningJobToken" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::DeclareMiningJob(m)) => { - if message_type.as_str() == "DeclareMiningJob" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::DeclareMiningJobSuccess(m)) => { - if message_type.as_str() == "DeclareMiningJobSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::DeclareMiningJobError(m)) => { - if message_type.as_str() == "DeclareMiningJobSuccess" { - let msg = serde_json::to_value(&m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::IdentifyTransactions(m)) => { - if message_type.as_str() == "AllocateMiningJobTokenSuccess" { - let msg = serde_json::to_value(&m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::IdentifyTransactionsSuccess(m)) => { - if message_type.as_str() == "AllocateMiningJobTokenSuccess" { - let msg = serde_json::to_value(&m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::ProvideMissingTransactions(m)) => { - if message_type.as_str() == "AllocateMiningJobTokenSuccess" { - let msg = serde_json::to_value(&m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::ProvideMissingTransactionsSuccess(m)) => { - if message_type.as_str() == "AllocateMiningJobTokenSuccess" { - let msg = serde_json::to_value(&m).unwrap(); - check_each_field(msg, field_data); - } - } - Ok(roles_logic_sv2::parsers::JobDeclaration::SubmitSolution(m)) => { - if message_type.as_str() == "SubmitSolution" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Err(e) => panic!("err {:?}", e), - } - } else if subprotocol.as_str() == "TemplateDistributionProtocol" { - match (header.msg_type(), payload).try_into() { - Ok(roles_logic_sv2::parsers::TemplateDistribution::SubmitSolution(m)) => { - if message_type.as_str() == "SubmitSolution" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::TemplateDistribution::NewTemplate(m)) => { - if message_type.as_str() == "NewTemplate" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::TemplateDistribution::SetNewPrevHash(m)) => { - if message_type.as_str() == "SetNewPrevHash" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::TemplateDistribution::CoinbaseOutputDataSize(m)) => { - if message_type.as_str() == "CoinbaseOutputDataSize" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::TemplateDistribution::RequestTransactionData(m)) => { - if message_type.as_str() == "RequestTransactionData" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::TemplateDistribution::RequestTransactionDataError(m)) => { - if message_type.as_str() == "RequestTransactionDataError" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Ok(roles_logic_sv2::parsers::TemplateDistribution::RequestTransactionDataSuccess(m)) => { - if message_type.as_str() == "RequestTransactionDataSuccess" { - let msg = serde_json::to_value(m).unwrap(); - check_each_field(msg, field_data); - } - }, - Err(e) => panic!("err {:?}", e), - } - } else { - info!( - "match_message_field subprotocol not valid - received: {}", - subprotocol - ); - panic!() - } - } - ActionResult::GetMessageField { - subprotocol, - message_type: _, - fields, - } => { - let message = match recv.recv().await { - Ok(message) => message, - Err(_) => { - success = false; - error!("Connection closed before receiving the message"); - break; - } - }; - - let mut message: Sv2Frame, _> = - message.try_into().unwrap(); - debug!("RECV {:#?}", message); - let header = message.get_header().unwrap(); - let payload = message.payload(); - if subprotocol.as_str() == "CommonMessages" { - match (header.msg_type(), payload).try_into() { - Ok(parsers::CommonMessages::SetupConnection(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::CommonMessages::SetupConnectionError(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::CommonMessages::ChannelEndpointChanged(m)) => { - let mess = serde_json::to_value(m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::CommonMessages::SetupConnectionSuccess(m)) => { - let mess = serde_json::to_value(m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Err(e) => panic!("err {:?}", e), - } - } else if subprotocol.as_str() == "MiningProtocol" { - match (header.msg_type(), payload).try_into() { - Ok(parsers::Mining::OpenExtendedMiningChannel(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::OpenExtendedMiningChannelSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::OpenStandardMiningChannel(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::OpenStandardMiningChannelSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::CloseChannel(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::NewMiningJob(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::NewExtendedMiningJob(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetTarget(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SubmitSharesError(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SubmitSharesStandard(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SubmitSharesSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SubmitSharesExtended(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::OpenMiningChannelError(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::Reconnect(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetCustomMiningJobSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetExtranoncePrefix(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetGroupChannel(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetNewPrevHash(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::UpdateChannel(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::UpdateChannelError(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetCustomMiningJob(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::Mining::SetCustomMiningJobError(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Err(e) => panic!("err {:?}", e), - } - } else if subprotocol.as_str() == "JobDeclarationProtocol" { - match (header.msg_type(), payload).try_into() { - Ok(parsers::JobDeclaration::AllocateMiningJobTokenSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::JobDeclaration::AllocateMiningJobToken(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::JobDeclaration::DeclareMiningJob(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::JobDeclaration::DeclareMiningJobSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(roles_logic_sv2::parsers::JobDeclaration::DeclareMiningJobError(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(roles_logic_sv2::parsers::JobDeclaration::IdentifyTransactions(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(roles_logic_sv2::parsers::JobDeclaration::IdentifyTransactionsSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(roles_logic_sv2::parsers::JobDeclaration::ProvideMissingTransactions(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(roles_logic_sv2::parsers::JobDeclaration::ProvideMissingTransactionsSuccess(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::JobDeclaration::SubmitSolution(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Err(e) => panic!("err {:?}", e), - } - } else if subprotocol.as_str() == "TemplateDistributionProtocol" { - match (header.msg_type(), payload).try_into() { - Ok(parsers::TemplateDistribution::SubmitSolution(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::TemplateDistribution::NewTemplate(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::TemplateDistribution::SetNewPrevHash(m)) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::TemplateDistribution::CoinbaseOutputDataSize(m)) => { - let mess = serde_json::to_value(m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::TemplateDistribution::RequestTransactionData(m)) => { - let mess = serde_json::to_value(m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok(parsers::TemplateDistribution::RequestTransactionDataError( - m, - )) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Ok( - parsers::TemplateDistribution::RequestTransactionDataSuccess(m), - ) => { - let mess = serde_json::to_value(&m).unwrap(); - self.save = save_message_field(mess, self.save.clone(), fields); - } - Err(e) => panic!("err {:?}", e), - } - } else { - error!("GetMessageField not implemented for this protocol",); - panic!() - }; - } - ActionResult::MatchMessageLen(message_len) => { - let message = match recv.recv().await { - Ok(message) => message, - Err(_) => { - success = false; - error!("Connection closed before receiving the message"); - break; - } - }; - - let mut message: Sv2Frame, _> = - message.try_into().unwrap(); - debug!("RECV {:#?}", message); - let payload = message.payload(); - if payload.len() != *message_len { - error!( - "WRONG MESSAGE len expected: {} received: {}", - message_len, - payload.len() - ); - success = false; - break; - } - } - ActionResult::MatchExtensionType(ext_type) => { - let message = match recv.recv().await { - Ok(message) => message, - Err(_) => { - success = false; - error!("Connection closed before receiving the message"); - break; - } - }; - - let message: Sv2Frame, _> = message.try_into().unwrap(); - debug!("RECV {:#?}", message); - let header = message.get_header().unwrap(); - if header.ext_type() != *ext_type { - error!( - "WRONG EXTENSION TYPE expected: {} received: {}", - ext_type, - header.ext_type() - ); - success = false; - break; - } - } - ActionResult::CloseConnection => { - info!( - "Waiting 1 sec to make sure that remote has time to close the connection" - ); - tokio::time::sleep(std::time::Duration::from_secs(1)).await; - if !recv.is_closed() { - error!("Expected connection to close, but it didn't. Test failed."); - success = false; - break; - } - } - ActionResult::SustainConnection => { - info!( - "Waiting 1 sec to make sure that remote has time to close the connection" - ); - tokio::time::sleep(std::time::Duration::from_secs(1)).await; - if recv.is_closed() { - error!("Expected connection to sustain, but it didn't. Test failed."); - success = false; - break; - } - } - ActionResult::None => todo!(), - } - } - } - for command in self.cleanup_commmands { - os_command( - &command.command, - command.args.iter().map(String::as_str).collect(), - command.conditions, - ) - // Give time to the last cleanup command to return before exit from the process - .await - .unwrap() - .wait() - .await - .unwrap(); - } - - #[allow(clippy::manual_flatten)] - for child in self.process { - if let Some(mut child) = child { - while child.id().is_some() { - // Sends kill signal and waits 1 second before checking to ensure child was - // killed - child.kill().await.expect("Failed to kill child process"); - tokio::time::sleep(std::time::Duration::from_millis(1000)).await; - } - } - } - if !success { - panic!("test failed!!!"); - } - } -} - -fn change_fields( - m: AnyMessage<'_>, - replace_fields: Vec, - values: HashMap, -) -> AnyMessage<'static> { - let mut replace_fields = replace_fields; - let next = replace_fields - .pop() - .expect("replace_fields cannot be empty"); - let keyword = next.keyword; - let field_name = next.field_name; - let value = values - .get(&keyword) - .expect("value not found for the keyword"); - - match m.clone() { - AnyMessage::Common(m) => { - let m_ = change_value_of_serde_field(m, value, field_name); - let m_ = into_static(AnyMessage::Common(serde_json::from_str(&m_).unwrap())); - if replace_fields.is_empty() { - m_ - } else { - change_fields(m_, replace_fields, values) - } - } - AnyMessage::Mining(m) => { - let m_ = change_value_of_serde_field(m, value, field_name); - let m_ = into_static(AnyMessage::Mining(serde_json::from_str(&m_).unwrap())); - if replace_fields.is_empty() { - m_ - } else { - change_fields(m_, replace_fields, values) - } - } - AnyMessage::JobDeclaration(m) => { - let m_ = change_value_of_serde_field(m, value, field_name); - let m_ = into_static(AnyMessage::JobDeclaration( - serde_json::from_str(&m_).unwrap(), - )); - if replace_fields.is_empty() { - m_ - } else { - change_fields(m_, replace_fields, values) - } - } - AnyMessage::TemplateDistribution(m) => { - let m_ = change_value_of_serde_field(m, value, field_name); - let m_ = into_static(AnyMessage::TemplateDistribution( - serde_json::from_str(&m_).unwrap(), - )); - if replace_fields.is_empty() { - m_ - } else { - change_fields(m_, replace_fields, values) - } - } - } -} - -fn change_value_of_serde_field( - message: T, - value: &serde_json::Value, - field_name: String, -) -> String { - let mut message_as_serde_value = serde_json::to_value(&message).unwrap(); - let path = message_as_serde_value - .as_object() - .unwrap() - .keys() - .next() - .unwrap() - .clone(); - *message_as_serde_value - .pointer_mut(&format!("/{}/{}", path, field_name.as_str())) - .unwrap() = value.clone(); - serde_json::to_string(&message_as_serde_value).unwrap() -} - -fn change_fields_with_arbitrary_value( - m: AnyMessage<'_>, - arbitrary_fields: Vec, -) -> AnyMessage<'_> { - let mut replace_fields: Vec = Vec::new(); - let mut save: HashMap = HashMap::new(); - - for field_to_be_replaced in arbitrary_fields.iter() { - let replace_field = ReplaceField { - field_name: field_to_be_replaced.clone().field_name, - keyword: field_to_be_replaced.clone().field_name, - }; - replace_fields.push(replace_field); - let value = get_arbitrary_message_value_from_string_id( - m.clone(), - field_to_be_replaced.field_name.clone(), - ); - save.insert(field_to_be_replaced.clone().field_name, value); - } - change_fields(m, replace_fields, save) -} -fn save_message_field( - mess: serde_json::Value, - mut save: HashMap, - fields: &Vec, -) -> HashMap { - for field in fields { - let key = field.keyword.clone(); - let field_name = &field.field_name; - let to_save = message_to_value(&mess, field_name); - save.insert(key, to_save.clone()); - } - save -} - -fn check_msg_field(msg: serde_json::Value, field_name: &str, value_type: &str, field: &Sv2Type) { - let msg = msg.as_object().unwrap(); - let value = msg - .get(field_name) - .expect("match_message_field field name is not valid") - .clone(); - let value = serde_json::to_string(&value).unwrap(); - let value = format!(r#"{{"{}":{}}}"#, value_type, value); - let value: crate::Sv2Type = serde_json::from_str(&value).unwrap(); - assert!( - field == &value, - "match_message_field value is incorrect. Expected = {:?}, Recieved = {:?}", - field, - value - ) -} - -fn check_each_field(msg: serde_json::Value, field_info: &Vec<(String, Sv2Type)>) { - for field in field_info { - let value_type = serde_json::to_value(&field.1) - .unwrap() - .as_object() - .unwrap() - .keys() - .next() - .unwrap() - .to_string(); - - check_msg_field(msg.clone(), &field.0, &value_type, &field.1) - } -} -fn message_to_value<'a>(m: &'a serde_json::Value, field: &str) -> &'a serde_json::Value { - let msg = m.as_object().unwrap(); - let value = msg.get(field).unwrap_or_else(|| { - panic!( - "{}", - format!("Fail with message {:?} for field {}", m, field).to_string() - ) - }); - value -} - -// to be unified with GetMessageField logic -fn get_arbitrary_message_value_from_string_id( - message: AnyMessage<'_>, - field_id: String, -) -> serde_json::Value { - match message { - roles_logic_sv2::parsers::PoolMessages::Common(m) => match m { - roles_logic_sv2::parsers::CommonMessages::ChannelEndpointChanged(message) => { - let field_id = field_id.as_str(); - if field_id == "channel_id" { - let value_new = Sv2Type::U32(message.channel_id).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else { - panic!("unknown message field"); - } - } - roles_logic_sv2::parsers::CommonMessages::SetupConnection(message) => { - let field_id = field_id.as_str(); - if field_id == "flags" { - let value_new = Sv2Type::U32(message.flags).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "protocol" { - let value_new = Sv2Type::U8(message.protocol.into()).arbitrary(); - if let Sv2Type::U8(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "max_version" { - let value_new = Sv2Type::U16(message.max_version).arbitrary(); - if let Sv2Type::U16(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "min_version" { - let value_new = Sv2Type::U16(message.min_version).arbitrary(); - if let Sv2Type::U16(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "endpoint_host" { - let value_new = Sv2Type::B0255(message.endpoint_host.to_vec()).arbitrary(); - if let Sv2Type::Str0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "endpoint_port" { - let value_new = Sv2Type::U16(message.endpoint_port).arbitrary(); - if let Sv2Type::U16(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "vendor" { - let value_new = Sv2Type::B0255(message.vendor.to_vec()).arbitrary(); - if let Sv2Type::Str0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "hardware_version" { - let value_new = Sv2Type::B0255(message.hardware_version.to_vec()).arbitrary(); - if let Sv2Type::Str0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "firmware" { - let value_new = Sv2Type::B0255(message.firmware.to_vec()).arbitrary(); - if let Sv2Type::Str0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "device_id" { - let value_new = Sv2Type::B0255(message.device_id.to_vec()).arbitrary(); - if let Sv2Type::Str0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else { - panic!("unknown message field"); - } - } - roles_logic_sv2::parsers::CommonMessages::SetupConnectionError(message) => { - let field_id = field_id.as_str(); - if field_id == "flags" { - let value_new = Sv2Type::U32(message.flags).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "error_code" { - let value_new = Sv2Type::B0255(message.error_code.to_vec()).arbitrary(); - if let Sv2Type::Str0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else { - panic!("unknown message field"); - } - } - roles_logic_sv2::parsers::CommonMessages::SetupConnectionSuccess(message) => { - let field_id = field_id.as_str(); - if field_id == "flags" { - let value_new = Sv2Type::U32(message.flags).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "used_version" { - let value_new = Sv2Type::U16(message.used_version).arbitrary(); - if let Sv2Type::U16(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else { - panic!("unknown message field"); - } - } - }, - roles_logic_sv2::parsers::PoolMessages::Mining(m) => match m { - roles_logic_sv2::parsers::Mining::CloseChannel(_) => todo!(), - roles_logic_sv2::parsers::Mining::NewExtendedMiningJob(_) => todo!(), - roles_logic_sv2::parsers::Mining::NewMiningJob(_) => todo!(), - roles_logic_sv2::parsers::Mining::OpenExtendedMiningChannel(message) => { - let field_id = field_id.as_str(); - if field_id == "request_id" { - let value_new = Sv2Type::U32(message.request_id).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "user_identity" { - let value_new = Sv2Type::B0255(message.user_identity.to_vec()).arbitrary(); - if let Sv2Type::B0255(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "nominal_hashrate" { - panic!("f32 not implemented yet as Sv2Type for the message generator") - } else if field_id == "max_target" { - let value_new = Sv2Type::U256(message.max_target.to_vec()).arbitrary(); - if let Sv2Type::U256(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "min_extranonce_size" { - let value_new = Sv2Type::U16(message.min_extranonce_size).arbitrary(); - if let Sv2Type::U256(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else { - panic!("unknown message field"); - } - } - roles_logic_sv2::parsers::Mining::OpenExtendedMiningChannelSuccess(message) => { - let field_id = field_id.as_str(); - if field_id == "channel_id" { - let value_new = Sv2Type::U32(message.channel_id).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "request_id" { - let value_new = Sv2Type::U32(message.request_id).arbitrary(); - if let Sv2Type::U32(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "target" { - let value_new = Sv2Type::U256(message.target.to_vec()).arbitrary(); - if let Sv2Type::U256(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else if field_id == "extranonce_prefix" { - let value_new = Sv2Type::B032(message.extranonce_prefix.to_vec()).arbitrary(); - if let Sv2Type::U256(inner) = value_new { - serde_json::to_value(inner).unwrap() - } else { - todo!() - } - } else { - panic!("unknown message field"); - } - } - roles_logic_sv2::parsers::Mining::OpenMiningChannelError(_) => todo!(), - roles_logic_sv2::parsers::Mining::OpenStandardMiningChannel(_) => todo!(), - roles_logic_sv2::parsers::Mining::OpenStandardMiningChannelSuccess(_) => todo!(), - roles_logic_sv2::parsers::Mining::Reconnect(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetCustomMiningJob(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetCustomMiningJobError(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetCustomMiningJobSuccess(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetExtranoncePrefix(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetGroupChannel(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetNewPrevHash(_) => todo!(), - roles_logic_sv2::parsers::Mining::SetTarget(_) => todo!(), - roles_logic_sv2::parsers::Mining::SubmitSharesError(_) => todo!(), - roles_logic_sv2::parsers::Mining::SubmitSharesExtended(_) => todo!(), - roles_logic_sv2::parsers::Mining::SubmitSharesStandard(_) => todo!(), - roles_logic_sv2::parsers::Mining::SubmitSharesSuccess(_) => todo!(), - roles_logic_sv2::parsers::Mining::UpdateChannel(_) => todo!(), - roles_logic_sv2::parsers::Mining::UpdateChannelError(_) => todo!(), - }, - roles_logic_sv2::parsers::PoolMessages::JobDeclaration(_) => todo!(), - roles_logic_sv2::parsers::PoolMessages::TemplateDistribution(_) => todo!(), - } -} diff --git a/utils/message-generator/src/executor_sv1.rs b/utils/message-generator/src/executor_sv1.rs deleted file mode 100644 index 9da74c9343..0000000000 --- a/utils/message-generator/src/executor_sv1.rs +++ /dev/null @@ -1,206 +0,0 @@ -use crate::{ - external_commands::os_command, net::setup_as_sv1_downstream, Command, Sv1Action, - Sv1ActionResult, Test, -}; -use async_channel::{Receiver, Sender}; -use std::{collections::HashMap, sync::Arc}; -use v1::Message; - -use tracing::{debug, error, info}; - -pub struct Sv1Executor { - #[allow(dead_code)] - name: Arc, - send_to_up: Option>, - recv_from_up: Option>, - actions: Vec, - cleanup_commmands: Vec, - process: Vec>, - #[allow(dead_code)] // TODO why we have it? - save: HashMap, -} - -impl Sv1Executor { - pub async fn new(test: Test<'static>, test_name: String) -> Sv1Executor { - let save: HashMap = HashMap::new(); - let mut process: Vec> = vec![]; - for command in test.setup_commmands { - if command.command == "kill" { - let index: usize = command.args[0].parse().unwrap(); - let p = process[index].as_mut(); - let mut pid = p.as_ref().unwrap().id(); - // Kill process - p.unwrap().kill().await.expect("Failed to kill process"); - // Wait until the process is killed to move on - while pid.is_some() { - let p = process[index].as_mut(); - pid = p.as_ref().unwrap().id(); - p.unwrap().kill().await.expect("Failed to kill process"); - tokio::time::sleep(std::time::Duration::from_millis(1000)).await; - } - let _p = process[index].as_mut(); // TODO why we have it? - } else if command.command == "sleep" { - let ms: u64 = command.args[0].parse().unwrap(); - tokio::time::sleep(std::time::Duration::from_millis(ms)).await; - } else { - let p = os_command( - &command.command, - command.args.iter().map(String::as_str).collect(), - command.conditions, - ) - .await; - - process.push(p); - } - } - - match (test.as_dowstream, test.as_upstream) { - (Some(as_down), None) => { - let (recv_from_up, send_to_up) = setup_as_sv1_downstream(as_down.addr).await; - Self { - name: Arc::new(test_name.clone()), - send_to_up: Some(send_to_up), - recv_from_up: Some(recv_from_up), - actions: test.sv1_actions.unwrap(), - cleanup_commmands: test.cleanup_commmands, - process, - save, - } - } - _ => unreachable!(), - } - } - - pub async fn execute(self) { - let mut success = true; - for action in self.actions { - if let Some(doc) = action.actiondoc { - info!("actiondoc: {}", doc); - } - let (sender, recv) = ( - self.send_to_up - .as_ref() - .expect("Action require executor to act as downstream"), - self.recv_from_up - .as_ref() - .expect("Action require executor to act as downstream"), - ); - for message_ in action.messages { - let replace_fields = message_.1.clone(); - let message = serde_json::to_string(&message_.0).unwrap(); - let message = message + "\n"; - if replace_fields.is_empty() { - debug!("SEND {:#?}", message); - match sender.send(message).await { - Ok(_) => (), - Err(_) => panic!(), - } - } else { - //TODO: modified message - } - } - let mut rs = 0; - for result in &action.result { - rs += 1; - info!( - "Working on result {}/{}: {}", - rs, - action.result.len(), - result - ); - - // If the connection should drop at this point then let's just break the loop - // Can't do anything else after the connection drops. - if *result == Sv1ActionResult::CloseConnection { - recv.recv() - .await - .expect_err("Expecting the connection to be closed: wasn't"); - break; - } - - let message = match recv.recv().await { - Ok(message) => message, - Err(_) => { - success = false; - error!("Connection closed before receiving the message"); - break; - } - }; - let message: Message = serde_json::from_str(&message).unwrap(); - debug!("RECV {:#?}", message); - match message { - Message::OkResponse(response) | Message::ErrorResponse(response) => { - match result { - Sv1ActionResult::MatchMessageId(message_id) => { - if response.id != *message_id { - error!( - "WRONG MESSAGE ID expected: {} received: {}", - message_id, response.id - ); - success = false; - break; - } else { - info!("MATCHED MESSAGE ID {}", message_id); - } - } - Sv1ActionResult::MatchMessageField { - message_type: _, - fields, - } => { - let msg = serde_json::to_value(response).unwrap(); - check_sv1_fields(msg, fields); - } - _ => todo!(), - } - } - _ => error!("WRONG MESSAGE TYPE RECEIVED: expected Response"), - } - } - } - - for command in self.cleanup_commmands { - os_command( - &command.command, - command.args.iter().map(String::as_str).collect(), - command.conditions, - ) - // Give time to the last cleanup command to return before exit from the process - .await - .unwrap() - .wait() - .await - .unwrap(); - } - - #[allow(clippy::manual_flatten)] - for child in self.process { - if let Some(mut child) = child { - while child.id().is_some() { - // Sends kill signal and waits 1 second before checking to ensure child was - // killed - child.kill().await.expect("Failed to kill process"); - tokio::time::sleep(std::time::Duration::from_millis(1000)).await; - } - } - } - if !success { - panic!("test failed!!!"); - } - } -} - -fn check_sv1_fields(msg: serde_json::Value, field_info: &Vec<(String, serde_json::Value)>) { - for field in field_info { - let msg = msg.as_object().unwrap(); - let value = msg - .get(&field.0) - .expect("match_message_field field name is not valid") - .clone(); - assert!( - field.1 == value, - "match_message_field value is incorrect. Expected = {:?}, Recieved = {:?}", - field.1, - value - ) - } -} diff --git a/utils/message-generator/src/external_commands.rs b/utils/message-generator/src/external_commands.rs deleted file mode 100644 index f0171c207d..0000000000 --- a/utils/message-generator/src/external_commands.rs +++ /dev/null @@ -1,342 +0,0 @@ -use binary_sv2::{Deserialize, Serialize}; -use std::{process::Stdio, time::Duration}; -use tokio::{ - io::{AsyncBufReadExt, BufReader}, - process::{ChildStderr, ChildStdout, Command}, - time::timeout, -}; -use tracing::info; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -pub enum OutputLocation { - StdOut, - StdErr, -} - -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub struct ExternalCommandCondition { - /// String that output must contain in order to fail or pass - pub output_string: String, - /// Where the string should be (stderr, stdout) - pub output_location: OutputLocation, - /// if true and out contain string continue the test - pub condition: bool, - /// if true the condition is checked after initialization - pub late_condition: bool, -} - -#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] -pub enum ExternalCommandConditions { - /// Just run the command and return - None, - /// timer: Number of second after we panic and the test fail - WithConditions { - conditions: Vec, - timer_secs: u64, - warn_no_panic: bool, - }, -} - -impl ExternalCommandConditions { - #[allow(dead_code)] - pub fn new_with_timer_secs(secs: u64) -> Self { - Self::WithConditions { - conditions: vec![], - timer_secs: secs, - warn_no_panic: false, - } - } - - #[allow(dead_code)] - pub fn warn_no_panic(self) -> Self { - match self { - ExternalCommandConditions::WithConditions { - conditions, - timer_secs, - .. - } => Self::WithConditions { - conditions, - timer_secs, - warn_no_panic: true, - }, - ExternalCommandConditions::None => panic!("Expect conditions"), - } - } - - #[allow(dead_code)] - pub fn continue_if_std_out_have(self, to_check: &str) -> Self { - let condition = ExternalCommandCondition { - output_string: to_check.to_string(), - output_location: OutputLocation::StdOut, - condition: true, - late_condition: false, - }; - match self { - ExternalCommandConditions::WithConditions { - mut conditions, - timer_secs, - warn_no_panic, - } => { - conditions.push(condition); - Self::WithConditions { - conditions, - timer_secs, - warn_no_panic, - } - } - ExternalCommandConditions::None => panic!("Expect with condition self"), - } - } - - #[allow(dead_code)] - pub fn fail_if_std_out_have(self, to_check: &str) -> Self { - let condition = ExternalCommandCondition { - output_string: to_check.to_string(), - output_location: OutputLocation::StdOut, - condition: false, - late_condition: false, - }; - match self { - ExternalCommandConditions::WithConditions { - mut conditions, - timer_secs, - warn_no_panic, - } => { - conditions.push(condition); - Self::WithConditions { - conditions, - timer_secs, - warn_no_panic, - } - } - ExternalCommandConditions::None => panic!("Expect with condition self"), - } - } - - #[allow(dead_code)] - pub fn continue_if_std_err_have(self, to_check: &str) -> Self { - let condition = ExternalCommandCondition { - output_string: to_check.to_string(), - output_location: OutputLocation::StdErr, - condition: true, - late_condition: false, - }; - match self { - ExternalCommandConditions::WithConditions { - mut conditions, - timer_secs, - warn_no_panic, - } => { - conditions.push(condition); - Self::WithConditions { - conditions, - timer_secs, - warn_no_panic, - } - } - ExternalCommandConditions::None => panic!("Expect with condition self"), - } - } - - #[allow(dead_code)] - pub fn fail_if_std_err_have(self, to_check: &str) -> Self { - let condition = ExternalCommandCondition { - output_string: to_check.to_string(), - output_location: OutputLocation::StdErr, - condition: false, - late_condition: false, - }; - match self { - ExternalCommandConditions::WithConditions { - mut conditions, - timer_secs, - warn_no_panic, - } => { - conditions.push(condition); - Self::WithConditions { - conditions, - timer_secs, - warn_no_panic, - } - } - ExternalCommandConditions::None => panic!("Expect with condition self"), - } - } - - #[allow(dead_code)] - pub fn fail_if_anything_on_std_err(self) -> Self { - let condition = ExternalCommandCondition { - output_string: "".to_string(), - output_location: OutputLocation::StdErr, - condition: false, - late_condition: false, - }; - match self { - ExternalCommandConditions::WithConditions { - mut conditions, - timer_secs, - warn_no_panic, - } => { - conditions.push(condition); - Self::WithConditions { - conditions, - timer_secs, - warn_no_panic, - } - } - ExternalCommandConditions::None => panic!("Expect with condition self"), - } - } - - fn check_condition(&self, output: String, location: OutputLocation, is_late: bool) -> bool { - match self { - ExternalCommandConditions::WithConditions { - conditions, - warn_no_panic, - .. - } => { - for condition in conditions { - if output.contains(&condition.output_string) - && condition.output_location == location - && condition.late_condition == is_late - { - match condition.condition { - true => return true, - false => match warn_no_panic { - true => todo!(), - false => panic!(), - }, - } - }; - } - false - } - ExternalCommandConditions::None => { - panic!("Try to take conditions but no conditions in self") - } - } - } - - fn get_timer(&self) -> Duration { - match self { - ExternalCommandConditions::WithConditions { timer_secs, .. } => { - Duration::from_secs(*timer_secs) - } - ExternalCommandConditions::None => { - panic!("Try to take timer but no conditions in self") - } - } - } - - async fn check_std_out_(&self, std_out: &mut ChildStdout, is_late: bool) { - let mut reader = BufReader::new(std_out).lines(); - loop { - let line = match reader.next_line().await.unwrap() { - Some(line) => { - info!("STD OUT: {}", line); - line - } - None => return, - }; - if self.check_condition(line, OutputLocation::StdOut, is_late) { - return; - } - } - } - pub async fn check_std_out(&self, std_out: &mut ChildStdout, is_late: bool) -> Result<(), ()> { - let seconds = match is_late { - true => self.get_timer(), - false => Duration::from_secs(u64::MAX), - }; - timeout(seconds, self.check_std_out_(std_out, is_late)) - .await - .map_err(|_| { - if !self.get_warn_no_panic() { - panic!() - }; - }) - } - - async fn check_std_err_(&self, std_err: &mut ChildStderr, is_late: bool) { - let mut reader = BufReader::new(std_err).lines(); - loop { - let line = match reader.next_line().await.unwrap() { - Some(line) => { - if !line.contains("unused manifest key") { - info!("STD ERR: {}", line); - } - line - } - None => return, - }; - if self.check_condition(line, OutputLocation::StdErr, is_late) { - return; - } - } - } - pub async fn check_std_err(&self, std_err: &mut ChildStderr, is_late: bool) -> Result<(), ()> { - let seconds = match is_late { - true => self.get_timer(), - false => Duration::from_secs(u64::MAX), - }; - timeout(seconds, self.check_std_err_(std_err, is_late)) - .await - .map_err(|_| { - if !self.get_warn_no_panic() { - panic!() - }; - }) - } - fn get_warn_no_panic(&self) -> bool { - match self { - ExternalCommandConditions::None => panic!("Expect conditions"), - ExternalCommandConditions::WithConditions { warn_no_panic, .. } => *warn_no_panic, - } - } -} - -pub async fn os_command( - command_: &str, - args: Vec<&str>, - conditions_: ExternalCommandConditions, -) -> Option { - let mut command = Command::new(command_); - command.stdin(Stdio::null()); - command.stdout(Stdio::piped()); - command.stderr(Stdio::piped()); - command.kill_on_drop(true); - for arg in args.clone() { - command.arg(arg); - } - - let mut child = if args.len() == 2 && command_ == "cargo" { - command.spawn().unwrap() - } else { - command.current_dir("../../roles").spawn().unwrap() - }; - debug_assert!(child.stdout.is_some()); - debug_assert!(child.stderr.is_some()); - match &conditions_ { - ExternalCommandConditions::WithConditions { .. } => { - let mut stdout = child.stdout.take().unwrap(); - let mut stderr = child.stderr.take().unwrap(); - - match tokio::select! { - r = conditions_.check_std_out(&mut stdout,false) => r, - r = conditions_.check_std_err(&mut stderr,false) => r, - } { - Ok(_) => { - tokio::task::spawn(async move { - tokio::select! { - r = conditions_.check_std_out(&mut stdout,true) => r, - r = conditions_.check_std_err(&mut stderr,true) => r, - } - }); - Some(child) - } - Err(_) => None, - } - } - ExternalCommandConditions::None => Some(child), - } -} diff --git a/utils/message-generator/src/into_static.rs b/utils/message-generator/src/into_static.rs deleted file mode 100644 index fb20c5f739..0000000000 --- a/utils/message-generator/src/into_static.rs +++ /dev/null @@ -1,428 +0,0 @@ -use roles_logic_sv2::{ - common_messages_sv2::{ - ChannelEndpointChanged, SetupConnection, SetupConnectionError, SetupConnectionSuccess, - }, - job_declaration_sv2::{ - AllocateMiningJobToken, AllocateMiningJobTokenSuccess, DeclareMiningJob, - DeclareMiningJobError, DeclareMiningJobSuccess, IdentifyTransactions, - IdentifyTransactionsSuccess, ProvideMissingTransactions, ProvideMissingTransactionsSuccess, - }, - mining_sv2::{ - CloseChannel, NewExtendedMiningJob, NewMiningJob, OpenExtendedMiningChannel, - OpenExtendedMiningChannelSuccess, OpenMiningChannelError, OpenStandardMiningChannel, - OpenStandardMiningChannelSuccess, Reconnect, SetCustomMiningJob, SetCustomMiningJobError, - SetCustomMiningJobSuccess, SetExtranoncePrefix, SetGroupChannel, - SetNewPrevHash as MiningSetNewPrevHash, SetTarget, SubmitSharesError, SubmitSharesExtended, - SubmitSharesStandard, SubmitSharesSuccess, UpdateChannel, UpdateChannelError, - }, - parsers::{self, AnyMessage, CommonMessages, PoolMessages}, - template_distribution_sv2::{ - CoinbaseOutputDataSize, NewTemplate, RequestTransactionData, RequestTransactionDataError, - RequestTransactionDataSuccess, SubmitSolution, - }, -}; - -pub fn into_static(m: AnyMessage<'_>) -> AnyMessage<'static> { - match m { - PoolMessages::Common(m) => match m { - CommonMessages::ChannelEndpointChanged(m) => PoolMessages::Common( - CommonMessages::ChannelEndpointChanged(ChannelEndpointChanged { - channel_id: m.channel_id, - }), - ), - CommonMessages::SetupConnection(m) => { - let m = SetupConnection { - protocol: m.protocol, - min_version: m.min_version, - max_version: m.max_version, - flags: m.flags, - endpoint_host: m.endpoint_host.into_static(), - endpoint_port: m.endpoint_port, - vendor: m.vendor.into_static(), - hardware_version: m.hardware_version.into_static(), - firmware: m.firmware.into_static(), - device_id: m.device_id.into_static(), - }; - PoolMessages::Common(CommonMessages::SetupConnection(m)) - } - CommonMessages::SetupConnectionError(m) => { - let m = SetupConnectionError { - flags: m.flags, - error_code: m.error_code.into_static(), - }; - PoolMessages::Common(CommonMessages::SetupConnectionError(m)) - } - CommonMessages::SetupConnectionSuccess(m) => { - let m = SetupConnectionSuccess { - used_version: m.used_version, - flags: m.flags, - }; - PoolMessages::Common(CommonMessages::SetupConnectionSuccess(m)) - } - }, - PoolMessages::Mining(m) => match m { - parsers::Mining::CloseChannel(m) => { - let m = CloseChannel { - channel_id: m.channel_id, - reason_code: m.reason_code.into_static(), - }; - PoolMessages::Mining(parsers::Mining::CloseChannel(m)) - } - parsers::Mining::NewExtendedMiningJob(m) => { - let m = NewExtendedMiningJob { - channel_id: m.channel_id, - job_id: m.job_id, - min_ntime: m.min_ntime.into_static(), - version: m.version, - version_rolling_allowed: m.version_rolling_allowed, - merkle_path: m.merkle_path.into_static(), - coinbase_tx_prefix: m.coinbase_tx_prefix.into_static(), - coinbase_tx_suffix: m.coinbase_tx_suffix.into_static(), - }; - PoolMessages::Mining(parsers::Mining::NewExtendedMiningJob(m)) - } - parsers::Mining::NewMiningJob(m) => { - let m = NewMiningJob { - channel_id: m.channel_id, - job_id: m.job_id, - min_ntime: m.min_ntime.into_static(), - version: m.version, - merkle_root: m.merkle_root.into_static(), - }; - PoolMessages::Mining(parsers::Mining::NewMiningJob(m)) - } - parsers::Mining::OpenExtendedMiningChannel(m) => { - let m = OpenExtendedMiningChannel { - request_id: m.request_id, - user_identity: m.user_identity.into_static(), - nominal_hash_rate: m.nominal_hash_rate, - max_target: m.max_target.into_static(), - min_extranonce_size: m.min_extranonce_size, - }; - PoolMessages::Mining(parsers::Mining::OpenExtendedMiningChannel(m)) - } - parsers::Mining::OpenExtendedMiningChannelSuccess(m) => { - let m = OpenExtendedMiningChannelSuccess { - request_id: m.request_id, - channel_id: m.channel_id, - target: m.target.into_static(), - extranonce_size: m.extranonce_size, - extranonce_prefix: m.extranonce_prefix.into_static(), - }; - PoolMessages::Mining(parsers::Mining::OpenExtendedMiningChannelSuccess(m)) - } - parsers::Mining::OpenMiningChannelError(m) => { - let m = OpenMiningChannelError { - request_id: m.request_id, - error_code: m.error_code.into_static(), - }; - PoolMessages::Mining(parsers::Mining::OpenMiningChannelError(m)) - } - parsers::Mining::OpenStandardMiningChannel(m) => { - let m = OpenStandardMiningChannel { - request_id: m.request_id, - user_identity: m.user_identity.into_static(), - nominal_hash_rate: m.nominal_hash_rate, - max_target: m.max_target.into_static(), - }; - PoolMessages::Mining(parsers::Mining::OpenStandardMiningChannel(m)) - } - parsers::Mining::OpenStandardMiningChannelSuccess(m) => { - let m = OpenStandardMiningChannelSuccess { - request_id: m.request_id, - channel_id: m.channel_id, - target: m.target.into_static(), - extranonce_prefix: m.extranonce_prefix.into_static(), - group_channel_id: m.group_channel_id, - }; - PoolMessages::Mining(parsers::Mining::OpenStandardMiningChannelSuccess(m)) - } - parsers::Mining::Reconnect(m) => { - let m = Reconnect { - new_host: m.new_host.into_static(), - new_port: m.new_port, - }; - PoolMessages::Mining(parsers::Mining::Reconnect(m)) - } - parsers::Mining::SetCustomMiningJob(m) => { - let m = SetCustomMiningJob { - channel_id: m.channel_id, - request_id: m.request_id, - token: m.token.into_static(), - version: m.version, - prev_hash: m.prev_hash.into_static(), - min_ntime: m.min_ntime, - nbits: m.nbits, - coinbase_tx_version: m.coinbase_tx_version, - coinbase_prefix: m.coinbase_prefix.into_static(), - coinbase_tx_input_n_sequence: m.coinbase_tx_input_n_sequence, - coinbase_tx_value_remaining: m.coinbase_tx_value_remaining, - coinbase_tx_outputs: m.coinbase_tx_outputs.into_static(), - coinbase_tx_locktime: m.coinbase_tx_locktime, - merkle_path: m.merkle_path.into_static(), - extranonce_size: m.extranonce_size, - }; - PoolMessages::Mining(parsers::Mining::SetCustomMiningJob(m)) - } - parsers::Mining::SetCustomMiningJobError(m) => { - let m = SetCustomMiningJobError { - channel_id: m.channel_id, - request_id: m.request_id, - error_code: m.error_code.into_static(), - }; - PoolMessages::Mining(parsers::Mining::SetCustomMiningJobError(m)) - } - parsers::Mining::SetCustomMiningJobSuccess(m) => { - let m = SetCustomMiningJobSuccess { - channel_id: m.channel_id, - request_id: m.request_id, - job_id: m.job_id, - }; - PoolMessages::Mining(parsers::Mining::SetCustomMiningJobSuccess(m)) - } - parsers::Mining::SetExtranoncePrefix(m) => { - let m = SetExtranoncePrefix { - channel_id: m.channel_id, - extranonce_prefix: m.extranonce_prefix.into_static(), - }; - PoolMessages::Mining(parsers::Mining::SetExtranoncePrefix(m)) - } - parsers::Mining::SetGroupChannel(m) => { - let m = SetGroupChannel { - group_channel_id: m.group_channel_id, - channel_ids: m.channel_ids.into_static(), - }; - PoolMessages::Mining(parsers::Mining::SetGroupChannel(m)) - } - parsers::Mining::SetNewPrevHash(m) => { - let m = MiningSetNewPrevHash { - channel_id: m.channel_id, - job_id: m.job_id, - prev_hash: m.prev_hash.into_static(), - min_ntime: m.min_ntime, - nbits: m.nbits, - }; - PoolMessages::Mining(parsers::Mining::SetNewPrevHash(m)) - } - parsers::Mining::SetTarget(m) => { - let m = SetTarget { - channel_id: m.channel_id, - maximum_target: m.maximum_target.into_static(), - }; - PoolMessages::Mining(parsers::Mining::SetTarget(m)) - } - parsers::Mining::SubmitSharesError(m) => { - let m = SubmitSharesError { - channel_id: m.channel_id, - sequence_number: m.sequence_number, - error_code: m.error_code.into_static(), - }; - PoolMessages::Mining(parsers::Mining::SubmitSharesError(m)) - } - parsers::Mining::SubmitSharesExtended(m) => { - let m = SubmitSharesExtended { - channel_id: m.channel_id, - sequence_number: m.sequence_number, - job_id: m.job_id, - nonce: m.nonce, - ntime: m.ntime, - version: m.version, - extranonce: m.extranonce.into_static(), - }; - PoolMessages::Mining(parsers::Mining::SubmitSharesExtended(m)) - } - parsers::Mining::SubmitSharesStandard(m) => { - let m = SubmitSharesStandard { - channel_id: m.channel_id, - sequence_number: m.sequence_number, - job_id: m.job_id, - nonce: m.nonce, - ntime: m.ntime, - version: m.version, - }; - PoolMessages::Mining(parsers::Mining::SubmitSharesStandard(m)) - } - parsers::Mining::SubmitSharesSuccess(m) => { - let m = SubmitSharesSuccess { - channel_id: m.channel_id, - last_sequence_number: m.last_sequence_number, - new_submits_accepted_count: m.new_submits_accepted_count, - new_shares_sum: m.new_shares_sum, - }; - PoolMessages::Mining(parsers::Mining::SubmitSharesSuccess(m)) - } - parsers::Mining::UpdateChannel(m) => { - let m = UpdateChannel { - channel_id: m.channel_id, - nominal_hash_rate: m.nominal_hash_rate, - maximum_target: m.maximum_target.into_static(), - }; - PoolMessages::Mining(parsers::Mining::UpdateChannel(m)) - } - parsers::Mining::UpdateChannelError(m) => { - let m = UpdateChannelError { - channel_id: m.channel_id, - error_code: m.error_code.into_static(), - }; - PoolMessages::Mining(parsers::Mining::UpdateChannelError(m)) - } - }, - PoolMessages::JobDeclaration(m) => match m { - parsers::JobDeclaration::AllocateMiningJobToken(m) => { - let m = AllocateMiningJobToken { - user_identifier: m.user_identifier.into_static(), - request_id: m.request_id, - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::AllocateMiningJobToken(m)) - } - parsers::JobDeclaration::AllocateMiningJobTokenSuccess(m) => { - let m = AllocateMiningJobTokenSuccess { - request_id: m.request_id, - mining_job_token: m.mining_job_token.into_static(), - coinbase_output_max_additional_size: m.coinbase_output_max_additional_size, - coinbase_output: m.coinbase_output.into_static(), - async_mining_allowed: m.async_mining_allowed, - }; - PoolMessages::JobDeclaration( - parsers::JobDeclaration::AllocateMiningJobTokenSuccess(m), - ) - } - parsers::JobDeclaration::DeclareMiningJob(m) => { - let m = DeclareMiningJob { - request_id: m.request_id, - mining_job_token: m.mining_job_token.into_static(), - version: m.version, - coinbase_prefix: m.coinbase_prefix.into_static(), - coinbase_suffix: m.coinbase_suffix.into_static(), - tx_short_hash_nonce: m.tx_short_hash_nonce, - tx_short_hash_list: m.tx_short_hash_list.into_static(), - tx_hash_list_hash: m.tx_hash_list_hash.into_static(), - excess_data: m.excess_data.into_static(), - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::DeclareMiningJob(m)) - } - parsers::JobDeclaration::DeclareMiningJobSuccess(m) => { - let m = DeclareMiningJobSuccess { - request_id: m.request_id, - new_mining_job_token: m.new_mining_job_token.into_static(), - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::DeclareMiningJobSuccess(m)) - } - parsers::JobDeclaration::DeclareMiningJobError(m) => { - let m = DeclareMiningJobError { - request_id: m.request_id, - error_code: m.error_code.into_static(), - error_details: m.error_details.into_static(), - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::DeclareMiningJobError(m)) - } - parsers::JobDeclaration::IdentifyTransactions(m) => { - let m = IdentifyTransactions { - request_id: m.request_id, - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::IdentifyTransactions(m)) - } - parsers::JobDeclaration::IdentifyTransactionsSuccess(m) => { - let m = IdentifyTransactionsSuccess { - request_id: m.request_id, - tx_data_hashes: m.tx_data_hashes.into_static(), - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::IdentifyTransactionsSuccess( - m, - )) - } - parsers::JobDeclaration::ProvideMissingTransactions(m) => { - let m = ProvideMissingTransactions { - request_id: m.request_id, - unknown_tx_position_list: m.unknown_tx_position_list.into_static(), - }; - PoolMessages::JobDeclaration(parsers::JobDeclaration::ProvideMissingTransactions(m)) - } - parsers::JobDeclaration::ProvideMissingTransactionsSuccess(m) => { - let m = ProvideMissingTransactionsSuccess { - request_id: m.request_id, - transaction_list: m.transaction_list.into_static(), - }; - PoolMessages::JobDeclaration( - parsers::JobDeclaration::ProvideMissingTransactionsSuccess(m), - ) - } - parsers::JobDeclaration::SubmitSolution(_m) => { - todo!() - } - }, - PoolMessages::TemplateDistribution(m) => match m { - parsers::TemplateDistribution::CoinbaseOutputDataSize(m) => { - let m = CoinbaseOutputDataSize { - coinbase_output_max_additional_size: m.coinbase_output_max_additional_size, - }; - PoolMessages::TemplateDistribution( - parsers::TemplateDistribution::CoinbaseOutputDataSize(m), - ) - } - parsers::TemplateDistribution::NewTemplate(m) => { - let m = NewTemplate { - template_id: m.template_id, - future_template: m.future_template, - version: m.version, - coinbase_tx_version: m.coinbase_tx_version, - coinbase_prefix: m.coinbase_prefix.into_static(), - coinbase_tx_input_sequence: m.coinbase_tx_input_sequence, - coinbase_tx_value_remaining: m.coinbase_tx_value_remaining, - coinbase_tx_outputs_count: m.coinbase_tx_outputs_count, - coinbase_tx_outputs: m.coinbase_tx_outputs.into_static(), - coinbase_tx_locktime: m.coinbase_tx_locktime, - merkle_path: m.merkle_path.into_static(), - }; - PoolMessages::TemplateDistribution(parsers::TemplateDistribution::NewTemplate(m)) - } - parsers::TemplateDistribution::RequestTransactionData(m) => { - let m = RequestTransactionData { - template_id: m.template_id, - }; - PoolMessages::TemplateDistribution( - parsers::TemplateDistribution::RequestTransactionData(m), - ) - } - parsers::TemplateDistribution::RequestTransactionDataError(m) => { - let m = RequestTransactionDataError { - template_id: m.template_id, - error_code: m.error_code.into_static(), - }; - PoolMessages::TemplateDistribution( - parsers::TemplateDistribution::RequestTransactionDataError(m), - ) - } - parsers::TemplateDistribution::RequestTransactionDataSuccess(m) => { - let m = RequestTransactionDataSuccess { - template_id: m.template_id, - excess_data: m.excess_data.into_static(), - transaction_list: m.transaction_list.into_static(), // TODO! DA RIVEDERE! - }; - PoolMessages::TemplateDistribution( - parsers::TemplateDistribution::RequestTransactionDataSuccess(m), - ) - } - parsers::TemplateDistribution::SetNewPrevHash(m) => { - let m = roles_logic_sv2::template_distribution_sv2::SetNewPrevHash { - template_id: m.template_id, - prev_hash: m.prev_hash.into_static(), - header_timestamp: m.header_timestamp, - n_bits: m.n_bits, - target: m.target.into_static(), - }; - PoolMessages::TemplateDistribution(parsers::TemplateDistribution::SetNewPrevHash(m)) - } - parsers::TemplateDistribution::SubmitSolution(m) => { - let m = SubmitSolution { - template_id: m.template_id, - version: m.version, - header_timestamp: m.header_timestamp, - header_nonce: m.header_nonce, - coinbase_tx: m.coinbase_tx.into_static(), - }; - PoolMessages::TemplateDistribution(parsers::TemplateDistribution::SubmitSolution(m)) - } - }, - } -} diff --git a/utils/message-generator/src/main.rs b/utils/message-generator/src/main.rs deleted file mode 100644 index 174aded2cc..0000000000 --- a/utils/message-generator/src/main.rs +++ /dev/null @@ -1,844 +0,0 @@ -mod executor; -mod executor_sv1; -mod external_commands; -mod into_static; -mod net; -mod parser; - -#[macro_use] -extern crate load_file; - -use crate::parser::sv2_messages::ReplaceField; -use binary_sv2::{Deserialize, Serialize}; -use codec_sv2::StandardEitherFrame as EitherFrame; -use external_commands::*; -use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; -use rand::Rng; -use roles_logic_sv2::parsers::AnyMessage; -use secp256k1::{Secp256k1, SecretKey}; -use std::{ - convert::TryInto, - fmt, - net::SocketAddr, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - vec::Vec, -}; -use tracing::{error, info}; -use tracing_core::{Event, Subscriber}; -use tracing_subscriber::{ - filter::EnvFilter, - fmt::{ - format::{self, FormatEvent, FormatFields}, - FmtContext, FormattedFields, - }, - registry::LookupSpan, -}; -use v1::json_rpc::StandardRequest; -struct Formatter; - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -enum Sv2Type { - Bool(bool), - U8(u8), - U16(u16), - U24(Vec), - U32(u32), - U256(Vec), - Str0255(Vec), - B0255(Vec), - B064K(Vec), - B016m(Vec), - B032(Vec), - Pubkey(Vec), - Seq0255(Vec>), - Seq064k(Vec>), -} - -impl Sv2Type { - fn arbitrary(self) -> Self { - let mut rng = rand::thread_rng(); - match self { - Sv2Type::Bool(_) => Sv2Type::Bool(rng.gen::()), - Sv2Type::U8(_) => Sv2Type::U8(rng.gen::()), - Sv2Type::U16(_) => Sv2Type::U16(rng.gen::()), - Sv2Type::U24(_) => { - //let length: u8 = rng.gen::() % 3; - let length: u8 = 3; - crate::Sv2Type::U24((0..length).map(|_| rng.gen::()).collect()) - } - Sv2Type::U32(_) => Sv2Type::U32(rng.gen::()), - Sv2Type::U256(_) => { - let length: u8 = 32; - //let length: u8 = rng.gen::() % max_len_in_bytes; - Sv2Type::U256((0..length).map(|_| rng.gen::()).collect()) - } - // seems that also in the SRI Str0255 is defined as a B0255, so the same implementation - // of arbitrary is used - Sv2Type::Str0255(_) => { - let length: u8 = rng.gen::(); - let vector_suffix = vec![0; length.into()]; - let mut vector_suffix: Vec = - vector_suffix.into_iter().map(|_| rng.gen::()).collect(); - let mut vector = vec![length]; - vector.append(&mut vector_suffix); - Sv2Type::Str0255(vector) - } - Sv2Type::B0255(_) => { - let length: u8 = rng.gen::(); - let vector_suffix = vec![0; length.into()]; - let mut vector_suffix: Vec = - vector_suffix.into_iter().map(|_| rng.gen::()).collect(); - let mut vector = vec![length]; - vector.append(&mut vector_suffix); - Sv2Type::B0255(vector) - } - Sv2Type::B064K(_) => { - let length: u16 = rng.gen::(); - let vector_suffix = vec![0; length.into()]; - let mut vector_suffix: Vec = - vector_suffix.into_iter().map(|_| rng.gen::()).collect(); - let mut vector: Vec = length.to_le_bytes().into(); - vector.append(&mut vector_suffix); - Sv2Type::B064K(vector) - } - Sv2Type::B016m(_) => { - let mut vector: Vec = match Sv2Type::U24(vec![1]).arbitrary() { - Self::U24(vector) => vector, - _ => panic!(), - }; - // why do I have to use 8 bytes instead of 4? - let mut length_8_bytes = vector.clone(); - length_8_bytes.resize(length_8_bytes.len() + 5, 0); - //for _ in 0..5 { - // length_8_bytes.push(0); - //} - let length_8_bytes_array: [u8; 8] = length_8_bytes.clone().try_into().unwrap(); - let length = u64::from_le_bytes(length_8_bytes_array); - let vector_suffix = vec![0; length as usize]; - //for _ in 0..length { - // vector_suffix.push(0); - //} - let mut vector_suffix: Vec = - vector_suffix.into_iter().map(|_| rng.gen::()).collect(); - vector.append(&mut vector_suffix); - Sv2Type::B016m(vector) - } - Sv2Type::B032(_) => { - let length: u8 = rng.gen::(); - let mut vector_suffix = (0..length).map(|_| rng.gen::()).collect(); - let mut vector: Vec = length.to_le_bytes().into(); - vector.append(&mut vector_suffix); - Sv2Type::B032(vector) - } - Sv2Type::Pubkey(_) => { - let vector: Vec = (0..32).map(|_| rng.gen::()).collect(); - let secret_key = SecretKey::from_slice(&vector[..]).unwrap(); - let secp = Secp256k1::new(); - let pubkey_as_vec = secret_key.public_key(&secp).serialize().to_vec(); - Sv2Type::Pubkey(pubkey_as_vec) - } - Sv2Type::Seq0255(_) => { - // we assume the type T to be at most 128bits - let number_of_elements_of_type_t: u8 = rng.gen::(); - let vector_suffix: Vec = (0..number_of_elements_of_type_t) - .map(|_| rng.gen::()) - .collect(); - let mut vector_suffix: Vec> = vector_suffix - .iter() - .map(|s| s.to_le_bytes().to_vec()) - .collect(); - let mut vector: Vec> = - vec![number_of_elements_of_type_t.to_le_bytes().into()]; - vector.append(&mut vector_suffix); - Sv2Type::Seq0255(vector) - } - Sv2Type::Seq064k(_) => { - let number_of_elements_of_type_t: u16 = rng.gen::(); - let vector_suffix: Vec = (0..number_of_elements_of_type_t) - .map(|_| rng.gen::()) - .collect(); - let mut vector_suffix: Vec> = vector_suffix - .iter() - .map(|s| s.to_le_bytes().to_vec()) - .collect(); - let mut vector: Vec> = - vec![number_of_elements_of_type_t.to_le_bytes().into()]; - vector.append(&mut vector_suffix); - Sv2Type::Seq0255(vector) - } - } - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -pub struct SaveField { - field_name: String, - keyword: String, -} - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -enum ActionResult { - MatchMessageType(u8), - MatchMessageField((String, String, Vec<(String, Sv2Type)>)), - GetMessageField { - subprotocol: String, - message_type: String, - fields: Vec, - }, - MatchMessageLen(usize), - MatchExtensionType(u16), - CloseConnection, - SustainConnection, - None, -} - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)] -enum Sv1ActionResult { - MatchMessageId(serde_json::Value), - MatchMessageField { - message_type: String, - fields: Vec<(String, serde_json::Value)>, - }, - CloseConnection, - None, -} - -impl std::fmt::Display for ActionResult { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match self { - ActionResult::MatchMessageType(message_type) => { - write!( - f, - "MatchMessageType: {} ({:#x})", - message_type, message_type - ) - } - ActionResult::MatchMessageField(message_field) => { - write!(f, "MatchMessageField: {:?}", message_field) - } - ActionResult::MatchMessageLen(message_len) => { - write!(f, "MatchMessageLen: {}", message_len) - } - ActionResult::MatchExtensionType(extension_type) => { - write!(f, "MatchExtensionType: {}", extension_type) - } - ActionResult::CloseConnection => write!(f, "Close connection"), - ActionResult::SustainConnection => write!(f, "Sustain connection"), - ActionResult::GetMessageField { - subprotocol, - fields, - .. - } => { - write!(f, "GetMessageField: {:?} {:?}", subprotocol, fields) - } - ActionResult::None => write!(f, "None"), - } - } -} - -impl std::fmt::Display for Sv1ActionResult { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match self { - Sv1ActionResult::MatchMessageId(message_id) => { - write!(f, "MatchMessageId: {}", message_id) - } - Sv1ActionResult::MatchMessageField { - message_type, - fields, - } => { - write!(f, "MatchMessageField: {:?} {:?}", message_type, fields) - } - Sv1ActionResult::CloseConnection => write!(f, "Close connection"), - Sv1ActionResult::None => write!(f, "None"), - } - } -} - -#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Copy)] -enum Role { - Upstream, - Downstream, - Proxy, -} - -#[derive(Debug, Clone, PartialEq)] -pub enum TestVersion { - V1, - V2, -} - -#[derive(Debug, Clone)] -struct Upstream { - addr: SocketAddr, - /// If Some a noise connection is used, otherwise a plain connection is used. - keys: Option<(Secp256k1PublicKey, Secp256k1SecretKey)>, -} - -#[derive(Debug, Clone)] -struct Downstream { - addr: SocketAddr, - /// If Some a noise connection is used, otherwise a plain connection is used. - key: Option, -} - -//TODO: change name to Sv2Action -#[derive(Debug)] -pub struct Action<'a> { - messages: Vec<( - EitherFrame>, - AnyMessage<'a>, - Vec, - )>, - result: Vec, - role: Role, - actiondoc: Option, -} -#[derive(Debug)] -pub struct Sv1Action { - messages: Vec<(StandardRequest, Vec)>, - result: Vec, - actiondoc: Option, -} - -/// Represents a shell command to be executed on setup, after a connection is opened, or on -/// cleanup. -#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)] -pub struct Command { - command: String, - args: Vec, - /// Stdout or Stderr conditions for when a command is considered a success or failure. - conditions: ExternalCommandConditions, -} - -/// Represents all of the parsed contents from the configuration file, ready for execution. -#[derive(Debug)] -pub struct Test<'a> { - version: TestVersion, - actions: Option>>, - sv1_actions: Option>, - /// Some if role is upstream or proxy. - as_upstream: Option, - /// Some if role is downstream or proxy. - as_dowstream: Option, - setup_commmands: Vec, - execution_commands: Vec, - cleanup_commmands: Vec, -} - -async fn clean_up(commands: Vec) { - for command in commands { - os_command( - &command.command, - command.args.iter().map(String::as_str).collect(), - command.conditions, - ) - // Give time to the last cleanup command to return before exit from the process - .await - .expect("TEST AND CLEANUP FAILED") - .wait() - .await - .expect("TEST AND CLEANUP FAILED"); - } -} - -impl FormatEvent for Formatter -where - S: Subscriber + for<'a> LookupSpan<'a>, - N: for<'a> FormatFields<'a> + 'static, -{ - fn format_event( - &self, - ctx: &FmtContext<'_, S, N>, - mut writer: format::Writer<'_>, - event: &Event<'_>, - ) -> fmt::Result { - if let Some(scope) = ctx.event_scope() { - for span in scope.from_root() { - write!(writer, "{}", span.name())?; - let ext = span.extensions(); - let fields = &ext - .get::>() - .expect("will never be `None`"); - if !fields.is_empty() { - write!(writer, "{{{}}}", fields)?; - } - write!(writer, ": ")?; - } - } - ctx.field_format().format_fields(writer.by_ref(), event)?; - writeln!(writer) - } -} - -fn load_file(path: &str) -> String { - std::fs::read_to_string(path).unwrap() -} -fn string_to_static_str(s: String) -> &'static str { - Box::leak(s.into_boxed_str()) -} - -#[tokio::main] -async fn main() { - tracing_subscriber::fmt() - .with_env_filter(EnvFilter::from_default_env()) - .event_format(Formatter) - .init(); - let args: Vec = std::env::args().collect(); - let test_path = &args[1]; - info!(""); - info!("EXECUTING {}", test_path); - info!(""); - let mut _test_path = args[1].clone(); - //_test_path.insert_str(0, "../"); - let test_path_ = &_test_path; - // Load contents of `test.json`, then parse - let test_static = string_to_static_str(load_file(test_path_)); - let test = parser::Parser::parse_test(test_static); - let test_name: String = test_path - .split('/') - .collect::>() - .last() - .unwrap() - .to_string(); - let cleanup = test.cleanup_commmands.clone(); - // Executes everything (the shell commands and actions) - // If the `executor` returns false, the test fails - let fail = Arc::new(AtomicBool::new(false)); - let pass = Arc::new(AtomicBool::new(false)); - { - let fail = fail.clone(); - std::panic::set_hook(Box::new(move |info| { - error!("{:#?}", info); - fail.store(true, Ordering::Relaxed); - })); - } - { - let pass = pass.clone(); - tokio::spawn(async move { - match test.version { - TestVersion::V1 => { - let executor = executor_sv1::Sv1Executor::new(test, test_name).await; - executor.execute().await; - pass.store(true, Ordering::Relaxed); - } - TestVersion::V2 => { - let executor = executor::Executor::new(test, test_name).await; - executor.execute().await; - pass.store(true, Ordering::Relaxed); - } - } - }); - } - loop { - tokio::task::yield_now().await; - if fail.load(Ordering::Relaxed) { - clean_up(cleanup).await; - let _ = std::panic::take_hook(); - panic!("TEST FAILED"); - } - if pass.load(Ordering::Relaxed) { - info!("TEST OK"); - std::process::exit(0); - } - } -} - -#[cfg(test)] -mod test { - use super::*; - use crate::{ - into_static::into_static, - net::{setup_as_downstream, setup_as_upstream}, - }; - use codec_sv2::Sv2Frame; - use roles_logic_sv2::{ - mining_sv2::{ - CloseChannel, NewExtendedMiningJob, OpenExtendedMiningChannel, - OpenExtendedMiningChannelSuccess, SetCustomMiningJob, SetTarget, - }, - parsers::Mining, - }; - use std::convert::TryInto; - use tokio::join; - - // The following test see that the composition serialise fist and deserialize - // second is the identity function (on an example message) - #[test] - fn test_serialise_and_deserialize() { - let message_string = r#"{"Mining":{"OpenExtendedMiningChannelSuccess":{"request_id":666666,"channel_id":1,"target":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255],"extranonce_size":16,"extranonce_prefix":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]}}}"#; - let message_: AnyMessage<'_> = serde_json::from_str(&message_string).unwrap(); - let message_as_serde_value = serde_json::to_value(&message_).unwrap(); - let message_as_string = serde_json::to_string(&message_as_serde_value).unwrap(); - let message: AnyMessage<'_> = serde_json::from_str(&message_as_string).unwrap(); - let m_ = into_static(message); - let message_as_string_ = serde_json::to_string(&m_).unwrap(); - - let message_ = match message_ { - AnyMessage::Mining(m) => m, - _ => panic!(), - }; - let message_ = match message_ { - Mining::OpenExtendedMiningChannelSuccess(m) => m, - _ => panic!(), - }; - - let m_ = match m_ { - AnyMessage::Mining(m) => m, - _ => panic!(), - }; - let m_ = match m_ { - Mining::OpenExtendedMiningChannelSuccess(m) => m, - _ => panic!(), - }; - if message_.request_id != m_.request_id { - panic!(); - }; - if message_.channel_id != m_.channel_id { - panic!(); - }; - if message_.target != m_.target { - panic!(); - }; - if message_.extranonce_size != m_.extranonce_size { - panic!(); - }; - if message_.extranonce_prefix != m_.extranonce_prefix { - panic!(); - }; - } - - //here oemc stands for OpenExtendedMiningChannel - #[test] - fn test_serialize_and_deserialize_2_oemc() { - let message = OpenExtendedMiningChannel { - request_id: 90, - user_identity: binary_sv2::B0255::try_from(vec![3, 0, 0, 0]).unwrap(), - nominal_hash_rate: 10.0, - max_target: binary_sv2::U256::try_from(vec![1; 32]).unwrap(), - min_extranonce_size: 3, - }; - let message_as_serde_value = serde_json::to_value(message.clone()).unwrap(); - let message_as_string = serde_json::to_string(&message_as_serde_value).unwrap(); - let message_new: OpenExtendedMiningChannel = - serde_json::from_str(&message_as_string).unwrap(); - assert!(message_new == message); - } - - // oemcs is oemc.Success - #[test] - fn test_serialize_and_deserialize_3_oemcs() { - let message = OpenExtendedMiningChannelSuccess { - request_id: 666666, - channel_id: 1, - target: binary_sv2::U256::try_from(vec![ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, - 255, 255, 255, 255, 255, 255, - ]) - .unwrap(), - extranonce_size: 3, - extranonce_prefix: vec![ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, - 255, 255, 255, 255, 255, 255, - ] - .try_into() - .unwrap(), - }; - let message_as_serde_value = serde_json::to_value(message.clone()).unwrap(); - let message_as_string = serde_json::to_string(&message_as_serde_value).unwrap(); - let message_new: OpenExtendedMiningChannelSuccess = - serde_json::from_str(&message_as_string).unwrap(); - - assert!(message_new == message); - } - - // nemj NewExtendedMiningJob - #[test] - fn test_serialize_and_deserialize_4_nemj() { - let message = NewExtendedMiningJob { - channel_id: 1, - job_id: 1, - min_ntime: binary_sv2::Sv2Option::try_from(vec![0, 0, 0, 0]).unwrap(), - version: 1, - version_rolling_allowed: true, - merkle_path: binary_sv2::Seq0255::new(vec![binary_sv2::U256::from([1; 32])]).unwrap(), - coinbase_tx_prefix: binary_sv2::B064K::try_from(vec![0, 1, 1]).unwrap(), - coinbase_tx_suffix: binary_sv2::B064K::try_from(vec![0, 1, 1]).unwrap(), - }; - let message_as_serde_value = serde_json::to_value(message.clone()).unwrap(); - let message_as_string = serde_json::to_string(&message_as_serde_value).unwrap(); - let message_new: NewExtendedMiningJob = serde_json::from_str(&message_as_string).unwrap(); - - assert!(message_new == message); - } - - fn test_serialize_and_deserialize_5_scmj() { - let message = SetCustomMiningJob { - channel_id: 1, - request_id: 1, - token: binary_sv2::B0255::try_from(vec![3, 0, 0, 0]).unwrap(), - version: 2, - prev_hash: binary_sv2::U256::from([1; 32]), - min_ntime: 0, - nbits: 1, - coinbase_tx_version: 2, - coinbase_prefix: binary_sv2::B0255::try_from(vec![3, 0, 0, 0]).unwrap(), - coinbase_tx_input_n_sequence: 1, - coinbase_tx_value_remaining: 1, - coinbase_tx_outputs: binary_sv2::B064K::try_from(vec![0, 1, 1]).unwrap(), - coinbase_tx_locktime: 1, - merkle_path: binary_sv2::Seq0255::new(vec![binary_sv2::U256::from([1; 32])]).unwrap(), - extranonce_size: 20, - }; - let message_as_serde_value = serde_json::to_value(message.clone()).unwrap(); - let message_as_string = serde_json::to_string(&message_as_serde_value).unwrap(); - let message_new: SetCustomMiningJob = serde_json::from_str(&message_as_string).unwrap(); - - assert!(message_new == message); - } - - //DeclareMiningJob in Declaration Protocol - // TODO! MAKE THIS TEST COMPILE AND PASS! - //fn test_serialize_and_deserialize_6_dmj() { - // let message = DeclareMiningJob { - // request_id: 1, - // mining_job_token: binary_sv2::B0255::try_from(vec![3, 0, 0, 0]).unwrap(), - // version: 2, - // coinbase_tx_version: 2, - // coinbase_prefix: todo!(), - // coinbase_tx_input_n_sequence: 1, - // coinbase_tx_value_remaining: 1, - // coinbase_tx_outputs: binary_sv2::B064K::try_from(vec![0, 1, 1]).unwrap(), - // coinbase_tx_locktime: 1, - // min_extranonce_size: 1, - // tx_short_hash_nonce: 1, - // tx_short_hash_list: binary_sv2::Seq064K::new(vec![binary_sv2::ShortTxId::try_from( - // [1; 32], - // )]), - // tx_hash_list_hash: todo!(), - // excess_data: todo!(), - // }; - // let message_as_serde_value = serde_json::to_value(message.clone()).unwrap(); - // let message_as_string = serde_json::to_string(&message_as_serde_value).unwrap(); - // let message_new: DeclareMiningJob = serde_json::from_str(&message_as_string).unwrap(); - - // assert!(message_new == message); - //} - - #[tokio::test] - async fn it_send_and_receive() { - let mut childs = vec![]; - let message = CloseChannel { - channel_id: 78, - reason_code: "no reason".to_string().try_into().unwrap(), - }; - let frame = Sv2Frame::from_message( - message.clone(), - const_sv2::MESSAGE_TYPE_CLOSE_CHANNEL, - 0, - true, - ) - .unwrap(); - let server_socket = SocketAddr::new("127.0.0.1".parse().unwrap(), 54254); - let client_socket = SocketAddr::new("127.0.0.1".parse().unwrap(), 54254); - let ((server_recv, server_send), (client_recv, client_send)) = join!( - setup_as_upstream(server_socket, None, vec![], &mut childs), - setup_as_downstream(client_socket, None) - ); - server_send - .send(frame.clone().try_into().unwrap()) - .await - .unwrap(); - client_send - .send(frame.clone().try_into().unwrap()) - .await - .unwrap(); - let server_received = server_recv.recv().await.unwrap(); - let client_received = client_recv.recv().await.unwrap(); - match (server_received, client_received) { - (EitherFrame::Sv2(mut frame1), EitherFrame::Sv2(mut frame2)) => { - let mt1 = frame1.get_header().unwrap().msg_type(); - let mt2 = frame2.get_header().unwrap().msg_type(); - let p1 = frame1.payload(); - let p2 = frame2.payload(); - let message1: Mining = (mt1, p1).try_into().unwrap(); - let message2: Mining = (mt2, p2).try_into().unwrap(); - match (message1, message2) { - (Mining::CloseChannel(message1), Mining::CloseChannel(message2)) => { - assert!(message1.channel_id == message2.channel_id); - assert!(message2.channel_id == message.channel_id); - assert!(message1.reason_code == message2.reason_code); - assert!(message2.reason_code == message.reason_code); - } - _ => assert!(false), - } - } - _ => assert!(false), - } - } - - #[test] - fn it_create_tests_with_different_messages() { - let message1 = CloseChannel { - channel_id: 78, - reason_code: "no reason".to_string().try_into().unwrap(), - }; - let maximum_target: binary_sv2::U256 = [0; 32].try_into().unwrap(); - let message2 = SetTarget { - channel_id: 78, - maximum_target, - }; - let message1 = Mining::CloseChannel(message1); - let message2 = Mining::SetTarget(message2); - let frame = Sv2Frame::from_message( - message1.clone(), - const_sv2::MESSAGE_TYPE_CLOSE_CHANNEL, - 0, - true, - ) - .unwrap(); - let frame = EitherFrame::Sv2(frame); - let frame2 = Sv2Frame::from_message( - message2.clone(), - const_sv2::MESSAGE_TYPE_CLOSE_CHANNEL, - 0, - true, - ) - .unwrap(); - let frame2 = EitherFrame::Sv2(frame2); - let _ = vec![frame, frame2]; - assert!(true) - } - - //#[tokio::test] - //async fn it_initialize_a_pool_and_connect_to_it() { - // //let mut bitcoind = os_command( - // // "./test/bin/bitcoind", - // // vec!["--regtest", "--datadir=./test/appdata/bitcoin_data/"], - // // ExternalCommandConditions::new_with_timer_secs(10) - // // .continue_if_std_out_have("sv2 thread start") - // // .fail_if_anything_on_std_err(), - // //) - // //.await; - // //let mut child = os_command( - // // "./test/bin/bitcoin-cli", - // // vec![ - // // "--regtest", - // // "--datadir=./test/appdata/bitcoin_data/", - // // "generatetoaddress", - // // "16", - // // "bcrt1qttuwhmpa7a0ls5kr3ye6pjc24ng685jvdrksxx", - // // ], - // // ExternalCommandConditions::None, - // //) - // //.await; - // //child.unwrap().wait().await.unwrap(); - // let mut pool = os_command( - // "cargo", - // vec![ - // "llvm-cov", - // "--no-report", - // "run", - // "-p", - // "pool_sv2", - // "--", - // "-c", - // "./test/config/pool-config-sri-tp.toml", - // ], - // ExternalCommandConditions::new_with_timer_secs(60) - // .continue_if_std_out_have("Listening for encrypted connection on: - // 127.0.0.1:34254"), ) - // .await; - - // let setup_connection = CommonMessages::SetupConnection(SetupConnection { - // protocol: Protocol::MiningProtocol, - // min_version: 2, - // max_version: 2, - // flags: 0, - // endpoint_host: "".to_string().try_into().unwrap(), - // endpoint_port: 0, - // vendor: "".to_string().try_into().unwrap(), - // hardware_version: "".to_string().try_into().unwrap(), - // firmware: "".to_string().try_into().unwrap(), - // device_id: "".to_string().try_into().unwrap(), - // }); - - // let frame = Sv2Frame::from_message( - // setup_connection.clone(), - // const_sv2::MESSAGE_TYPE_SETUP_CONNECTION, - // 0, - // true, - // ) - // .unwrap(); - - // let frame = EitherFrame::Sv2(frame); - - // let pool_address = SocketAddr::new("127.0.0.1".parse().unwrap(), 34254); - // let pub_key: EncodedEd25519PublicKey = - // "2di19GHYQnAZJmEpoUeP7C3Eg9TCcksHr23rZCC83dvUiZgiDL" .to_string() - // .try_into() - // .unwrap(); - // tokio::time::sleep(std::time::Duration::from_secs(1)).await; - // let (recv_from_pool, send_to_pool) = setup_as_downstream(pool_address, - // Some(pub_key)).await; send_to_pool.send(frame.try_into().unwrap()).await.unwrap(); - // match recv_from_pool.recv().await.unwrap() { - // EitherFrame::Sv2(a) => { - // assert!(true) - // } - // _ => assert!(false), - // } - // let mut child = os_command( - // "rm", - // vec!["-rf", "./test/appdata/bitcoin_data/regtest"], - // ExternalCommandConditions::None, - // ) - // .await; - // child.unwrap().wait().await.unwrap(); - - // // TODO not panic in network utils but return an handler - // //pool.kill().unwrap(); - // //bitcoind.kill().await.unwrap(); - // assert!(true) - //} - - //#[tokio::test] - //async fn it_test_against_remote_endpoint() { - // let proxy = match os_command( - // "cargo", - // vec![ - // "run", - // "-p", - // "mining-proxy", - // "--", - // "-c", - // "./test/config/ant-pool-config.toml", - // ], - // ExternalCommandConditions::new_with_timer_secs(10) - // .continue_if_std_out_have("PROXY INITIALIZED") - // .warn_no_panic(), - // ) - // .await - // { - // Some(child) => child, - // None => { - // write!( - // &mut std::io::stdout(), - // "WARNING: remote not avaiable it_test_against_remote_endpoint not executed" - // ) - // .unwrap(); - // return; - // } - // }; - // //loop {} - // let _ = os_command( - // "cargo", - // vec!["run", "-p", "mining-device"], - // ExternalCommandConditions::new_with_timer_secs(10) - // .continue_if_std_out_have("channel opened with"), - // ) - // .await; - // assert!(true) - //} -} diff --git a/utils/message-generator/src/net.rs b/utils/message-generator/src/net.rs deleted file mode 100644 index 8893a9bd5b..0000000000 --- a/utils/message-generator/src/net.rs +++ /dev/null @@ -1,135 +0,0 @@ -use crate::{os_command, Command}; -use async_channel::{bounded, Receiver, Sender}; -use binary_sv2::{Deserialize, GetSize, Serialize}; -use codec_sv2::{HandshakeRole, Initiator, Responder, StandardEitherFrame as EitherFrame}; -use key_utils::{Secp256k1PublicKey, Secp256k1SecretKey}; -use network_helpers_sv2::{ - noise_connection_tokio::Connection, plain_connection_tokio::PlainConnection, -}; -use std::{net::SocketAddr, time::Duration}; -use tokio::{ - io::{AsyncReadExt, AsyncWriteExt}, - net::{TcpListener, TcpStream}, - task, -}; - -pub async fn setup_as_upstream< - 'a, - Message: Serialize + Deserialize<'a> + GetSize + Send + 'static, ->( - socket: SocketAddr, - keys: Option<(Secp256k1PublicKey, Secp256k1SecretKey)>, - execution_commands: Vec, - childs: &mut Vec>, -) -> (Receiver>, Sender>) { - let listner = TcpListener::bind(socket).await.unwrap(); - for command in execution_commands { - let child = os_command( - &command.command, - command.args.iter().map(String::as_str).collect(), - command.conditions, - ) - .await; - childs.push(child); - } - let (stream, _) = listner.accept().await.unwrap(); - match keys { - Some((publ, secret)) => { - let responder = Responder::from_authority_kp( - &publ.into_bytes(), - &secret.into_bytes(), - std::time::Duration::from_secs(6000), - ) - .unwrap(); - let (recv, sender, _, _) = Connection::new(stream, HandshakeRole::Responder(responder)) - .await - .unwrap(); - (recv, sender) - } - None => PlainConnection::new(stream).await, - } -} - -pub async fn setup_as_downstream< - 'a, - Message: Serialize + Deserialize<'a> + GetSize + Send + 'static, ->( - socket: SocketAddr, - key: Option, -) -> (Receiver>, Sender>) { - let stream = TcpStream::connect(socket).await.unwrap(); - match key { - Some(publ) => { - let initiator = Initiator::from_raw_k(publ.into_bytes()).unwrap(); - let (recv, sender, _, _) = Connection::new(stream, HandshakeRole::Initiator(initiator)) - .await - .unwrap(); - (recv, sender) - } - None => PlainConnection::new(stream).await, - } -} - -pub async fn setup_as_sv1_downstream(socket: SocketAddr) -> (Receiver, Sender) { - let socket = loop { - tokio::time::sleep(Duration::from_secs(1)).await; - match TcpStream::connect(socket).await { - Ok(st) => { - println!("CLIENT - connected to server at {}", socket); - break st; - } - Err(_) => { - println!("Server not ready... retry"); - continue; - } - } - }; - let (mut reader, mut writer) = socket.into_split(); - - let (sender_incoming, receiver_incoming): (Sender, Receiver) = bounded(10); - let (sender_outgoing, receiver_outgoing): (Sender, Receiver) = bounded(10); - - // RECEIVE INCOMING MESSAGES FROM TCP STREAM - task::spawn(async move { - loop { - let mut buf = vec![0; 1024]; - match reader.read(&mut buf).await { - Ok(n) => { - let message = String::from_utf8_lossy(&buf[..n]).to_string(); - sender_incoming.send(message).await.unwrap(); - buf.clear(); - } - Err(e) => { - // Just fail and force to reinitialize everything - println!("Failed to read from stream: {}", e); - sender_incoming.close(); - task::yield_now().await; - break; - } - } - } - }); - - // SEND INCOMING MESSAGES TO TCP STREAM - task::spawn(async move { - loop { - let received = receiver_outgoing.recv().await; - match received { - Ok(msg) => match (writer).write_all(msg.as_bytes()).await { - Ok(_) => (), - Err(_) => { - let _ = writer.shutdown().await; - } - }, - Err(_) => { - // Just fail and force to reinitilize everything - let _ = writer.shutdown().await; - println!("Failed to read from stream - terminating connection"); - task::yield_now().await; - break; - } - }; - } - }); - (receiver_incoming, sender_outgoing) -} diff --git a/utils/message-generator/src/parser/actions.rs b/utils/message-generator/src/parser/actions.rs deleted file mode 100644 index 23bf6188be..0000000000 --- a/utils/message-generator/src/parser/actions.rs +++ /dev/null @@ -1,174 +0,0 @@ -use crate::{Action, ActionResult, Role, SaveField, Sv1Action, Sv1ActionResult, Sv2Type}; -use codec_sv2::{buffer_sv2::Slice, StandardEitherFrame, Sv2Frame}; -use roles_logic_sv2::parsers::AnyMessage; -use serde_json::{Map, Value}; -use std::collections::HashMap; -use v1::json_rpc::StandardRequest; - -use super::sv2_messages::ReplaceField; - -pub struct Sv2ActionParser {} -pub struct Sv1ActionParser {} - -impl Sv2ActionParser { - pub fn from_step_2<'a, 'b: 'a>( - test: &'b str, - frames: HashMap, Slice>>, - //Action.messages: Vec<(EitherFrame>,AnyMessage<'a>,Vec<(String,String)>)> - messages: HashMap, Vec)>, - ) -> Vec> { - let test: Map = serde_json::from_str(test).unwrap(); - let actions = test.get("actions").unwrap().as_array().unwrap(); - let mut result = vec![]; - for action in actions { - let role = match action.get("role").unwrap().as_str().unwrap() { - "client" => Role::Downstream, - "server" => Role::Upstream, - role => panic!("Unknown role: {}", role), - }; - let mut action_frames = vec![]; - let ids = action.get("message_ids").unwrap().as_array().unwrap(); - for id in ids { - let frame = frames - .get(id.as_str().unwrap()) - .unwrap_or_else(|| { - panic!("Frame id not found: {} Impossible to parse action", id) - }) - .clone(); - let frame = StandardEitherFrame::Sv2(frame); - let message = messages.get(id.as_str().unwrap()); - let message = message - .unwrap_or_else(|| { - panic!("Message id not found: {} Impossible to parse action", id) - }) - .clone(); - action_frames.push((frame, message.0, message.1)); - } - - let actiondoc = action.get("actiondoc").map(|t| t.to_string()); - let mut action_results = vec![]; - let results = action.get("results").unwrap().as_array().unwrap(); - for result in results { - match result.get("type").unwrap().as_str().unwrap() { - "match_message_type" => { - let message_type = u8::from_str_radix(&result.get("value").unwrap().as_str().unwrap()[2..], 16).expect("Result message_type should be an hex value starting with 0x and not bigger than 0xff"); - action_results.push(ActionResult::MatchMessageType(message_type)); - } - "get_message_field" => { - let sv2_type = result.get("value").unwrap().clone(); - let sv2_type: (String, String, Vec) = - serde_json::from_value(sv2_type) - .expect("match_message_field values not correct"); - let get_message_field = ActionResult::GetMessageField { - subprotocol: sv2_type.0, - message_type: sv2_type.1, - fields: sv2_type.2, - }; - action_results.push(get_message_field); - } - "match_message_field" => { - let sv2_type = result.get("value").unwrap().clone(); - let sv2_type: (String, String, Vec<(String, Sv2Type)>) = - serde_json::from_value(sv2_type) - .expect("match_message_field values not correct"); - action_results.push(ActionResult::MatchMessageField(sv2_type)); - } - "match_message_len" => { - let message_len = result.get("value").unwrap().as_u64().unwrap() as usize; - action_results.push(ActionResult::MatchMessageLen(message_len)); - } - "match_extension_type" => { - let extension_type = result - .get("extension_type") - .unwrap() - .as_str() - .unwrap() - .replace('_', "") - .parse::() - .unwrap(); - action_results.push(ActionResult::MatchExtensionType(extension_type)); - } - "close_connection" => { - action_results.push(ActionResult::CloseConnection); - } - "sustain_connection" => action_results.push(ActionResult::SustainConnection), - "none" => { - action_results.push(ActionResult::None); - } - type_ => panic!("Unknown result type {}", type_), - } - } - - let action = Action { - messages: action_frames, - result: action_results, - role, - actiondoc, - }; - result.push(action); - } - result - } -} - -impl Sv1ActionParser { - pub fn from_step_2( - test: &'_ str, - messages: HashMap)>, - ) -> Vec { - let test: Map = serde_json::from_str(test).unwrap(); - let actions = test.get("actions").unwrap().as_array().unwrap(); - let mut result = vec![]; - for action in actions { - let mut action_requests = vec![]; - let ids = action.get("message_ids").unwrap().as_array().unwrap(); - for id in ids { - let message = messages.get(id.as_str().unwrap()); - let message = message - .unwrap_or_else(|| { - panic!("Message id not found: {} Impossible to parse action", id) - }) - .clone(); - action_requests.push(message); - } - let actiondoc = action.get("actiondoc").map(|t| t.to_string()); - let mut action_results = vec![]; - let results = action.get("results").unwrap().as_array().unwrap(); - for result in results { - match result.get("type").unwrap().as_str().unwrap() { - "match_message_id" => { - let message_id = result.get("value").unwrap().as_u64().unwrap(); - action_results.push(Sv1ActionResult::MatchMessageId( - serde_json::to_value(message_id).unwrap(), - )); - } - "match_message_field" => { - let sv1_value = result.get("value").unwrap().clone(); - let sv1_value: (String, Vec<(String, Value)>) = - serde_json::from_value(sv1_value) - .expect("match_message_field values not correct"); - action_results.push(Sv1ActionResult::MatchMessageField { - message_type: sv1_value.0, - fields: sv1_value.1, - }); - } - "close_connection" => { - action_results.push(Sv1ActionResult::CloseConnection); - } - "none" => { - action_results.push(Sv1ActionResult::None); - } - type_ => panic!("Unknown result type {}", type_), - } - } - - let action = Sv1Action { - messages: action_requests, - result: action_results, - actiondoc, - }; - result.push(action); - } - result - } -} diff --git a/utils/message-generator/src/parser/frames.rs b/utils/message-generator/src/parser/frames.rs deleted file mode 100644 index b612415071..0000000000 --- a/utils/message-generator/src/parser/frames.rs +++ /dev/null @@ -1,86 +0,0 @@ -use super::sv2_messages::{message_from_path, ReplaceField}; -use codec_sv2::{buffer_sv2::Slice, Sv2Frame}; -use roles_logic_sv2::parsers::AnyMessage; -use serde_json::{Map, Value}; -use std::{collections::HashMap, convert::TryInto}; - -#[derive(Debug, Clone)] -pub struct Frames<'a> { - pub frames: HashMap, Slice>>, -} - -impl<'a> Frames<'a> { - pub fn from_step_1<'b: 'a>( - test: &'b str, - messages: HashMap, Vec)>, - ) -> (Self, HashMap, Vec)>) { - let test: Map = serde_json::from_str(test).unwrap(); - let frames = test.get("frame_builders").unwrap().as_array().unwrap(); - let mut messages = messages.clone(); - - let mut result = HashMap::new(); - for frame in frames { - let id: Vec = frame - .get("message_id") - .unwrap() - .as_str() - .unwrap() - .to_string() - .split("::") - .map(|s| s.to_string()) - .collect(); - // If id consists of a single element, the it is the id of a message contained in the - // present file, otherwise returs [path, id_], where the message appears in the file - // indicated by path and appears under the label "id_" - //the length of id is at most 2 - let (message, id) = match &id.len() { - 1 => ( - messages - .get(&id[0]) - .unwrap_or_else(|| panic!("Missing messages message_id {}", id[0])) - .0 - .clone(), - id[0].clone(), - ), - 2 => { - // the function "message_from_id" returns a an AnyMessage from the path in - // input - let mut path = id[0].clone(); - std::string::String::insert_str(&mut path, 0, "../../../../"); - let message = message_from_path(&[path, id[1].clone()]); - // TODO: if a message is taken from a module, should it be allowed to have a - // replace_fields? perhaps not. In this case, check that no replace_field - // appears in message - messages.insert(id[1].clone(), (message.clone(), vec![])); - (message, id[1].clone()) - } - _ => panic!("The length if id vector should have length equal or less than 2"), - }; - let type_ = frame.get("type").unwrap().as_str().unwrap(); - match type_ { - "automatic" => { - let frame: Sv2Frame, Slice> = message.try_into().unwrap(); - result.insert(id, frame); - } - "manual" => { - let message_type = u8::from_str_radix(&frame.get("message_type").unwrap().as_str().unwrap()[2..], 16).expect("Frame message_type should be an hex value starting with 0x and not bigger than 0xff"); - let extension_type = frame - .get("extension_type") - .unwrap() - .as_str() - .unwrap() - .replace('_', "") - .parse::() - .unwrap(); - let channel_msg = frame.get("channel_msg").unwrap().as_bool().unwrap(); - let frame = - Sv2Frame::from_message(message, message_type, extension_type, channel_msg) - .unwrap(); - result.insert(id, frame); - } - _ => panic!("Unrecognized frames parsing type {}", type_), - } - } - (Frames { frames: result }, messages) - } -} diff --git a/utils/message-generator/src/parser/mod.rs b/utils/message-generator/src/parser/mod.rs deleted file mode 100644 index 9d5a05cfde..0000000000 --- a/utils/message-generator/src/parser/mod.rs +++ /dev/null @@ -1,457 +0,0 @@ -mod actions; -mod frames; -pub mod sv1_messages; -pub mod sv2_messages; - -use crate::{parser::sv2_messages::ReplaceField, Action, Command, Sv1Action, Test, TestVersion}; -use codec_sv2::{buffer_sv2::Slice, Sv2Frame}; -use frames::Frames; -use roles_logic_sv2::parsers::AnyMessage; -use serde_json::{Map, Value}; -use std::{collections::HashMap, convert::TryInto}; -use sv2_messages::TestMessageParser; -use v1::json_rpc::StandardRequest; - -use self::sv1_messages::Sv1TestMessageParser; - -#[derive(Debug, Clone)] -pub enum MessageMap<'a> { - V1MessageMap(HashMap)>), - V2MessageMap(HashMap, Vec)>), -} - -#[derive(Debug)] -pub enum ActionVec<'a> { - Sv1Action(Vec), - Sv2Action(Vec>), -} - -#[derive(Debug)] -pub enum Parser<'a> { - /// Parses any number or combination of messages to be later used by an action identified by - /// message id. - /// they are saved as (field_name, keyword) - Step1 { - version: TestVersion, - messages: MessageMap<'a>, - }, - /// Serializes messages into `Sv2Frames` identified by message id. - Step2 { - version: TestVersion, - messages: MessageMap<'a>, - frames: Option, Slice>>>, - }, - /// Parses the setup, execution, and cleanup shell commands, roles, and actions. - Step3 { - version: TestVersion, - messages: MessageMap<'a>, - frames: Option, Slice>>>, - actions: ActionVec<'a>, - }, - /// Prepare for execution. - Step4(Test<'a>), -} - -impl<'a> Parser<'a> { - pub fn parse_test<'b: 'a>(test: &'b str) -> Test<'a> { - let step1 = Self::initialize(test); - let step2 = step1.next_step(test); - let step3 = step2.next_step(test); - let step4 = step3.next_step(test); - match step4 { - Self::Step4(test) => test, - _ => unreachable!(), - } - } - - fn initialize<'b: 'a>(test: &'b str) -> Self { - let test_map: Map = serde_json::from_str(test).unwrap(); - let version: TestVersion = match test_map.get("version").unwrap().as_str().unwrap() { - "1" => TestVersion::V1, - "2" => TestVersion::V2, - _ => panic!("no version specified"), - }; - let messages = match version { - TestVersion::V1 => { - MessageMap::V1MessageMap(Sv1TestMessageParser::from_str(test).into_map()) - } - TestVersion::V2 => { - MessageMap::V2MessageMap(TestMessageParser::from_str(test).into_map()) - } - }; - - Self::Step1 { version, messages } - } - - fn next_step<'b: 'a>(self, test: &'b str) -> Self { - match self { - Self::Step1 { version, messages } => match messages { - MessageMap::V1MessageMap(_) => Self::Step2 { - version, - messages, - frames: None, - }, - MessageMap::V2MessageMap(m) => { - let (frames, messages) = Frames::from_step_1(test, m.clone()); - Self::Step2 { - version, - messages: MessageMap::V2MessageMap(messages), - frames: Some(frames.frames), - } - } - }, - Self::Step2 { - version, - messages, - frames, - } => match messages { - MessageMap::V1MessageMap(m) => { - let actions = actions::Sv1ActionParser::from_step_2(test, m.clone()); - Self::Step3 { - version, - messages: MessageMap::V1MessageMap(m), - frames: None, - actions: ActionVec::Sv1Action(actions), - } - } - MessageMap::V2MessageMap(m) => { - let actions = actions::Sv2ActionParser::from_step_2( - test, - frames.clone().unwrap(), - m.clone(), - ); - Self::Step3 { - version, - messages: MessageMap::V2MessageMap(m), - frames, - actions: ActionVec::Sv2Action(actions), - } - } - }, - Self::Step3 { - version, - messages: _, - frames: _, - actions, - } => { - let test: Map = serde_json::from_str(test).unwrap(); - let setup_commands = test.get("setup_commands").unwrap().as_array().unwrap(); - let execution_commands = - test.get("execution_commands").unwrap().as_array().unwrap(); - let cleanup_commands = test.get("cleanup_commands").unwrap().as_array().unwrap(); - - let setup_commmands: Vec = setup_commands - .iter() - .map(|s| serde_json::from_value(s.clone()).unwrap()) - .collect(); - let execution_commands: Vec = execution_commands - .iter() - .map(|s| serde_json::from_value(s.clone()).unwrap()) - .collect(); - let cleanup_commmands: Vec = cleanup_commands - .iter() - .map(|s| serde_json::from_value(s.clone()).unwrap()) - .collect(); - - let (as_upstream, as_dowstream) = match test.get("role").unwrap().as_str().unwrap() - { - "client" => { - let downstream = test.get("downstream").unwrap(); - let ip = downstream.get("ip").unwrap().as_str().unwrap(); - let port = downstream.get("port").unwrap().as_u64().unwrap() as u16; - let pub_key = downstream - .get("pub_key") - .map(|a| a.as_str().unwrap().to_string()); - ( - None, - Some(crate::Downstream { - addr: std::net::SocketAddr::new(ip.parse().unwrap(), port), - key: pub_key.map(|k| k.to_string().try_into().unwrap()), - }), - ) - } - "server" => { - let upstream = test.get("upstream").unwrap(); - let ip = upstream.get("ip").unwrap().as_str().unwrap(); - let port = upstream.get("port").unwrap().as_u64().unwrap() as u16; - let pub_key = upstream - .get("pub_key") - .map(|a| a.as_str().unwrap().to_string()); - let secret_key = upstream - .get("secret_key") - .map(|a| a.as_str().unwrap().to_string()); - let keys = match (pub_key, secret_key) { - (Some(p), Some(s)) => Some(( - p.to_string().try_into().unwrap(), - s.to_string().try_into().unwrap(), - )), - (None, None) => None, - _ => panic!(), - }; - ( - Some(crate::Upstream { - addr: std::net::SocketAddr::new(ip.parse().unwrap(), port), - keys, - }), - None, - ) - } - "proxy" => { - let downstream = test.get("downstream").unwrap(); - let ip = downstream.get("ip").unwrap().as_str().unwrap(); - let port = downstream.get("port").unwrap().as_u64().unwrap() as u16; - let pub_key = downstream - .get("pub_key") - .map(|a| a.as_str().unwrap().to_string()); - let downstream = crate::Downstream { - addr: std::net::SocketAddr::new(ip.parse().unwrap(), port), - key: pub_key.map(|k| k.to_string().try_into().unwrap()), - }; - - let upstream = test.get("upstream").unwrap(); - let ip = upstream.get("ip").unwrap().as_str().unwrap(); - let port = upstream.get("port").unwrap().as_u64().unwrap() as u16; - let pub_key = upstream - .get("pub_key") - .map(|a| a.as_str().unwrap().to_string()); - let secret_key = upstream - .get("secret_key") - .map(|a| a.as_str().unwrap().to_string()); - let keys = match (pub_key, secret_key) { - (Some(p), Some(s)) => Some(( - p.to_string().try_into().unwrap(), - s.to_string().try_into().unwrap(), - )), - (None, None) => None, - _ => panic!(), - }; - let upstream = crate::Upstream { - addr: std::net::SocketAddr::new(ip.parse().unwrap(), port), - keys, - }; - (Some(upstream), Some(downstream)) - } - "none" => (None, None), - role => panic!("Unknown role: {}", role), - }; - - let test = match actions { - ActionVec::Sv1Action(a) => Test { - version, - actions: None, - sv1_actions: Some(a), - as_upstream, - as_dowstream, - setup_commmands, - execution_commands, - cleanup_commmands, - }, - ActionVec::Sv2Action(a) => Test { - version, - actions: Some(a), - sv1_actions: None, - as_upstream, - as_dowstream, - setup_commmands, - execution_commands, - cleanup_commmands, - }, - }; - - Self::Step4(test) - } - Parser::Step4(test) => Parser::Step4(test), - } - } -} - -#[cfg(test)] -mod test { - use std::hash::Hash; - - use crate::Sv1ActionResult; - - use super::*; - use binary_sv2::*; - use serde_json::json; - - #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] - struct TestStruct<'decoder> { - #[serde(borrow)] - test_b016m: B016M<'decoder>, - #[serde(borrow)] - test_b0255: B0255<'decoder>, - #[serde(borrow)] - test_b032: B032<'decoder>, - #[serde(borrow)] - test_b064: B064K<'decoder>, - #[serde(borrow)] - test_seq_064k_bool: Seq064K<'decoder, bool>, - #[serde(borrow)] - test_seq_064k_b064k: Seq064K<'decoder, B064K<'decoder>>, - } - - #[test] - fn it_parse_test() { - let test = std::fs::read_to_string("./test.json").unwrap(); - let step1 = Parser::initialize(&test); - - let step2 = step1.next_step(&test); - let step3 = step2.next_step(&test); - let step4 = step3.next_step(&test); - match step4 { - Parser::Step4(test) => { - assert!(test.actions.unwrap().len() == 2); - assert_eq!(test.version, TestVersion::V2); - } - _ => unreachable!(), - } - } - - #[test] - fn it_parse_sequences() { - let test_json = r#" - { - "test_b016m": [1,1], - "test_b0255": [1,1], - "test_b032": [1,1], - "test_b064": [1,1], - "test_seq_064k_bool": [true,false], - "test_seq_064k_b064k": [[1,2],[3,4]] - } - "#; - let test_struct: TestStruct = serde_json::from_str(test_json).unwrap(); - assert!(test_struct.test_b016m == vec![1, 1].try_into().unwrap()); - assert!(test_struct.test_b0255 == vec![1, 1].try_into().unwrap()); - assert!(test_struct.test_b032 == vec![1, 1].try_into().unwrap()); - assert!(test_struct.test_b064 == vec![1, 1].try_into().unwrap()); - assert!(test_struct.test_b064 == vec![1, 1].try_into().unwrap()); - assert!(test_struct.test_seq_064k_bool.into_inner() == vec![true, false]); - assert!( - test_struct.test_seq_064k_b064k.into_inner() - == vec![ - vec![1, 2].try_into().unwrap(), - vec![3, 4].try_into().unwrap(), - ] - ); - } - - #[test] - fn it_parse_sv1_messages() { - let test_json = r#" - { - "version": "1", - "sv1_messages": [ - { - "message": { - "id": 1, - "method": "mining.subscribe", - "params": ["cpuminer/1.0.0"] - }, - "id": "mining.subscribe" - }, - { - "message": { - "id": 2, - "method": "mining.authorize", - "params": ["username", "password"] - }, - "id": "mining.authorize" - } - ] - } - "#; - let step1 = Parser::initialize(test_json); - let step2 = step1.next_step(test_json); - - let message1 = StandardRequest { - id: 1, - method: "mining.subscribe".to_string(), - params: json!(["cpuminer/1.0.0".to_string()]), - }; - let message2 = StandardRequest { - id: 2, - method: "mining.authorize".to_string(), - params: json!(["username".to_string(), "password".to_string()]), - }; - - match step2 { - Parser::Step2 { - version, - messages, - frames: _, - } => { - assert_eq!(version, TestVersion::V1); - match messages { - MessageMap::V1MessageMap(m) => { - assert_eq!(m.get("mining.subscribe").unwrap().0, message1); - assert_eq!(m.get("mining.authorize").unwrap().0, message2); - } - MessageMap::V2MessageMap(_) => unreachable!(), - } - } - _ => unreachable!(), - } - } - - #[test] - fn it_parse_sv1_actions() { - let test_json = r#" - { - "version": "1", - "sv1_messages": [ - { - "message": { - "id": 1, - "method": "mining.subscribe", - "params": ["cpuminer/1.0.0"] - }, - "id": "mining.subscribe" - } - ], - "actions": [ - { - "message_ids": ["mining.subscribe"], - "results": [ - { - "type": "match_message_id", - "value": 1 - } - ], - "actiondoc": "" - } - ] - } - "#; - - let message = StandardRequest { - id: 1, - method: "mining.subscribe".to_string(), - params: json!(["cpuminer/1.0.0".to_string()]), - }; - let result = Sv1ActionResult::MatchMessageId(serde_json::to_value(1).unwrap()); - let step1 = Parser::initialize(test_json); - let step2 = step1.next_step(test_json); - let step3 = step2.next_step(test_json); - - match step3 { - Parser::Step3 { - version, - messages: _, - frames, - actions, - } => { - assert_eq!(version, TestVersion::V1); - assert!(frames.is_none()); - match actions { - ActionVec::Sv1Action(a) => { - assert_eq!(a.get(0).unwrap().messages.get(0).unwrap().0, message); - assert_eq!(a.get(0).unwrap().result.get(0).unwrap(), &result); - } - _ => unreachable!(), - } - } - _ => unreachable!(), - } - } -} diff --git a/utils/message-generator/src/parser/sv1_messages.rs b/utils/message-generator/src/parser/sv1_messages.rs deleted file mode 100644 index c80f15950a..0000000000 --- a/utils/message-generator/src/parser/sv1_messages.rs +++ /dev/null @@ -1,77 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::collections::HashMap; -use v1::json_rpc::*; - -use super::sv2_messages::ReplaceField; - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Sv1Message { - message: StandardRequest, - id: String, - replace_fields: Option>, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Sv1TestMessageParser { - sv1_messages: Option>, -} - -impl Sv1TestMessageParser { - pub fn into_map(self) -> HashMap)> { - let mut map = HashMap::new(); - if let Some(sv1_messages) = self.sv1_messages { - for message in sv1_messages { - let id = message.id; - let replace_fields = match message.replace_fields { - Some(replace_fields) => replace_fields, - None => vec![], - }; - let message = message.message; - map.insert(id, (message, replace_fields)); - } - }; - map - } - - pub fn from_str(test: &str) -> Self { - serde_json::from_str(test).unwrap() - } -} - -#[cfg(test)] -mod test { - use serde_json::json; - - use super::*; - #[test] - fn it_parse_messages() { - let data = r#" - { - "sv1_messages": [ - { - "message": { - "id": 1, - "method": "mining.authorize", - "params": ["username", "password"] - }, - "id": "authorize" - } - ] - }"#; - let v: Sv1TestMessageParser = serde_json::from_str(data).unwrap(); - let m1 = &v.sv1_messages.unwrap()[0]; - let m2: Sv1Message = Sv1Message { - message: StandardRequest { - id: 1, - method: "mining.authorize".to_string(), - params: json!(["username", "password"]), - }, - id: "authorize".to_string(), - }; - - assert_eq!(m1.message.params, m2.message.params); - assert_eq!(m1.message.method, m2.message.method); - assert_eq!(m1.message.id, m2.message.id); - assert_eq!(m1.id, m2.id); - } -} diff --git a/utils/message-generator/src/parser/sv2_messages.rs b/utils/message-generator/src/parser/sv2_messages.rs deleted file mode 100644 index 22b0aa3a08..0000000000 --- a/utils/message-generator/src/parser/sv2_messages.rs +++ /dev/null @@ -1,469 +0,0 @@ -use binary_sv2::{Deserialize, Serialize}; -use roles_logic_sv2::{ - common_messages_sv2::{SetupConnectionError, SetupConnectionSuccess}, - parsers::AnyMessage, -}; -use std::collections::HashMap; - -/// It takes a path and an id. If at `path` there is a file, then it loads it and tries to -/// transform it in `TestmessageParser`. Therefore, with into_map, trasforms the -/// `TestMessageParser` in HashMap (id -> AnyMessage) and tries to take the value that corresponds -/// to id -pub fn message_from_path(path: &[String]) -> AnyMessage<'static> { - let id = path[1].clone(); - let path = path[0].clone(); - let messages = load_str!(&path); - let parsed = TestMessageParser::from_str(messages); - parsed - .into_map() - .get(&id) - .unwrap_or_else(|| panic!("There is no value matching the id {:?}", id)) - .0 - .clone() -} - -/// This parses a json object that may or may not (and in this case field is None) have a value -/// with a particular key. While parsing the file below, the mining_message filed is None -// { -// "common_messages": [ -// { -// "message": { -// "type": "SetupConnection", -// "protocol": 0, -// "min_version": 2, -// "max_version": 2, -// "flags": 1, -// "endpoint_host": "", -// "endpoint_port": 0, -// "vendor": "", -// "hardware_version": "", -// "firmware": "", -// "device_id": "" -// }, -// "id": "setup_connection_mining_hom" -// }, -// { -// "message": { -// "type": "SetupConnectionSuccess", -// "flags": 0, -// "used_version": 2 -// }, -// "id": "setup_connection_success_flag_0" -// } -// ] -// } -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct TestMessageParser<'a> { - #[serde(borrow)] - common_messages: Option>>, - #[serde(borrow)] - job_declaration_messages: Option>>, - #[serde(borrow)] - mining_messages: Option>>, - #[serde(borrow)] - template_distribution_messages: Option>>, -} -/// This is not the same CommonMessages as the SRI, but the fiel message is. This structure is -/// needed because we use the id as a key to retrieve the message; this key is not part of the SRI -/// type CommonMessage<'a> -// { -//Defines an SRI messag "message": { -// "type": "SetupConnectionSuccess", -// "flags": 0, -// "used_version": 2 -// }, -//This is contained "id": "setup_connection_success_flag_0" -//field "id" } - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct ReplaceField { - pub field_name: String, - pub keyword: String, -} -impl ReplaceField { - #[allow(dead_code)] - fn from_vec_string_string(input: (String, String)) -> ReplaceField { - ReplaceField { - field_name: input.0, - keyword: input.1, - } - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -struct CommonMessage<'a> { - #[serde(borrow)] - message: CommonMessages<'a>, - id: String, - replace_fields: Option>, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -struct JobDeclarationMessage<'a> { - #[serde(borrow)] - message: JobDeclaration<'a>, - id: String, - // filed_name, keyword - replace_fields: Option>, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -struct MiningMessage<'a> { - #[serde(borrow)] - message: Mining<'a>, - id: String, - // filed_name, keyword - replace_fields: Option>, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -struct TemplateDistributionMessage<'a> { - #[serde(borrow)] - message: TemplateDistribution<'a>, - id: String, - // filed_name, keyword - replace_fields: Option>, -} - -impl<'a> TestMessageParser<'a> { - pub fn into_map(self) -> HashMap, Vec)> { - let mut map = HashMap::new(); - if let Some(common_messages) = self.common_messages { - for message in common_messages { - let id = message.id; - let replace_fields = match message.replace_fields { - Some(replace_fields) => replace_fields, - None => vec![], - }; - let message = message.message.into(); - map.insert(id, (message, replace_fields)); - } - }; - if let Some(job_declaration_messages) = self.job_declaration_messages { - for message in job_declaration_messages { - let id = message.id; - let replace_fields = match message.replace_fields { - Some(replace_fields) => replace_fields, - None => vec![], - }; - let message = message.message.into(); - let message = AnyMessage::JobDeclaration(message); - map.insert(id, (message, replace_fields)); - } - }; - if let Some(mining_messages) = self.mining_messages { - for message in mining_messages { - let id = message.id; - let replace_fields = match message.replace_fields { - Some(replace_fields) => replace_fields, - None => vec![], - }; - let message = message.message.into(); - let message = AnyMessage::Mining(message); - map.insert(id, (message, replace_fields)); - } - }; - if let Some(template_distribution_messages) = self.template_distribution_messages { - for message in template_distribution_messages { - let id = message.id; - let replace_fields = match message.replace_fields { - Some(replace_fields) => replace_fields, - None => vec![], - }; - let message = message.message.into(); - let message = AnyMessage::TemplateDistribution(message); - map.insert(id, (message, replace_fields)); - } - }; - map - } - - pub fn from_str<'b: 'a>(test: &'b str) -> Self { - serde_json::from_str(test).unwrap() - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn it_parse_messages() { - let data = r#" - { - "common_messages": [ - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 0, - "used_version": 2 - }, - "id": "setup_connection" - } - ], - "mining_messages": [ - { - "message": { - "type": "CloseChannel", - "channel_id": 78, - "reason_code": "no reason" - }, - "id": "close_channel" - } - ] - } - "#; - - let v: TestMessageParser = serde_json::from_str(data).unwrap(); - match v.common_messages.unwrap()[0].message { - CommonMessages::SetupConnectionSuccess(m) => { - assert!(m.used_version == 2); - assert!(m.flags == 0); - } - _ => panic!(), - } - match &v.mining_messages.unwrap()[0].message { - Mining::CloseChannel(m) => { - assert!(m.channel_id == 78); - let reason_code = m.reason_code.to_vec().clone(); - let reason_code = std::str::from_utf8(&reason_code[..]).unwrap(); - assert!(reason_code == "no reason".to_string()); - } - _ => panic!(), - } - } - - #[test] - fn it_can_be_converted_into_map() { - let data = r#" - { - "common_messages": [ - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 0, - "used_version": 2 - }, - "id": "setup_connection" - } - ], - "mining_messages": [ - { - "message": { - "type": "CloseChannel", - "channel_id": 78, - "reason_code": "no reason" - }, - "id": "close_channel" - } - ] - - } - "#; - - let v: TestMessageParser = serde_json::from_str(data).unwrap(); - let v = v.into_map(); - match v.get("setup_connection").unwrap().0 { - AnyMessage::Common( - roles_logic_sv2::parsers::CommonMessages::SetupConnectionSuccess(m), - ) => { - assert!(m.used_version == 2); - assert!(m.flags == 0); - } - _ => panic!(), - } - match &v.get("close_channel").unwrap().0 { - AnyMessage::Mining(roles_logic_sv2::parsers::Mining::CloseChannel(m)) => { - assert!(m.channel_id == 78); - let reason_code = m.reason_code.to_vec().clone(); - let reason_code = std::str::from_utf8(&reason_code[..]).unwrap(); - assert!(reason_code == "no reason".to_string()); - } - _ => panic!(), - } - } -} -use roles_logic_sv2::{ - common_messages_sv2::*, - job_declaration_sv2::*, - mining_sv2::*, - template_distribution_sv2::{ - CoinbaseOutputDataSize, NewTemplate, RequestTransactionData, RequestTransactionDataError, - RequestTransactionDataSuccess, SetNewPrevHash as TemplateSetNewPrevHash, SubmitSolution, - }, -}; - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(tag = "type")] -pub enum CommonMessages<'a> { - ChannelEndpointChanged(ChannelEndpointChanged), - #[serde(borrow)] - SetupConnection(SetupConnection<'a>), - #[serde(borrow)] - SetupConnectionError(SetupConnectionError<'a>), - SetupConnectionSuccess(SetupConnectionSuccess), -} - -impl<'a> From> for roles_logic_sv2::parsers::CommonMessages<'a> { - fn from(v: CommonMessages<'a>) -> Self { - match v { - CommonMessages::ChannelEndpointChanged(m) => Self::ChannelEndpointChanged(m), - CommonMessages::SetupConnection(m) => Self::SetupConnection(m), - CommonMessages::SetupConnectionError(m) => Self::SetupConnectionError(m), - CommonMessages::SetupConnectionSuccess(m) => Self::SetupConnectionSuccess(m), - } - } -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(tag = "type")] -pub enum TemplateDistribution<'a> { - CoinbaseOutputDataSize(CoinbaseOutputDataSize), - #[serde(borrow)] - NewTemplate(NewTemplate<'a>), - RequestTransactionData(RequestTransactionData), - #[serde(borrow)] - RequestTransactionDataError(RequestTransactionDataError<'a>), - #[serde(borrow)] - RequestTransactionDataSuccess(RequestTransactionDataSuccess<'a>), - #[serde(borrow)] - SetNewPrevHash(TemplateSetNewPrevHash<'a>), - #[serde(borrow)] - SubmitSolution(SubmitSolution<'a>), -} - -impl<'a> From> for roles_logic_sv2::parsers::TemplateDistribution<'a> { - fn from(v: TemplateDistribution<'a>) -> Self { - match v { - TemplateDistribution::CoinbaseOutputDataSize(m) => Self::CoinbaseOutputDataSize(m), - TemplateDistribution::NewTemplate(m) => Self::NewTemplate(m), - TemplateDistribution::RequestTransactionData(m) => Self::RequestTransactionData(m), - TemplateDistribution::RequestTransactionDataError(m) => { - Self::RequestTransactionDataError(m) - } - TemplateDistribution::RequestTransactionDataSuccess(m) => { - Self::RequestTransactionDataSuccess(m) - } - TemplateDistribution::SetNewPrevHash(m) => Self::SetNewPrevHash(m), - TemplateDistribution::SubmitSolution(m) => Self::SubmitSolution(m), - } - } -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(tag = "type")] -pub enum JobDeclaration<'a> { - #[serde(borrow)] - AllocateMiningJobTokenSuccess(AllocateMiningJobTokenSuccess<'a>), - #[serde(borrow)] - AllocateMiningJobToken(AllocateMiningJobToken<'a>), - #[serde(borrow)] - DeclareMiningJob(DeclareMiningJob<'a>), - #[serde(borrow)] - DeclareMiningJobSuccess(DeclareMiningJobSuccess<'a>), - #[serde(borrow)] - DeclareMiningJobError(DeclareMiningJobError<'a>), - ProvideMissingTransactions(ProvideMissingTransactions<'a>), - #[serde(borrow)] - ProvideMissingTransactionsSuccess(ProvideMissingTransactionsSuccess<'a>), - #[serde(borrow)] - SubmitSolution(SubmitSolutionJd<'a>), -} - -impl<'a> From> for roles_logic_sv2::parsers::JobDeclaration<'a> { - fn from(v: JobDeclaration<'a>) -> Self { - match v { - JobDeclaration::AllocateMiningJobTokenSuccess(m) => { - Self::AllocateMiningJobTokenSuccess(m) - } - JobDeclaration::AllocateMiningJobToken(m) => Self::AllocateMiningJobToken(m), - JobDeclaration::DeclareMiningJobSuccess(m) => Self::DeclareMiningJobSuccess(m), - JobDeclaration::DeclareMiningJob(m) => Self::DeclareMiningJob(m), - JobDeclaration::DeclareMiningJobError(m) => Self::DeclareMiningJobError(m), - JobDeclaration::ProvideMissingTransactions(m) => Self::ProvideMissingTransactions(m), - JobDeclaration::ProvideMissingTransactionsSuccess(m) => { - Self::ProvideMissingTransactionsSuccess(m) - } - JobDeclaration::SubmitSolution(m) => Self::SubmitSolution(m), - } - } -} - -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(tag = "type")] -pub enum Mining<'a> { - #[serde(borrow)] - CloseChannel(CloseChannel<'a>), - #[serde(borrow)] - NewExtendedMiningJob(NewExtendedMiningJob<'a>), - #[serde(borrow)] - NewMiningJob(NewMiningJob<'a>), - #[serde(borrow)] - OpenExtendedMiningChannel(OpenExtendedMiningChannel<'a>), - #[serde(borrow)] - OpenExtendedMiningChannelSuccess(OpenExtendedMiningChannelSuccess<'a>), - #[serde(borrow)] - OpenMiningChannelError(OpenMiningChannelError<'a>), - #[serde(borrow)] - OpenStandardMiningChannel(OpenStandardMiningChannel<'a>), - #[serde(borrow)] - OpenStandardMiningChannelSuccess(OpenStandardMiningChannelSuccess<'a>), - #[serde(borrow)] - Reconnect(Reconnect<'a>), - #[serde(borrow)] - SetCustomMiningJob(SetCustomMiningJob<'a>), - #[serde(borrow)] - SetCustomMiningJobError(SetCustomMiningJobError<'a>), - SetCustomMiningJobSuccess(SetCustomMiningJobSuccess), - #[serde(borrow)] - SetExtranoncePrefix(SetExtranoncePrefix<'a>), - #[serde(borrow)] - SetGroupChannel(SetGroupChannel<'a>), - #[serde(borrow)] - SetNewPrevHash(SetNewPrevHash<'a>), - #[serde(borrow)] - SetTarget(SetTarget<'a>), - #[serde(borrow)] - SubmitSharesError(SubmitSharesError<'a>), - #[serde(borrow)] - SubmitSharesExtended(SubmitSharesExtended<'a>), - SubmitSharesStandard(SubmitSharesStandard), - SubmitSharesSuccess(SubmitSharesSuccess), - #[serde(borrow)] - UpdateChannel(UpdateChannel<'a>), - #[serde(borrow)] - UpdateChannelError(UpdateChannelError<'a>), -} - -impl<'a> From> for roles_logic_sv2::parsers::Mining<'a> { - fn from(v: Mining<'a>) -> Self { - match v { - Mining::CloseChannel(m) => Self::CloseChannel(m), - Mining::NewExtendedMiningJob(m) => Self::NewExtendedMiningJob(m), - Mining::NewMiningJob(m) => Self::NewMiningJob(m), - Mining::OpenExtendedMiningChannel(m) => Self::OpenExtendedMiningChannel(m), - Mining::OpenExtendedMiningChannelSuccess(m) => { - Self::OpenExtendedMiningChannelSuccess(m) - } - Mining::OpenMiningChannelError(m) => Self::OpenMiningChannelError(m), - Mining::OpenStandardMiningChannel(m) => Self::OpenStandardMiningChannel(m), - Mining::OpenStandardMiningChannelSuccess(m) => { - Self::OpenStandardMiningChannelSuccess(m) - } - Mining::Reconnect(m) => Self::Reconnect(m), - Mining::SetCustomMiningJob(m) => Self::SetCustomMiningJob(m), - Mining::SetCustomMiningJobError(m) => Self::SetCustomMiningJobError(m), - Mining::SetCustomMiningJobSuccess(m) => Self::SetCustomMiningJobSuccess(m), - Mining::SetExtranoncePrefix(m) => Self::SetExtranoncePrefix(m), - Mining::SetGroupChannel(m) => Self::SetGroupChannel(m), - Mining::SetNewPrevHash(m) => Self::SetNewPrevHash(m), - Mining::SetTarget(m) => Self::SetTarget(m), - Mining::SubmitSharesError(m) => Self::SubmitSharesError(m), - Mining::SubmitSharesExtended(m) => Self::SubmitSharesExtended(m), - Mining::SubmitSharesStandard(m) => Self::SubmitSharesStandard(m), - Mining::SubmitSharesSuccess(m) => Self::SubmitSharesSuccess(m), - Mining::UpdateChannel(m) => Self::UpdateChannel(m), - Mining::UpdateChannelError(m) => Self::UpdateChannelError(m), - } - } -} diff --git a/utils/message-generator/test.json b/utils/message-generator/test.json deleted file mode 100644 index d3e376a05d..0000000000 --- a/utils/message-generator/test.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "version": "2", - "doc": [ - "What this test does:", - "1) launch SRI pool and wait for initialization", - "2) connect to the pool as a Downstream that uses noise", - "3) send SetupConnection to the pool", - "4) check that SetupConnectionSuccess is received", - "5) send OpenStandardMiningChannel with request id 89", - "6) check that NewExtendedJob is received", - "7) check that NewPrevHash is received", - "8) check that OpenStandardMiningChannelSuccess with request 89 is received" - ], - "common_messages": [ - { - "message": { - "type": "SetupConnection", - "protocol": 0, - "min_version": 2, - "max_version": 2, - "flags": 0, - "endpoint_host": "", - "endpoint_port": 0, - "vendor": "", - "hardware_version": "", - "firmware": "", - "device_id": "" - }, - "id": "setup_connection" - }, - { - "message": { - "type": "SetupConnectionSuccess", - "flags": 0, - "used_version": 2 - }, - "id": "setup_connection_success" - } - ], - "mining_messages": [ - { - "message": { - "type": "OpenStandardMiningChannel", - "request_id": 89, - "user_identity": "", - "nominal_hash_rate": 10, - "max_target": [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1] - }, - "id": "open_standard_mining_channel" - } - ], - "frame_builders": [ - { - "type": "automatic", - "message_id": "setup_connection_success" - }, - { - "type": "automatic", - "message_id": "setup_connection" - }, - { - "type": "automatic", - "message_id": "open_standard_mining_channel" - } - ], - "actions": [ - { - "message_ids": ["setup_connection"], - "role": "client", - "results": [ - { - "type": "match_message_type", - "value": "0x01" - } - ], - "actiondoc": "" - }, - { - "message_ids": ["open_standard_mining_channel"], - "role": "client", - "results": [ - { - "type": "match_message_field", - "value": [ - "MiningProtocol", - "OpenStandardMiningChannelSuccess", - [ - [ - "request_id", - {"U32": 89} - ], - [ - "extranonce_prefix", - {"B032": [[32], [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]]} - ] - ] - ] - }, - { - "type": "match_message_type", - "value": "0x20" - }, - { - "type": "match_message_type", - "value": "0x1f" - } - ], - "actiondoc": "" - } - - ], - "setup_commands": [ - { - "command": "cargo", - "args": [ - "run", - "-p", - "pool", - "--", - "-c", - "./test/config/pool-config-sri-tp.toml" - ], - "conditions": { - "WithConditions": { - "conditions": [ - { - "output_string": "Listening for encrypted connection on: 0.0.0.0:34254", - "output_location": "StdOut", - "condition": true - } - ], - "timer_secs": 60, - "warn_no_panic": false - } - } - } - ], - "execution_commands": [ - ], - "cleanup_commands": [ - ], - "role": "client", - "downstream": { - "ip": "0.0.0.0", - "port": 34254, - "pub_key": "2di19GHYQnAZJmEpoUeP7C3Eg9TCcksHr23rZCC83dvUiZgiDL" - } -}