Skip to content

Commit

Permalink
fix(papyrus_test_utils): generate random values for resource bounds t…
Browse files Browse the repository at this point in the history
…est instance
  • Loading branch information
AlonLStarkWare committed Feb 9, 2025
1 parent fdf4886 commit c44e6a1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/papyrus_test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,6 @@ auto_impl_get_test_instance! {
L1Gas = 0,
L2Gas = 1,
}
pub struct ResourceBounds {
pub max_amount: GasAmount,
pub max_price_per_unit: GasPrice,
}
pub struct InternalRpcTransaction {
pub tx: InternalRpcTransactionWithoutTxHash,
pub tx_hash: TransactionHash,
Expand Down Expand Up @@ -1195,3 +1191,14 @@ impl GetTestInstance for NonZeroU64 {
max(1, rng.next_u64()).try_into().expect("Failed to convert a non-zero u64 to NonZeroU64")
}
}

impl GetTestInstance for ResourceBounds {
// The default value is invalid in some cases, so we need to override it.
fn get_test_instance(rng: &mut ChaCha8Rng) -> Self {
Self {
max_amount: GasAmount(rng.next_u64()),
// TODO(alonl): change GasPrice generation to use u128 directly
max_price_per_unit: GasPrice(rng.next_u64().into()),
}
}
}

0 comments on commit c44e6a1

Please sign in to comment.