Skip to content

docs: add the engine-side test-utils harness page#342

Closed
lgahdl wants to merge 2 commits into
nullislabs:developfrom
bleu:docs/279-test-utils-page
Closed

docs: add the engine-side test-utils harness page#342
lgahdl wants to merge 2 commits into
nullislabs:developfrom
bleu:docs/279-test-utils-page

Conversation

@lgahdl

@lgahdl lgahdl commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

What

Closes #279 — adds docs/testing-runtime-harness.md describing crates/nexum-runtime's test-utils feature (MockChainProvider, MockStateStore, MockTypes, mock_components, TestRuntime/TestRuntimeBuilder), which had no prose documentation anywhere in the repo.

Verification before writing

  • Grepped every doc file for MockChainProvider, TestRuntime, mock_components — zero hits. Confirmed the gap is real.
  • The issue also claims a "one-sentence aside" already exists in docs/05-sdk-design.md. Checked: that's stale too — that doc only discusses the guest-side nexum-sdk-test/shepherd-sdk-test mocks (a different surface for testing module business logic), never the engine-side harness this page is about.
  • Read the actual source (test_utils/mod.rs, test_utils/harness.rs, test_utils/chain.rs, the crate's Cargo.toml feature/dev-dependency block) to write the API description and feature-gate quote, rather than paraphrasing the issue.

The worked example is a real, run test

Rather than write illustrative pseudocode, I built the worked example as a standalone #[tokio::test] against the actual crate, ran it, and only copied it into the doc after it passed. That caught a real bug before it shipped: Header::default() needs an explicit let mut header: Header = ... type annotation (the type param can't be inferred without it, since Header is generic) — I'd dropped it while writing the first draft. Would have been a broken doc example otherwise.

Structure

Leads with the guardrail the issue specifies (module logic → MockHost, no wasm; engine/host/boundary correctness → this harness, real wasm component) since that's the load-bearing part per the issue. Documents the feature gate + self dev-dependency pattern, the two API layers (bare mocks vs TestRuntime), the worked example, then pointers to chain-log injection / chain-request programming / error-and-stream-end injection / store assertions / the manual clock — and a closing section redirecting a module-logic reader to the right page.

Linked from docs/00-overview.md's SDK section with one sentence distinguishing the two mock surfaces at the exact spot a reader would otherwise conflate them, per the issue's explicit ask.

Testing

Docs-only change to the repo, but the code sample was compiled and run for real (see above) before being copied into the page. cargo test -p nexum-runtime test_utils:: — 18 passed, unaffected.

Closes nullislabs#279. crates/nexum-runtime's test-utils feature (MockChainProvider,
MockStateStore, MockTypes, mock_components, TestRuntime) had no prose
docs anywhere - grepped every doc for MockChainProvider/TestRuntime/
mock_components and found zero hits. The issue's claim of an existing
"one-sentence aside" in docs/05-sdk-design.md is also stale: that doc
only discusses the guest-side nexum-sdk-test/shepherd-sdk-test mocks,
a different surface entirely.

New page leads with the guardrail the issue specifies: module business
logic tests against MockHost in plain Rust (no wasm), the engine
harness reserved for engine/host/boundary correctness (needs a real
compiled component). Documents the test-utils feature gate + self
dev-dependency pattern (quoted verbatim from Cargo.toml), the two API
layers (bare mocks vs TestRuntime), and a worked example covering block
injection, wait_for_log, chain-request programming, error/stream-end
injection, store assertions, and the manual clock.

The worked example is not illustrative pseudocode: built it as a real
standalone #[tokio::test] against the actual crate and ran it (caught
and fixed a missing type annotation on Header::default() in the
process - the same bug would have shipped in the doc otherwise) before
copying it into the page. Linked from docs/00-overview.md's SDK
section, with a sentence distinguishing the two mock surfaces at the
exact spot a reader would otherwise conflate them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TfSsJPYDQ1GQGbnSVFxATx
@lgahdl lgahdl requested a review from mfw78 as a code owner July 14, 2026 20:15
…s harness page

Self-review: the "beyond the happy path" bullets present
ChainMethod::EthCall and push_block_err(err) as literal code, unlike
the main worked example (which is a complete, verified-compiling
block with its own use lines). Verified both types are public
(nexum_runtime::host::component::ChainMethod,
nexum_runtime::host::provider_pool::ProviderError) and added the
import path inline so a reader copy-pasting the fragment doesn't hit
an unresolved-name error and have to go hunting.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TfSsJPYDQ1GQGbnSVFxATx
@mfw78 mfw78 added the base: develop Open PR targets develop — merge FIRST, before the dev/m1 integration PRs. label Jul 15, 2026
@mfw78

mfw78 commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Superseded by #348 — same change rebased onto develop, Claude co-author trailers + the body footer stripped, authorship preserved (@lgahdl). Closing in favour of #348.

@mfw78 mfw78 closed this Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

base: develop Open PR targets develop — merge FIRST, before the dev/m1 integration PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: page for the runtime test-utils / mock backends surface

2 participants