Skip to content

Commit

Permalink
fix(ci): run spend simulation as its own test
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Jul 5, 2024
1 parent a64b2c1 commit 48bc9ed
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 6 deletions.
65 changes: 63 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ jobs:
timeout-minutes: 30

- name: Build testing executable
run: cargo test --release -p sn_node --features=local-discovery --test sequential_transfers --test storage_payments --test double_spend --test spend_simulation --no-run
run: cargo test --release -p sn_node --features=local-discovery --test sequential_transfers --test storage_payments --test double_spend --no-run
env:
# only set the target dir for windows to bypass the linker issue.
# happens if we build the node manager via testnet action
Expand Down Expand Up @@ -406,6 +406,67 @@ jobs:
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 25

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
log_file_prefix: safe_test_logs_spend
platform: ${{ matrix.os }}

# runs with increased node count
spend_simulation:
if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
name: spend simulation
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Build binaries
run: cargo build --release --features=local-discovery --bin safenode
timeout-minutes: 30

- name: Build faucet binary
run: cargo build --release --bin faucet --features="local-discovery,gifting"
timeout-minutes: 30

- name: Build testing executable
run: cargo test --release -p sn_node --features=local-discovery --test spend_simulation --no-run
env:
# only set the target dir for windows to bypass the linker issue.
# happens if we build the node manager via testnet action
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
with:
action: start
interval: 2000
node-count: 50
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: Check SAFE_PEERS was set
shell: bash
run: |
if [[ -z "$SAFE_PEERS" ]]; then
echo "The SAFE_PEERS variable has not been set"
exit 1
else
echo "SAFE_PEERS has been set to $SAFE_PEERS"
fi
- name: execute the spend simulation
run: cargo test --release -p sn_node --features="local-discovery" --test spend_simulation -- --nocapture --test-threads=1
env:
Expand All @@ -417,7 +478,7 @@ jobs:
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
log_file_prefix: safe_test_logs_spend
log_file_prefix: safe_test_logs_spend_simulation
platform: ${{ matrix.os }}

token_distribution_test:
Expand Down
65 changes: 62 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
timeout-minutes: 30

- name: Build testing executable
run: cargo test --release -p sn_node --features=local-discovery --test sequential_transfers --test storage_payments --test double_spend --test spend_simulation --no-run
run: cargo test --release -p sn_node --features=local-discovery --test sequential_transfers --test storage_payments --test double_spend --no-run
env:
# only set the target dir for windows to bypass the linker issue.
# happens if we build the node manager via testnet action
Expand All @@ -221,7 +221,7 @@ jobs:
build: true

- name: execute the sequential transfers test
run: cargo test --release -p sn_node --features="local-discovery" --test sequential_transfers -- --nocapture
run: cargo test --release -p sn_node --features="local-discovery" --test sequential_transfers -- --nocapture --test-threads=1
env:
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
SN_LOG: "all"
Expand All @@ -240,6 +240,65 @@ jobs:
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 25

- name: Small wait to allow reward receipt
run: sleep 30
timeout-minutes: 1

- name: Stop the local network and upload logs
if: always()
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
log_file_prefix: safe_test_logs_spend
platform: ${{ matrix.os }}

- name: post notification to slack on failure
if: ${{ failure() }}
uses: bryannice/[email protected]
env:
SLACK_INCOMING_WEBHOOK: ${{ secrets.SLACK_GH_ACTIONS_WEBHOOK_URL }}
SLACK_MESSAGE: "Please check the logs for the run at ${{ env.WORKFLOW_URL }}/${{ github.run_id }}"
SLACK_TITLE: "Nightly Spend Test Run Failed"

# runs with increased node count
spend_simulation:
name: spend simulation
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2
continue-on-error: true

- name: Build binaries
run: cargo build --release --features=local-discovery --bin safenode --bin faucet
timeout-minutes: 30

- name: Build testing executable
run: cargo test --release -p sn_node --features=local-discovery --test spend_simulation --no-run
env:
# only set the target dir for windows to bypass the linker issue.
# happens if we build the node manager via testnet action
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 30

- name: Start a local network
uses: maidsafe/sn-local-testnet-action@main
with:
action: start
interval: 2000
node-count: 50
node-path: target/release/safenode
faucet-path: target/release/faucet
platform: ${{ matrix.os }}
build: true

- name: execute the spend simulation test
run: cargo test --release -p sn_node --features="local-discovery" --test spend_simulation -- --nocapture --test-threads=1
env:
Expand All @@ -255,7 +314,7 @@ jobs:
uses: maidsafe/sn-local-testnet-action@main
with:
action: stop
log_file_prefix: safe_test_logs_spend
log_file_prefix: safe_test_logs_spend_simulation
platform: ${{ matrix.os }}

- name: post notification to slack on failure
Expand Down
2 changes: 1 addition & 1 deletion sn_node/tests/spend_simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::{
use tokio::sync::mpsc;
use tracing::*;

const MAX_WALLETS: usize = 50;
const MAX_WALLETS: usize = 30;
const MAX_CYCLES: usize = 10;
const AMOUNT_PER_RECIPIENT: NanoTokens = NanoTokens::from(1000);
/// The chance for an attack to happen. 1 in X chance.
Expand Down

0 comments on commit 48bc9ed

Please sign in to comment.