Skip to content

Commit

Permalink
Use prop_filter to ensure that random transactions are generated with…
Browse files Browse the repository at this point in the history
… valid fees.
  • Loading branch information
murisi committed Jan 6, 2025
1 parent deeeb9e commit 3cdb77d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,8 @@ pub mod testing {
}

prop_compose! {
/// Generate an arbitrary wrapper transaction
pub fn arb_wrapper_tx()(
/// Generate an arbitrary wrapper transaction. Do not check fee validity
pub fn arb_unchecked_wrapper_tx()(
fee in arb_fee(),
pk in arb_common_pk(),
gas_limit in arb_gas_limit(),
Expand All @@ -1051,6 +1051,18 @@ pub mod testing {
}
}

prop_compose! {
/// Generate an arbitrary wrapper transaction with valid fees
pub fn arb_wrapper_tx()(
wrapper in arb_unchecked_wrapper_tx().prop_filter(
"wrapper fees overflow",
|x| x.get_tx_fee().is_ok(),
),
) -> WrapperTx {
wrapper
}
}

prop_compose! {
/// Generate an arbitrary transaction type
pub fn arb_tx_type()(tx_type in prop_oneof![
Expand Down

0 comments on commit 3cdb77d

Please sign in to comment.