Again increase the amount of blocks we mine prior to running tests

This commit is contained in:
Luke Parker
2024-07-06 20:50:46 -04:00
parent 4743ea732c
commit d99ed9698e
2 changed files with 9 additions and 5 deletions

View File

@@ -163,7 +163,7 @@ async fn select_decoys<R: RngCore + CryptoRng>(
distribution.truncate(height); distribution.truncate(height);
if distribution.len() < DEFAULT_LOCK_WINDOW { 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)] #[allow(clippy::cast_precision_loss)]
@@ -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 // TODO: Create a TX with less than the target amount, as allowed by the protocol
let high = distribution[distribution.len() - DEFAULT_LOCK_WINDOW]; 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()) < if high.saturating_sub(u64::try_from(COINBASE_LOCK_WINDOW).unwrap()) <
u64::try_from(inputs.len() * ring_len).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 // Select all decoys for this transaction, assuming we generate a sane transaction

View File

@@ -125,8 +125,10 @@ pub async fn rpc() -> SimpleRequestRpc {
let rpc = let rpc =
SimpleRequestRpc::new("http://serai:seraidex@127.0.0.1:18081".to_string()).await.unwrap(); SimpleRequestRpc::new("http://serai:seraidex@127.0.0.1:18081".to_string()).await.unwrap();
const BLOCKS_TO_MINE: usize = 200;
// Only run once // Only run once
if rpc.get_height().await.unwrap() < 120 { if rpc.get_height().await.unwrap() < BLOCKS_TO_MINE {
return rpc; return rpc;
} }
@@ -137,8 +139,8 @@ pub async fn rpc() -> SimpleRequestRpc {
&Scalar::random(&mut OsRng) * ED25519_BASEPOINT_TABLE, &Scalar::random(&mut OsRng) * ED25519_BASEPOINT_TABLE,
); );
// Mine 100 blocks to ensure decoy availability // Mine enough blocks to ensure decoy availability
rpc.generate_blocks(&addr, 120).await.unwrap(); rpc.generate_blocks(&addr, BLOCKS_TO_MINE).await.unwrap();
rpc rpc
} }