sails-gtest
Sails Gtest
Goal
Run the Sails-first test loop with generated clients and explicit gtest evidence before any live-node smoke step.
Inputs
../../assets/gtest-report-template.md— report format for gtest results../../references/gtest-cheatsheet.md— quick reference for gtest APIs../../references/gtest-patterns.md— common test patterns../../references/sails-cheatsheet.md— Sails patterns and APIs../../references/sails-gtest-and-local-validation.md— full gtest and validation guide../../references/gear-gas-reservations-and-waitlist.md— gas reasoning for tests../../references/scale-binary-decoding-guide.md— decoding raw reply bytes
Write the result to docs/plans/YYYY-MM-DD-<topic>-gtest.md.
Expected Loop
- Confirm the implementation target is ready for verification.
- Use generated clients or
GtestEnvinstead of hand-built payloads where the workspace supports them. - If the test must go below generated clients, first decide whether the payload or reply bytes are Sails-routed, plain SCALE, or metadata-driven state output; then apply the raw mental model:
send_bytes*returns aMessageId,run_next_blockreturns theBlockRunResult, and the reply evidence lives in the block result. - Pick the right
BlockRunModeand advance blocks explicitly when replies or deferred effects depend on progression. - Use
run_to_blockwhen delayed work or timeout behavior spans multiple blocks. - Assert behavior, replies, events, or accounting in the test result, not just compilation.
- Record failure mode, fix, and passing command output in the gtest note.
- Route to
../sails-local-smoke/SKILL.mdonly after the suite is green.
Common Pitfalls
-
Rust 2024 listener lifetime: Under edition 2024 capture rules, chained calls like
program.service().listener().listen().awaitfail with "temporary value dropped while borrowed". Bind each intermediate to a longer-lived variable:let mut service = program.service_name(); let mut listener = service.listener(); let event = listener.listen().await.unwrap(); -
Program balance accounting in gtest: The deployed program account has an existential deposit. Absolute balance assertions like
== wageror== 0will fail even when the contract accounting logic is correct. Capture the initial balance after deploy and assert deltas relative to that baseline:let initial_balance = env.balance_of(program_id); // ... perform actions ... let final_balance = env.balance_of(program_id); assert_eq!(final_balance - initial_balance, expected_delta); -
Missing block advancement: Forgetting to call
run_next_blockafter sending a message means the reply is never processed. Always advance at least one block after send operations that expect replies.
Guardrails
- Do not use green
cargo testoutput without Sails-appropriate assertions as proof. - Do not start local-node smoke while
gtestis still red. - Do not skip gas or value reasoning when tests depend on it.
- Do not decode raw reply or event bytes as a bare business DTO until you have checked whether Sails routing framing is present.
More from gear-foundation/vara-skills
vara-skills
Use when a builder needs the top-level router for the provisional standard Gear/Vara Sails skill pack across Codex, Claude, or OpenClaw. Do not use for Vara.eth or ethexe work, non-Sails programs, or broad protocol research.
197sails-new-app
Use when a builder is starting a new standard Gear/Vara Sails app and needs the correct greenfield sequence before implementation. Do not use for edits to an established repo, Vara.eth or ethexe targets, or non-Sails templates.
2sails-dev-env
Use when a builder needs to prepare or repair a local macOS, Linux, or Windows machine for standard Gear/Vara Sails Rust development before building, testing, or running a local node. Do not use for live-network deployment, app-specific feature work, or Vara.eth/ethexe-only setup.
2vara-wallet
Use when an agent needs to interact with Vara Network on-chain — deploy programs, call Sails methods, manage wallets, transfer tokens, monitor events. Not for building Sails programs (use vara-skills for that).
2task-decomposer
Use when approved spec and architecture artifacts must become an ordered implementation plan for Gear or Vara work. Do not use when the architecture is still unsettled or when the request is only asking for a high-level idea.
2sails-frontend
Use when a builder needs to build or extend a React or TypeScript frontend for a standard Gear/Vara Sails app, using Sails-JS, generated clients, React hooks, and low-level Gear-JS only where it adds value. Do not use for Rust-only contract work, raw gstd service design, or non-Vara frontends.
2