PocketIC host tools
Use the root runner's host suite for isolated current-code checks. For direct Node commands, install the committed dependency lock from the repository root:
npm ci --ignore-scripts --prefix tests/pocketic
Direct Wire-client tests also need the generated runtime. Use a current canonical build's host tool to prepare it first:
python3 cdk-rsx/tools/wire_runtime.py \
--wasm-tool /absolute/current-artifacts/app.wasm-tool \
--out-dir tests/pocketic/.generated
npm --prefix tests/pocketic test
CDK_RSX_WIRE_RUNTIME may instead select an absolute generated runtime module;
the root runner uses this option to keep concurrent runs separate. The adapter
never builds a missing runtime implicitly.
This package pins @dfinity/pic 0.16.1 and @icp-sdk/core 6.1.0 without
application dependencies. It owns PocketIC sessions, single-submission ticks,
artifact receipt verification, management resource queries, instruction profiles
and exact native memory-trace archives. Resource queries require the controller
principal explicitly. Sessions remove only their own instance and temporary
state; an explicitly selected server and its viewer remain owned by the caller.
RRT_PIC_SERVER_URL selects an existing server; RRT_PIC_STATE_DIR overrides
the temporary-state directory. Otherwise factory sessions use
tests/tmp/pocketic-state and callers may supply stateDirectory explicitly.
Keep the state root short because PocketIC creates Unix sockets beneath it.
Results can live in a separate, deeper directory. Instance creation failures
from a locally launched server report its state directory and recent stderr.
Sessions allow five minutes of host wall time per PocketIC operation by default.
This also bounds reads of an already accepted tick result; it never permits
resubmitting the mutation. Callers can supply processingTimeoutMs explicitly.
This deadline does not change simulated time, instruction budgets or work.
Await mutations one at a time when a runner shares one instance across
actors. The strict ticker submits each tick once and polls accepted work.
Use pic.tick() when the test only needs a scheduler round, and use a
positive pic.advanceTime(ms) when advancing a timer deadline. A tick can
advance time below the millisecond precision of the host clock wrapper.
SDK fixture runners live beside these helpers:
sdk-lifecycle.mjsroot-authoring-lifecycle.mjsmemory-limit-lifecycle.mjshylix-lifecycle.mjshylix-ownership.mjscandid-lifecycle.mjstransient-recovery.mjsengine-composition-lifecycle.mjsstore-directory-lifecycle.mjs
Their --source-root selects the newstack factory root, and --output must name
a fresh directory under factory tests/tmp. Supply --pocket-ic with
the qualified executable and the runner's declared fixture artifacts. The
canonical example entry point is bash tests/tools/run-examples.sh; see the
testing guide for fixture selection and limits.
store-directory-lifecycle.mjs uses the unchanged Shop fixture
to retire interior inventories in committed calls, KEEP with retired directory
entries, verify all survivor values and refill the 32-branch limit twice. It
checks public business keys and values; exact Store slots/generations remain
opaque and are covered by SDK native tests. Build a fresh matching-candidate
Shop artifact with the canonical builder, then run:
node tests/pocketic/store-directory-lifecycle.mjs \
--source-root="$PWD" --pocket-ic="$POCKET_IC_BIN" \
--shop="$PWD/tests/tmp/store-directory/artifacts/shop" \
--output="$PWD/tests/tmp/store-directory/results"
Use --name shop --package shop-canister --manifest-path tests/Cargo.toml
and --out-dir tests/tmp/store-directory/artifacts for that canonical build.
Shop has no public intentional-trap hook; the runner records update-trap
rollback as NOT_RUN and leaves application sources unchanged.
compatibility-lifecycle.mjs supplies the actual IC gate for the
SDK compatibility coordinator.
It takes six explicit artifact paths (baseline, candidate, layout, meaning,
unqualified and trap) and --result, rather than --source-root/--output.
It populates the composition fixture in an earlier call, checks rejected
contracts and rollback, and exercises old-to-new-to-old KEEP with new writes.
It must spawn the recorded local server; an existing-server override rejects.
compatibility-native.py checks the build's frozen source tree and recorded
compiler, then runs native SDK and qualification-tool tests. The
qualification experiment
records the suite, exact artifacts and limits; the synthetic approval stays out
of the product's registry.
Check prepared wasm64 and the matching generated TypeScript client with a compatible local PocketIC executable. Pass the canonical artifact stem and a fresh result file. Packaged Quickstart runner
node tests/pocketic/packaged-quickstart.mjs \
--packaged=/absolute/artifacts/quickstart --pocket-ic="$POCKET_IC_BIN" \
--result="$PWD/tmp/package-rehearsal/result.json"
It populates Quickstart with known scores, checks public reads and update
refusals, then validates KEEP and fresh writes. To test KEEP both ways on
separate populated canisters, add --checkout=/absolute/checkout-artifacts/quickstart
and --expect-cross-keep=admit or --expect-cross-keep=reject. A rejected
upgrade must preserve the original module hash, scores, and future writes.
Use the artifact receipts from the package-resolution rehearsal to identify
the tested dependency closure.
Factory orchestration and benchmark runners import these helpers and
wire-client.mjs, the PocketIC transport adapter for generated
Wire interfaces. The adapter uses the product's shared codec; codec and generated
client tooling remain SDK-owned. Orchestration runners use the factory source
root and keep their results and temporary state under tests/tmp.
Benchmark launchers use binary.mjs to reuse a verified read-only
executable from playground/private-frozen-binaries/sha256/<hash>/pocket-ic
through a hardlink. A missing cache or different filesystem uses a checked copy.
Session receipts record the storage choice and installer hash; executable bytes,
IC settings and instruction measurements are unchanged. Never chmod a linked
session executable. After its server closes, unlinking that session name leaves
the frozen cache intact. Run node --test tests/pocketic/binary.test.mjs for the
placement and pin checks.
The orchestration arena, callback, archive Reader, pending-local, reader-upgrade and cold-migration probes use the same canonical builder and this host package. RRT Heavy16's application-specific runner belongs to benches/rrt.