Summary
The MockEnvBuilder accepts a wide range of inputs (sequence numbers, timestamps, balances) that could produce edge-case panics. Property-based testing with arbitrary would catch these before users encounter them.
Scope
Test the following properties:
- Sequence/Timestamp monotonicity —
at_sequence(u32::MAX) should not panic
- Account balance overflow — very large
Stroops values are handled gracefully
- Duplicate account names — second
.with_account("alice", ...) either overwrites or errors predictably
- Empty symbol string —
.with_token("", 6) fails with a clear message
Implementation
Add to contracts/crucible/src/tests.rs or a new contracts/crucible/tests/property.rs:
use arbitrary::Arbitrary;
#[derive(Arbitrary, Debug)]
struct EnvConfig {
sequence: u32,
timestamp: u64,
accounts: Vec<(String, u64)>,
}
fn roundtrip(config: EnvConfig) {
// should never panic, regardless of inputs
let _ = MockEnv::builder()
.at_sequence(config.sequence)
.at_timestamp(config.timestamp)
.build();
}
Acceptance Criteria
Summary
The
MockEnvBuilderaccepts a wide range of inputs (sequence numbers, timestamps, balances) that could produce edge-case panics. Property-based testing witharbitrarywould catch these before users encounter them.Scope
Test the following properties:
at_sequence(u32::MAX)should not panicStroopsvalues are handled gracefully.with_account("alice", ...)either overwrites or errors predictably.with_token("", 6)fails with a clear messageImplementation
Add to
contracts/crucible/src/tests.rsor a newcontracts/crucible/tests/property.rs:Acceptance Criteria
arbitraryadded as dev-dependencycargo test