midnight-cq:ledger-testing

Create deterministic unit and integration tests for Midnight ledger interactions.

37|9|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/devrelaicom/midnight-expert --skill midnight-cq-ledger-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: midnight-cq:ledger-testing
Source: https://github.com/devrelaicom/midnight-expert/tree/main/plugins/midnight-cq/skills/ledger-testing
Command: npx skills add https://github.com/devrelaicom/midnight-expert --skill midnight-cq-ledger-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps developers write deterministic, comprehensive tests for code that interacts directly with the Midnight ledger libraries by removing flaky test patterns and enforcing correct lifecycle transitions, fixture validity, and time control.

Core Features & Use Cases

  • Proof staging validation: Verify transactions progress through unproven → proved → bound → proof-erased stages and assert stage-specific behaviors and type-enforced transitions.
  • Ledger state and time control: Test ZswapLocalState and DustLocalState immutability, mutation return values, replayEvents, TTL expiry behavior with fixed dates, and watchFor/clearPending semantics.
  • Crypto fixtures, cost model, and serialization: Use deterministic sample functions for hex-typed fixtures, assert deterministic coinCommitment and coinNullifier properties, validate cost model dimensions and fee calculations, perform encode/decode and serialize/deserialize round-trip checks. Use case: Build unit and integration tests that validate transaction construction, fee estimation, well-formedness rejection cases, and on-chain LedgerState.apply effects.

Quick Start

Create a deterministic test that builds an unproven transaction from an intent, advances it through prove and bind, asserts CostModel dimensions and well-formedness, and verifies serialize/deserialize at a fixed date.

Frequently Asked Questions about midnight-cq:ledger-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write deterministic ledger tests for Midnight SDK transactions?

Deterministic ledger tests for Midnight SDK are written by validating transaction construction, proof staging lifecycles, and serialization round-trips using @midnight-ntwrk/ledger-v8 and @midnight-ntwrk/onchain-runtime.

What is proof staging validation in Midnight onchain-runtime testing?

Proof staging validation verifies that transactions progress sequentially through unproven, proved, bound, and proof-erased stages. It asserts stage-specific behaviors and enforces type-enforced transitions within the onchain-runtime.

How do I test ZswapLocalState and DustLocalState behaviors in a ledger test?

Testing ZswapLocalState and DustLocalState involves asserting their immutability, verifying mutation return values, and testing replayEvents. You also validate TTL expiry behavior using fixed dates and watchFor or clearPending semantics.

Does the Midnight ledger CostModel support explicit fee estimation assertions?

Yes, the Midnight ledger CostModel supports explicit fee estimation assertions. You validate cost model dimensions and verify fee calculations to ensure transaction costs are accurately predicted during testing.

Can I use hex-typed fixtures for crypto function testing in ledger-v8?

Yes, you can use deterministic sample functions to generate valid hex-typed fixtures for ledger-v8. This allows you to assert deterministic coinCommitment and coinNullifier properties during crypto function testing.

Why do I need negative tests for ledger transaction well-formedness?

Negative tests for ledger transaction well-formedness are needed to verify that invalid structures are correctly rejected. They validate that the on-chain LedgerState.apply effects properly fail when processing malformed inputs.