Skip to main content
Unit tests (Rust): All of the vault’s rules live in src/logic.rs, which never calls the host, so cargo test runs them natively — no node, no WASM. The host calls in lib.rs only run on wasm32; the end-to-end check is the store → grant → check flow on the previous page. From the agent-vault-starter folder:
A few of the tests in tests/logic.rs:
at(y, m, d) turns a date into cluster seconds, so time-dependent rules are tested on exact boundaries instead of whatever today is. Test checklist:
  • Happy path: store the example customer, then check with examples/rules.json returns true for every rule.
  • No values out: check answers, error messages and log lines never contain a field value — including validation errors on store, which name the field only.
  • Boundaries: age turns on the birthday, an ID is valid on its expiry date and not the day after, account tenure counts whole months.
  • Caller rules: store and forget refuse a delegated call; check reads only the calling customer’s record, never a DID from the input.
  • Input hygiene: unknown fields in the record or the rules are rejected, an empty rules object is rejected, and the flag rules accept only true.
  • Grant boundary (on testnet): an agent granted only check is refused on store.