Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(papyrus_test_utils): generate random values for resource bounds test instance #4036

Merged
merged 1 commit into from
Feb 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()),
}
}
}
Loading