TOKO/Toolkit/IC Testkit

Developer Tooling & Quality Infrastructure

IC Testkit

A higher-level testing experience on top of PocketIC.

IC Testkit is a small wrapper and helper layer around PocketIC, the local Internet Computer testing runtime. It doesn't replace PocketIC — it adds typed Candid calls, install helpers, cached baselines, deterministic identities, and benchmark reporting to reduce boilerplate and improve reproducibility.

RustBuilt on PocketICcrates.io: ic-testkitMIT licensed

What it is

Less boilerplate, more reproducible tests

Use PocketIC directly when you want the raw simulator API. Reach for IC Testkit when you want the conveniences a real test suite needs: typed Candid query and update helpers with contextual errors, install helpers, serialized PocketIC startup, cached baselines for expensive setup, deterministic fake principals, wasm artifact utilities, and compact benchmark reporting.

It resolves the PocketIC server binary for you — using a trusted path or a versioned cache — and fails with clear setup guidance instead of letting the underlying runtime panic.

Capabilities

What IC Testkit adds over PocketIC

01

Typed Candid calls

Query/update helpers with contextual errors, caller-identity variants, and panic-on-transport helpers for fast failures.

02

Install helpers

Generic wasm install helpers, standalone fixtures, sequential batch installs, and install-code rate-limit retries.

03

Cached baselines

Snapshot canisters once and restore them between tests; rebuild automatically if a cached instance has died.

04

Deterministic identities

Fake produces stable principals and account-like values from numeric seeds for predictable tests.

05

Artifact utilities

Build wasm packages into a dedicated target dir, check readiness, and verify generated .icp freshness.

06

Benchmark reporting

Parse compact ICTK log markers into events, spans, aggregates, CSV files, and a Markdown summary.

Quick start

Own a PocketIC instance, call a canister

Add ic-testkit as a dev-dependency, acquire a serial guard, and use the Candid-aware Pic wrapper for common calls.

rust
use ic_testkit::pic::{acquire_pic_serial_guard, pic};

#[test]
fn calls_a_counter_canister() {
    let _guard = acquire_pic_serial_guard();
    let pic = pic();
    let counter = install_counter(&pic);

    let _: () = pic.update_call(counter, "increment", ()).unwrap();
    let value: u64 = pic.query_call(counter, "get", ()).unwrap();
    assert_eq!(value, 1);
}

Who it's for

For canister developers who care about rigor

  • Teams writing PocketIC integration tests
  • Projects that need deterministic, reproducible suites
  • Anyone benchmarking canister instruction and memory cost
  • Frameworks shipping reusable test harnesses

Clear boundaries

IC Testkit doesn't define application init payloads, endpoint names, role models, canister topology, benchmark labels, threshold policy, or CI failure policy. Those belong to the application or framework that owns the canisters under test.

Validate before you deploy

See the full helper reference, benchmark format, and setup guide on GitHub.