From 8bcab6dfa001ead528702de996cce3144eb72e38 Mon Sep 17 00:00:00 2001 From: grumbach Date: Mon, 29 Jul 2024 17:44:34 +0200 Subject: [PATCH] test: bump sleep time to 20s --- sn_node/tests/double_spend.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/sn_node/tests/double_spend.rs b/sn_node/tests/double_spend.rs index 22401815e3..414703e3e1 100644 --- a/sn_node/tests/double_spend.rs +++ b/sn_node/tests/double_spend.rs @@ -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,18 +479,17 @@ 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)) => { @@ -500,10 +497,6 @@ async fn parent_and_child_double_spends_should_lead_to_cashnote_being_invalid() }); 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)) => {