From d99ed9698ea73b93778e4919d4e3e336800cc2a8 Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sat, 6 Jul 2024 20:50:46 -0400 Subject: [PATCH] Again increase the amount of blocks we mine prior to running tests --- coins/monero/wallet/src/decoys.rs | 6 ++++-- coins/monero/wallet/tests/runner/mod.rs | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/coins/monero/wallet/src/decoys.rs b/coins/monero/wallet/src/decoys.rs index de16c433e..00b771bcd 100644 --- a/coins/monero/wallet/src/decoys.rs +++ b/coins/monero/wallet/src/decoys.rs @@ -163,7 +163,7 @@ async fn select_decoys( distribution.truncate(height); if distribution.len() < DEFAULT_LOCK_WINDOW { - Err(RpcError::InternalError("not enough decoy candidates".to_string()))?; + Err(RpcError::InternalError("not enough blocks to select decoys".to_string()))?; } #[allow(clippy::cast_precision_loss)] @@ -181,10 +181,12 @@ async fn select_decoys( // TODO: Create a TX with less than the target amount, as allowed by the protocol let high = distribution[distribution.len() - DEFAULT_LOCK_WINDOW]; + // This assumes that each miner TX had one output (as sane) and checks we have sufficient + // outputs even when excluding them (due to their own timelock requirements) if high.saturating_sub(u64::try_from(COINBASE_LOCK_WINDOW).unwrap()) < u64::try_from(inputs.len() * ring_len).unwrap() { - Err(RpcError::InternalError("not enough coinbase candidates".to_string()))?; + Err(RpcError::InternalError("not enough decoy candidates".to_string()))?; } // Select all decoys for this transaction, assuming we generate a sane transaction diff --git a/coins/monero/wallet/tests/runner/mod.rs b/coins/monero/wallet/tests/runner/mod.rs index ba59beccc..623d2602f 100644 --- a/coins/monero/wallet/tests/runner/mod.rs +++ b/coins/monero/wallet/tests/runner/mod.rs @@ -125,8 +125,10 @@ pub async fn rpc() -> SimpleRequestRpc { let rpc = SimpleRequestRpc::new("http://serai:seraidex@127.0.0.1:18081".to_string()).await.unwrap(); + const BLOCKS_TO_MINE: usize = 200; + // Only run once - if rpc.get_height().await.unwrap() < 120 { + if rpc.get_height().await.unwrap() < BLOCKS_TO_MINE { return rpc; } @@ -137,8 +139,8 @@ pub async fn rpc() -> SimpleRequestRpc { &Scalar::random(&mut OsRng) * ED25519_BASEPOINT_TABLE, ); - // Mine 100 blocks to ensure decoy availability - rpc.generate_blocks(&addr, 120).await.unwrap(); + // Mine enough blocks to ensure decoy availability + rpc.generate_blocks(&addr, BLOCKS_TO_MINE).await.unwrap(); rpc }