Skip to content

refactor(tests): establish Sweettest scaffold (#61)#64

Merged
Soushi888 merged 9 commits into
devfrom
refactor/sweettest-migration
Mar 26, 2026
Merged

refactor(tests): establish Sweettest scaffold (#61)#64
Soushi888 merged 9 commits into
devfrom
refactor/sweettest-migration

Conversation

@Soushi888

@Soushi888 Soushi888 commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator

Intent

Tryorama (@holochain/tryorama) is officially unmaintained for Holochain 0.7+. We are on the last supported pair (HDK 0.6.0 / Tryorama 0.19.0). This PR establishes the Sweettest scaffold — the workspace config, build tooling, and conductor infrastructure — that unblocks the 0.7 upgrade path.

Per-zome tests are not included here. The NDO refactor (ndo_prima_materia.md §10) will touch every zome API. Writing tests against the current API now means rewriting them immediately after. Instead, each NDO implementation PR will co-evolve its own Sweettest tests alongside the API it introduces.

Changes

New test crate at dnas/nondominium/tests/:

  • Cargo.tomlnondominium_sweettest crate with [[test]] target for misc
  • src/common/conductors.rs — framework-level conductor helpers: setup_two_agents(), setup_three_agents(), setup_dual_dna_two_agents(); API-independent, survives any zome refactor
  • src/misc/mod.rsping test: calls misc::ping and asserts "Pong"; validates the full build chain end-to-end

Workspace changes:

  • Cargo.toml — add nondominium_sweettest workspace member + default-members to exclude the native crate from WASM builds + holochain = "=0.6.0" with test_utils feature + tokio workspace dep (trimmed to rt-multi-thread, time, macros)
  • flake.nix — add llvmPackages_19.libclang, cmake, pkg-config; export LIBCLANG_PATH and BINDGEN_EXTRA_CLANG_ARGS (required for datachannel-sys bindgen step)
  • package.json — add sweettest / sweettest:verbose / sweettest:only scripts

TypeScript Tryorama tests remain unchanged and are the active test suite during the transition.

Post-review improvements:

  • conductors.rs: expanded HREA_DNA_PATH doc comment to document runtime-panic semantics and submodule prerequisites
  • Cargo.toml: added maintenance note warning that members globs do not carry through to default-members; new zomes must be listed in both places

Decisions

Option Rejected because
Port all 20 TypeScript test files now NDO refactor (ndo_prima_materia.md §10) will invalidate every API-coupled test immediately; writing them twice is pure waste
Per-zome test crates Tests frequently cross all 3 zomes; single crate compiles holochain once
Import coordinator crates HDK depends on WASM-only getrandom_backend — not host-compilable
Updating holonix flake inputs llvmPackages_19 is already in nixpkgs; no flake update needed

CARGO_TARGET_DIR=target/native-tests isolates the native Sweettest build from the wasm32-unknown-unknown artifacts that bun run build:zomes produces.

How to test

nix develop
bun run build:happ       # prerequisite: builds nondominium.dna bundle
bun run sweettest        # cargo test -p nondominium_sweettest

Expected output: 1 test (misc::ping) passing.

To verify the crate compiles without running tests:

CARGO_TARGET_DIR=target/native-tests cargo check -p nondominium_sweettest --tests
# Expected: 0 errors, 0 warnings

Documentation

Updated documentation/Testing_Infrastructure.md: added Sweettest scaffold section (location, commands, environment requirements, co-evolution strategy).

Updated documentation/TEST_COMMANDS.md: added Sweettest commands, updated Tryorama section status.

Related

Closes #61

@Soushi888 Soushi888 changed the title refactor(tests): migrate Tryorama to Rust Sweettest (#61) refactor(tests): establish Sweettest scaffold (#61) Mar 25, 2026
Adds nondominium_sweettest crate at dnas/nondominium/tests/ with a
complete port of all 20 TypeScript test files to Rust Sweettest.

Sweettest runs in-process (no WebSocket round-trip) and directly uses
Holochain types, eliminating the msgpack decode layer. Uses the
Holochain team's recommended test framework for Holochain 0.7+.

## Infrastructure

- Workspace Cargo.toml: add nondominium_sweettest member + holochain/
  tokio workspace deps with test_utils feature
- dnas/nondominium/tests/Cargo.toml: 4 [[test]] targets (misc, person,
  resource, governance)
- common/ module: conductors (setup_two/three/dual_dna_agents), fixtures
  (sample helpers + input structs), mirrors (coordinator output types),
  zome_calls (typed wrappers for all 3 zomes)
- flake.nix: add llvmPackages_19.libclang + cmake + pkg-config for
  datachannel-sys bindgen step; export LIBCLANG_PATH + BINDGEN_EXTRA_CLANG_ARGS
- package.json: add sweettest / sweettest:verbose / sweettest:only scripts

## Test modules (30 files, ~5500 lines of Rust)

Person: foundation (7), integration (7), hrea_bridge (3), device_foundation
(10), device_integration (4), device_multi (6), device_security (7),
capability_sharing (8), scenarios (4)

Resource: foundation (4), update (1), integration (7), scenarios (4)

Governance: foundation (1), ppr/{foundation (4), cryptography (5),
debug (4), integration (4), scenarios (4)}

Misc: ping (1)

## Status

All 4 test binaries compile with zero errors. TypeScript tests remain
intact during transition. Runtime test execution requires bun run build:happ
first to generate the .dna bundle files.

Error-path tests that require catching zome panics are marked #[ignore]
with explicit reasons. hREA bridge test uses integrity crate types for
entry decoding (PersonMirror -> zome_person_integrity::Person).

Closes #61
…bers

The test crate has native-only deps (holochain, tokio, mio) that cannot
compile to wasm32-unknown-unknown. Adding default-members ensures that
`cargo build --target wasm32-unknown-unknown` only builds the zome crates.
…ol conflict

Linking zome_person_integrity, zome_resource_integrity, and
zome_gouvernance_integrity into one native test binary causes linker errors:
  multiple definition of '__num_entry_types'
  multiple definition of '__num_link_types'

These C-level symbols are generated by #[hdk_entry_types]/#[hdk_link_types]
macros in each integrity crate, and collide when all three are linked together.

Fix: remove all three integrity crate deps. Replace every integrity type
reference in the test crate with local mirror structs/enums using serde:
- ResourceState, DeviceStatus, ParticipationClaimType local enums
- VfAction as String (e.g. "Transfer")
- Commitment/EconomicEvent/Claim as serde_json::Value
- PersonMirror/ReaAgentMirror get holochain_serialized_bytes::SerializedBytes
  derive so to_app_option() still works for entry decoding
Remove API-coupled test files (fixtures, mirrors, zome_calls, and all
per-zome test modules). The current tests mirror the pre-NDO API which
will be torn up in the NDO refactor (ndo_prima_materia.md §10).

Keep:
- Workspace config (Cargo.toml, flake.nix, package.json, test crate Cargo.toml)
- common/conductors.rs — framework-level, API-independent
- misc/mod.rs — ping test, validates the full build chain end-to-end

Per-zome tests (person/, resource/, governance/) will be co-evolved
alongside each NDO refactor implementation PR so tests never become
stale by design.
@Soushi888 Soushi888 force-pushed the refactor/sweettest-migration branch from 603c35d to d918c01 Compare March 25, 2026 21:01
@Soushi888 Soushi888 marked this pull request as ready for review March 25, 2026 21:24
- Cargo.toml: replace tokio features = ["full"] with the three features
  actually needed by sweettest (rt-multi-thread, time, macros)
- conductors.rs: expand HREA_DNA_PATH doc comment — clarifies it is only
  used by setup_dual_dna_two_agents(), requires hREA submodule initialized
  and built, and panics at runtime (not compile time) if the .dna is absent
Document that workspace members globs do not carry through to default-members.
New zomes added via glob must be listed in default-members explicitly to
preserve WASM build isolation.
@Soushi888 Soushi888 merged commit 3b4d0d0 into dev Mar 26, 2026
1 check passed
@Soushi888 Soushi888 deleted the refactor/sweettest-migration branch March 26, 2026 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(tests): migrate from Tryorama to Sweettest

1 participant