Skip to content

Commit

Permalink
Merge pull request fedimint#6201 from bradleystachurski/fix-rbf-test
Browse files Browse the repository at this point in the history
fix(tests): retry client balance check to prevent flakiness
  • Loading branch information
bradleystachurski authored Oct 22, 2024
2 parents 594c5ab + 0c2fc74 commit ca1b4e4
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions modules/fedimint-wallet-tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use fedimint_wallet_server::WalletInit;
use futures::stream::StreamExt;
use secp256k1::rand::rngs::OsRng;
use tokio::select;
use tracing::info;
use tracing::{info, warn};

fn fixtures() -> Fixtures {
let fixtures = Fixtures::new_primary(DummyClientInit, DummyInit, DummyGenParams::default());
Expand Down Expand Up @@ -497,11 +497,30 @@ async fn rbf_withdrawals_are_rejected() -> anyhow::Result<()> {
sats(PEG_OUT_AMOUNT_SATS)
);

let current_balance = client.get_balance().await;
assert_eq!(
current_balance, balance_after_normal_peg_out,
"Balance is {current_balance}, expected {balance_after_normal_peg_out}"
);
// to prevent flakiness, we need to retry this check
// see: https://github.com/fedimint/fedimint/issues/6190
fedimint_core::util::retry(
"verify client balance",
fedimint_core::util::backoff_util::custom_backoff(
Duration::from_millis(100),
Duration::from_millis(100),
Some(100),
),
|| async {
let current_balance = client.get_balance().await;
if current_balance == balance_after_normal_peg_out {
Ok(())
} else {
let msg = format!(
"Balance is {current_balance}, expected {balance_after_normal_peg_out}"
);
warn!(msg);
Err(anyhow::anyhow!(msg))
}
},
)
.await
.expect("couldn't verify balance within 10s");

Ok(())
}
Expand Down

0 comments on commit ca1b4e4

Please sign in to comment.