Skip to content

testing: promote shared test helpers into the published test crates #497

Description

@mfw78

Follow-up from the end-of-train refactor analysis. Target: cross-repo (L1 nexum-runtime + L2 videre + L3 shepherd). Priority: medium.

Problem

Several test helpers are re-derived per site because downstream repos can only reach nexum helpers through the published test-utils feature and the nexum-sdk-test/videre-test tags, not through #[cfg(test)] items.

  1. videre-host reimplements the Supervisor boot ceremony (crates/videre-host/tests/platform.rs:324 calls Supervisor::boot_single; tests/zero_leak.rs:69 calls Supervisor::boot) because nexum-runtime's exported TestRuntime (crates/nexum-runtime/src/test_utils/harness.rs:145, :203) only surfaces logs/chain/store/clock and never exposes the booted Supervisor, which the venue tests need for services().get::<VenueRegistry>(), adapter_alive_count(), and dispatch_block().
  2. Manifest TOML is rebuilt ad hoc: harness.rs:322 (block_manifest), harness.rs:340 (chain_log_manifest), and platform.rs:303 (intent_status_manifest), differing only in the subscription stanza.
  3. AssetAmount/value-flow constructors are open-coded everywhere: platform.rs:239 (native), crates/videre-test/src/reference.rs:98 (minimal_be, the canonical trim-leading-zeros wire rule, locked private), crates/videre-sdk/tests/adapter.rs:70, crates/videre-test/tests/conformance.rs:35.
  4. Two different structs named RecordedRequest are re-exported side by side: the chain mock's (crates/nexum-runtime/src/test_utils/chain.rs:113) and videre-test's HTTP one (crates/videre-test/src/transport.rs:78, re-exported at src/lib.rs).

Change

  • Widen the exported harness so extension authors can drive a real boot: add TestRuntime::supervisor(&self) -> &Supervisor<E> (or a boot_supervisor constructor on TestRuntimeBuilder) so videre-host can drop its bespoke engine+linker+boot glue.
  • Add a typed manifest builder to test_utils, e.g. manifest(name).require([...]).subscribe_block(chain).subscribe_chain_log(chain).to_toml(), used by both the runtime harness tests and the videre platform tests.
  • Promote native(), erc20(token, amount), and minimal_be() into videre-test's public surface (the shared conformance crate, already consumed by cow-venue and echo-venue).
  • Rename videre-test's HTTP RecordedRequest to RecordedFetch to end the name collision.

Acceptance criteria

  • videre-host's two integration tests boot via the exported harness; Supervisor::boot/boot_single are no longer called directly in test code.
  • A single manifest builder replaces block_manifest/chain_log_manifest/intent_status_manifest and the stray inline literals.
  • native/erc20/minimal_be are public in videre-test; the inline AssetAmount constructions in the listed test sites use them.
  • Only one RecordedRequest type exists; the HTTP one is RecordedFetch.
  • All changes stay strict-up through the published crates.

Addendum: test-file hygiene + mock consolidation (from #447 review, 2026-07-21)

Beyond the shared helpers above, the integration test files carry AI-generated cruft to strip as part of this pass:

  • Decorative section dividers. crates/videre-host/tests/platform.rs uses box-drawing horizontal rules as section headers - // ── fixtures + assembly ──────, // ── world contract ──────, // ── intent-status subscription E2E ──────, // ── echo round trip ──────, // ── venue-adapter trap recovery ────── (5 in one 714-line file). These are decorative cruft against the terse house style; strip them (a plain lowercase comment or nothing suffices). Sweep the other test files for the same pattern while consolidating.
  • Duplicate scripted mock adapters. ScriptedAdapter (platform.rs, a status-script VenueAdapter) duplicates StubAdapter (the registry unit tests' with_status_script mock in videre-host/src/registry.rs). Consolidate into one shared scripted mock adapter in the test-support surface.

The locator / engine / linker / block / workspace_path scaffolding duplication (module_wasm_or_skip x4, make_wasmtime_engine x3, make_linker x3, fn block x5) is tracked in detail in #494 (exported nexum locator + a shared tests/common/mod.rs). Together #494 + #497 should leave the integration suites DRY and cruft-free; a house-style de-cruft sweep of the test files is in scope for whichever lands first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions