Skip to content

Commit

Permalink
rearrange test components
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed May 27, 2024
1 parent 3227ba8 commit e8081cd
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
5 changes: 2 additions & 3 deletions crates/hyperdrive-math/src/long/max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,9 @@ mod tests {
}) {
Ok(p) => match p {
Ok(p) => p,
Err(_) => continue,
Err(_) => continue, // Err; the amount results in the pool being insolvent.
},
// If the amount results in the pool being insolvent, skip this iteration.
Err(_) => continue,
Err(_) => continue, // panic; likely in FixedPoint
};

let p2 = match panic::catch_unwind(|| {
Expand Down
12 changes: 6 additions & 6 deletions crates/hyperdrive-math/src/short/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,9 @@ mod tests {
}) {
Ok(max_bond_amount) => match max_bond_amount {
Ok(max_bond_amount) => max_bond_amount,
Err(_) => continue,
Err(_) => continue, // Err; max short insolvent
},
Err(_) => continue,
Err(_) => continue, // panic; likely in FixedPoint
};
if max_bond_amount == fixed!(0) {
continue;
Expand Down Expand Up @@ -730,6 +730,10 @@ mod tests {
alice.fund(contribution).await?;
bob.fund(budget).await?;

// Alice initializes the pool.
// TODO: We'd like to set a random position duration & checkpoint duration.
alice.initialize(fixed_rate, contribution, None).await?;

// Set a random variable rate.
let variable_rate = rng.gen_range(fixed!(0.01e18)..=fixed!(1e18));
let vault = MockERC4626::new(
Expand All @@ -738,10 +742,6 @@ mod tests {
);
vault.set_rate(variable_rate.into()).send().await?;

// Alice initializes the pool.
// TODO: We'd like to set a random position duration & checkpoint duration.
alice.initialize(fixed_rate, contribution, None).await?;

// Bob opens a short with a random bond amount. Before opening the
// short, we calculate the implied rate.
let bond_amount = rng.gen_range(
Expand Down
7 changes: 3 additions & 4 deletions crates/hyperdrive-math/src/test_utils/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ pub trait HyperdriveMathAgent {
impl HyperdriveMathAgent for Agent<ChainClient<LocalWallet>, ChaCha8Rng> {
/// Gets the current state of the pool.
async fn get_state(&self) -> Result<State> {
Ok(State::new(
self.get_config().clone(),
self.hyperdrive().get_pool_info().await?,
))
let pool_config = self.get_config().clone();
let pool_info = self.hyperdrive().get_pool_info().await?;
Ok(State::new(pool_config, pool_info))
}

/// Gets the latest checkpoint.
Expand Down
4 changes: 2 additions & 2 deletions crates/hyperdrive-math/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ mod tests {
}) {
Ok(max_short) => match max_short {
Ok(max_short) => max_short,
Err(_) => continue, // Max threw an Err. Don't finish this fuzz iteration.
Err(_) => continue, // Max threw an Err; don't finish this fuzz iteration.
},
Err(_) => continue, // Max threw a paanic. Don't finish this fuzz iteration.
Err(_) => continue, // Max threw a panic; don't finish this fuzz iteration.
};
let max_rate = state.calculate_spot_rate_after_short(max_short, None)?;

Expand Down
4 changes: 2 additions & 2 deletions crates/hyperdrive-test-utils/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ lazy_static! {
// The amount of fuzz runs that Hyperdrive fuzz tests will use. This is only
// used by end-to-end fuzz tests that spin up all of the Hyperdrive machinery
// since lower-level fuzz tests have less constraints.
pub static ref FUZZ_RUNS: u64 = env::var("HYPERDRIVE_FUZZ_RUNS").ok().map(|s| s.parse().unwrap()).unwrap_or(100);
pub static ref FUZZ_RUNS: u64 = env::var("HYPERDRIVE_FUZZ_RUNS").ok().map(|s| s.parse().unwrap()).unwrap_or(1_000);

// The amount of fuzz runs that fast fuzz tests use.
pub static ref FAST_FUZZ_RUNS: u64 = env::var("HYPERDRIVE_FAST_FUZZ_RUNS").ok().map(|s| s.parse().unwrap()).unwrap_or(10_000);
pub static ref FAST_FUZZ_RUNS: u64 = env::var("HYPERDRIVE_FAST_FUZZ_RUNS").ok().map(|s| s.parse().unwrap()).unwrap_or(50_000);
}

0 comments on commit e8081cd

Please sign in to comment.