Skip to content

Commit

Permalink
test: bump sleep time to 20s
Browse files Browse the repository at this point in the history
grumbach committed Jul 29, 2024
1 parent 9fe6f44 commit 8bcab6d
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions sn_node/tests/double_spend.rs
Original file line number Diff line number Diff line change
@@ -87,16 +87,14 @@ async fn cash_note_transfer_double_spend_fail() -> Result<()> {
let res = client.send_spends(transfer_to_3.spends.iter(), false).await;
assert!(res.is_ok());

// check the CashNotes, it should fail
info!("Verifying the transfers from first wallet... Sleeping for 3 seconds.");
tokio::time::sleep(Duration::from_secs(3)).await;
// we wait 5s to ensure that the double spend attempt is detected and accumulated
info!("Verifying the transfers from first wallet... Sleeping for 10 seconds.");
tokio::time::sleep(Duration::from_secs(10)).await;

let cash_notes_for_2: Vec<_> = transfer_to_2.output_cashnotes.clone();
let cash_notes_for_3: Vec<_> = transfer_to_3.output_cashnotes.clone();

// we wait 5s to ensure that the double spend attempt is detected and accumulated
tokio::time::sleep(Duration::from_secs(5)).await;

// check the CashNotes, it should fail
let should_err1 = client.verify_cashnote(&cash_notes_for_2[0]).await;
let should_err2 = client.verify_cashnote(&cash_notes_for_3[0]).await;
info!("Both should fail during GET record accumulation : {should_err1:?} {should_err2:?}");
@@ -481,29 +479,24 @@ async fn parent_and_child_double_spends_should_lead_to_cashnote_being_invalid()

info!("Verifying the transfers from B -> Y wallet... It should error out.");
let cash_notes_for_y: Vec<_> = transfer_to_y.output_cashnotes.clone();
let result = client.verify_cashnote(&cash_notes_for_y[0]).await;
info!("Got result while verifying double spend from B -> Y: {result:?}");

// sleep for a bit to allow the network to process and accumulate the double spend
tokio::time::sleep(Duration::from_secs(10)).await;
tokio::time::sleep(Duration::from_secs(30)).await;

let result = client.verify_cashnote(&cash_notes_for_y[0]).await;
info!("Got result while verifying double spend from B -> Y: {result:?}");
assert_matches!(result, Err(WalletError::CouldNotVerifyTransfer(str)) => {
assert!(str.starts_with("Network Error Double spend(s) was detected"));
});

info!("Verifying the original cashnote of A -> B");

let result = client.verify_cashnote(&cash_notes_for_b[0]).await;
info!("Got result while verifying the original spend from A -> B: {result:?}");
assert_matches!(result, Err(WalletError::CouldNotVerifyTransfer(str)) => {
assert!(str.starts_with("Network Error Double spend(s) attempt was detected"));
});

info!("Verifying the original cashnote of B -> C");

// arbitrary time sleep to allow for network accumulation of double spend.
tokio::time::sleep(Duration::from_secs(15)).await;

let result = client.verify_cashnote(&cash_notes_for_c[0]).await;
info!("Got result while verifying the original spend from B -> C: {result:?}");
assert_matches!(result, Err(WalletError::CouldNotVerifyTransfer(str)) => {

0 comments on commit 8bcab6d

Please sign in to comment.