Skip to content

Commit 966d34b

Browse files
authored
chore: fix flaky coin caching test (#1636)
The `coin caching` test was flaky as the node returns a random number of coins when requesting a certain amount. This led the test to fail when no more coins were available. I have increased the initial amount of coins and did not change the the test logic.
1 parent c37ce72 commit 966d34b

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

e2e/tests/providers.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,9 @@ async fn transactions_with_the_same_utxo() -> Result<()> {
836836

837837
#[cfg(feature = "coin-cache")]
838838
#[tokio::test]
839-
async fn test_caching() -> Result<()> {
839+
async fn coin_caching() -> Result<()> {
840840
let amount = 1000;
841-
let num_coins = 10;
841+
let num_coins = 50;
842842
let mut wallets = launch_custom_provider_and_get_wallets(
843843
WalletsConfig::new(Some(1), Some(num_coins), Some(amount)),
844844
Some(NodeConfig::default()),
@@ -852,9 +852,11 @@ async fn test_caching() -> Result<()> {
852852
// Consecutively send transfer txs. Without caching, the txs will
853853
// end up trying to use the same input coins because 'get_spendable_coins()'
854854
// won't filter out recently used coins.
855+
let num_iterations = 10;
856+
let amount_to_send = 100;
855857
let mut tx_ids = vec![];
856-
for _ in 0..10 {
857-
let tx = create_transfer(&wallet_1, 100, wallet_2.address()).await?;
858+
for _ in 0..num_iterations {
859+
let tx = create_transfer(&wallet_1, amount_to_send, wallet_2.address()).await?;
858860
let tx_id = provider.send_transaction(tx).await?;
859861
tx_ids.push(tx_id);
860862
}
@@ -868,7 +870,10 @@ async fn test_caching() -> Result<()> {
868870
}
869871

870872
// Verify the transfers were successful
871-
assert_eq!(wallet_2.get_asset_balance(&AssetId::zeroed()).await?, 1000);
873+
assert_eq!(
874+
wallet_2.get_asset_balance(&AssetId::zeroed()).await?,
875+
num_iterations * amount_to_send
876+
);
872877

873878
Ok(())
874879
}

0 commit comments

Comments
 (0)