Skip to content

Commit

Permalink
Again increase the amount of blocks we mine prior to running tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Jul 7, 2024
1 parent 4743ea7 commit d99ed96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions coins/monero/wallet/src/decoys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ async fn select_decoys<R: RngCore + CryptoRng>(
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)]
Expand All @@ -181,10 +181,12 @@ async fn select_decoys<R: RngCore + CryptoRng>(

// 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
Expand Down
8 changes: 5 additions & 3 deletions coins/monero/wallet/tests/runner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ pub async fn rpc() -> SimpleRequestRpc {
let rpc =
SimpleRequestRpc::new("http://serai:[email protected]: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;
}

Expand All @@ -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
}
Expand Down

0 comments on commit d99ed96

Please sign in to comment.