Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

2024 12 13 int test cleanup #39

Merged
merged 13 commits into from
Jan 9, 2025
Merged
32 changes: 32 additions & 0 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
push:
branches:
- main
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-musl

steps:
- name: Use stable toolchain
uses: actions/checkout@v4
with:
profile: minimal
toolchain: stable
override: true

- name: Roles Integration Tests
run: |
cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture
4 changes: 0 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ jobs:
cargo build --manifest-path=roles/Cargo.toml
cargo build --manifest-path=utils/Cargo.toml

- name: Roles Integration Tests
run: |
cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture

- name: Run sv1-client-and-server example
run: |
cargo run --manifest-path=examples/sv1-client-and-server/Cargo.toml --bin client_and_server -- 60
Expand Down
2 changes: 1 addition & 1 deletion roles/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions roles/jd-client/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub static IS_NEW_TEMPLATE_HANDLED: AtomicBool = AtomicBool::new(true);
/// switching to backup Pools in case of declared custom jobs refused by JDS (which is Pool side).
/// As a solution of last-resort, it is able to switch to Solo Mining until new safe Pools appear
/// in the market.
#[derive(Debug, Clone)]
pub struct JobDeclaratorClient {
/// Configuration of the proxy server [`JobDeclaratorClient`] is connected to.
config: ProxyConfig,
Expand Down
1 change: 1 addition & 0 deletions roles/jd-server/src/lib/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub type Message = JdsMessages<'static>;
pub type StdFrame = StandardSv2Frame<Message>;
pub type EitherFrame = StandardEitherFrame<Message>;

#[derive(Debug, Clone)]
pub struct JobDeclaratorServer {
config: Configuration,
}
Expand Down
4 changes: 2 additions & 2 deletions roles/tests-integration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "integration-test"
name = "integration_tests_sv2"
version = "0.1.0"
authors = ["The Stratum V2 Developers"]
edition = "2018"
Expand Down Expand Up @@ -35,4 +35,4 @@ rand = "0.8.4"
stratum-common = { path = "../../common" }

[lib]
path = "tests/common/mod.rs"
path = "lib/mod.rs"
26 changes: 26 additions & 0 deletions roles/tests-integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SV2 Integration Tests

This is a test crate and it can be used in order to test the behavior of different roles when
working together. Each role should have a `start_[role_name]` function under `common` folder that
can be called in order to run the role. In order to assert the behavior of the role or the messages
it exchanges with other roles, you can use the `Sniffer` helper in order to listen to the messages
exchanged between the roles, and assert those messages using the `assert_message_[message_type]`
function. For examples on how to use the `Sniffer` helper, you can check the
`sniffer_integration.rs` module or other tests in the `tests` folder.

All of our tests run in regtest network. We download the Template Provider node from
https://github.com/Sjors/bitcoin/releases/download. This is a pre-built binary that we use to run an
Stratum V2 compatible bitcoin node. Note that this is the only external dependency(and Role) that we
have in our tests.

## Running Instructions

In order to run the integration tests, you can use the following command:

```bash
$ git clone [email protected]:stratum-mining/stratum.git
$ cargo test --manifest-path=roles/Cargo.toml --verbose --test '*' -- --nocapture
```

## License
MIT OR Apache-2.0
Loading
Loading