Keyboard shortcuts

Press โ† or โ†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

soroban-testkit-generators

Soroban-aware property-testing strategies for proptest and arbitrary, so generated inputs respect the ranges real contracts accept.

Packagesoroban-testkit-generators
Featuresproptest (default) ยท arbitrary
Modulestrategies

Available strategies

StrategyTypeRange
token_amount()i1280 to 1e15
ledger_sequence()u321 to 10,000,000
timestamp()u64Sep 2020 to May 2033

Usage with proptest

#![allow(unused)]
fn main() {
use proptest::prelude::*;
use soroban_testkit_generators::strategies;

proptest! {
    #[test]
    fn transfer_preserves_total_supply(
        amount in strategies::token_amount(),
        seq in strategies::ledger_sequence(),
    ) {
        // amount is always a valid token balance
        // seq is always a realistic ledger sequence number
    }
}
}

Custom strategies

Compose the built-ins with proptest combinators:

#![allow(unused)]
fn main() {
use proptest::prelude::*;
use soroban_testkit_generators::strategies;

fn transfer_args() -> impl Strategy<Value = (i128, i128)> {
    (strategies::token_amount(), strategies::token_amount())
        .prop_filter("sender must have sufficient balance", |(a, b)| a >= b)
}
}
Keep cases bounded

Soroban tests run on the host and pay for every instruction. Start proptest! cases at the default 256, and shrink ranges before raising the count โ€” Property Testing covers the trade-offs.

Feature flags

Opt in per backend

Enable proptest, arbitrary, or both. Unused backends stay out of your dependency graph.

Good first issue

More strategies

Address, symbol and BytesN<32> generators are labelled Medium 150 pts on the issue tracker.