Docs Técnicas
Testing Contracts
Recommended test layers:
O conteúdo abaixo vem das fontes técnicas do repositório e é prerenderizado no site para leitura direta por pessoas, crawlers e agentes.
Recommended test layers:
- parse and verify source;
- compile and inspect artifact hashes;
- execute locally with
ContractInstance; - assert storage snapshots and effects;
- run ledger integration tests for posting policy.
Local Runtime Test
rust
let module = parse_contract(source)?;
verify_contract(&module)?;
let mut instance = ContractInstance::new(module)?;
let output = instance.execute("entrypoint", args, ctx)?;
assert!(output.cost.total_units > 0);Use local runtime tests to prove:
- guard behavior;
- storage transitions;
- event emission;
- effect shape.
Ledger Test
Use ledger tests when a contract emits post(...), because AllowedEdge policy is enforced at ledger commit.
Use ledger tests to prove:
- posting route admissibility;
- lifecycle gating;
- accepted version resolution;
- artifact publication and instance binding behavior.
Coverage Rule
A passing local runtime test does not prove that ledger commit will succeed.
If a contract produces accounting effects, add at least one ledger integration test for the same flow.
Fixture Location
Current fixtures live at:
text
crates/domain/atlas-trea/tests/fixtures/