Skip to content

Commit

Permalink
fix(test): do not overwhelm the nodes and the client
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Jul 6, 2024
1 parent 3a0d718 commit 45ca228
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ jobs:
fi
- name: execute the spend simulation
run: cargo test --release -p sn_node --features="local-discovery" --test spend_simulation -- --nocapture --test-threads=1
run: cargo test --release -p sn_node --features="local-discovery" --test spend_simulation -- --nocapture
env:
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 25
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ jobs:
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
run: cargo test --release -p sn_node --features="local-discovery" --test spend_simulation -- --nocapture
env:
CARGO_TARGET_DIR: ${{ matrix.os == 'windows-latest' && './test-target' || '.' }}
timeout-minutes: 25
Expand Down
7 changes: 4 additions & 3 deletions sn_node/tests/spend_simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use std::{
use tokio::sync::mpsc;
use tracing::*;

const MAX_WALLETS: usize = 30;
const MAX_CYCLES: usize = 10;
const MAX_WALLETS: usize = 15;
const MAX_CYCLES: usize = 5;
const AMOUNT_PER_RECIPIENT: NanoTokens = NanoTokens::from(1000);
/// The chance for an attack to happen. 1 in X chance.
const ONE_IN_X_CHANCE_FOR_AN_ATTACK: u32 = 2;
Expand Down Expand Up @@ -125,7 +125,7 @@ struct PendingTasksTracker {
/// cycle is repeated until the max cycles are reached.
#[tokio::test]
async fn spend_simulation() -> Result<()> {
let _log_guards = LogBuilder::init_single_threaded_tokio_test("spend_simulation", true);
let _log_guards = LogBuilder::init_single_threaded_tokio_test("spend_simulation", false);

let (client, mut state) = init_state(MAX_WALLETS).await?;

Expand Down Expand Up @@ -157,6 +157,7 @@ async fn spend_simulation() -> Result<()> {
.map(|(id, s)| (*id, s.clone()))
.collect_vec();
for (id, action_sender) in iter {
tokio::time::sleep(Duration::from_secs(3)).await;
let illicit_spend = rng.gen::<u32>() % ONE_IN_X_CHANCE_FOR_AN_ATTACK == 0;

if illicit_spend {
Expand Down

0 comments on commit 45ca228

Please sign in to comment.