You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current suite tests individual functions with fixed inputs. It does not assert that the core accounting invariants hold across arbitrary sequences of operations — and those invariants are exactly what keeps user funds safe. A regression in any of them is a fund-loss bug that fixed-input tests can easily miss.
The invariants that must hold after every operation, for every user/asset:
0 <= locked <= balance
balance >= 0
On finalize, locked decreases by exactly the task's plan_cost and balance decreases by exactly spent, where 0 <= spent <= plan_cost.
A new test module that drives multi-step operation sequences against a single vault and asserts invariants 1–4 after each step.
Requirements & constraints
Deterministic and reproducible. Use a seeded generator (a small hand-rolled LCG over a fixed op vocabulary is enough and keeps the crate #![no_std]/dependency-free). If you prefer proptest, gate it strictly behind #[cfg(test)] dev-dependencies and keep CI green.
Coverage of the op vocabulary:deposit, withdraw, create_task, release_payment, complete_task, cancel_task, force_complete_stale_task (advance ledger time via env.ledger() to trigger staleness).
Sequences should include multiple users and at least two assets so cross-account/cross-asset isolation is exercised.
On any invariant violation, the failure message must print the seed and the step index so it's reproducible.
Acceptance criteria
New seeded, deterministic test module drives randomized multi-step sequences
Invariants 1–4 asserted after every operation
At least one sequence exercises partial releases followed by completion and checks the refund math (invariant 3)
Generator covers the full op vocabulary above, with ≥2 users and ≥2 assets
Failures report the seed + step index
No production (lib.rs) changes are required
cargo test and cargo clippy --all-targets -- -D warnings pass
Pointers
Add to contracts/agent-vault/src/tests.rs; reuse the existing setup_test() harness and token-minting helpers.
Notes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.
The current suite tests individual functions with fixed inputs. It does not assert that the core accounting invariants hold across arbitrary sequences of operations — and those invariants are exactly what keeps user funds safe. A regression in any of them is a fund-loss bug that fixed-input tests can easily miss.
The invariants that must hold after every operation, for every user/asset:
0 <= locked <= balancebalance >= 0lockeddecreases by exactly the task'splan_costandbalancedecreases by exactlyspent, where0 <= spent <= plan_cost.total_spentis monotonically non-decreasing.sum(get_balance over users)for an asset never exceeds the vault's realtoken_balancefor that asset (only assertable once issue feat: Add update_orchestrator function to allow users to rotate their… #34's reconciliation view lands — treat as optional/stretch here).Goal
A new test module that drives multi-step operation sequences against a single vault and asserts invariants 1–4 after each step.
Requirements & constraints
#![no_std]/dependency-free). If you preferproptest, gate it strictly behind#[cfg(test)]dev-dependencies and keep CI green.deposit,withdraw,create_task,release_payment,complete_task,cancel_task,force_complete_stale_task(advance ledger time viaenv.ledger()to trigger staleness).Acceptance criteria
lib.rs) changes are requiredcargo testandcargo clippy --all-targets -- -D warningspassPointers
contracts/agent-vault/src/tests.rs; reuse the existingsetup_test()harness and token-minting helpers.Notes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.