Migrating to icpp-pro 6.0.0
Your tests must now be told which icp identity to run as. icpp-pro no longer uses the
machine-wide active identity (icp identity default), because any other process can change it
while your tests are running.
If you upgrade without changing anything, the run stops at session start and tells you what to add. It never silently runs as the wrong principal.
Still on dfx?
Do Migrating from dfx first, then come back here.
The migration
1. Create an identity. Any name — it no longer has to be default:
icp identity new my-project-testing --storage plaintext
--storage plaintext is required: icpp-pro exports the key to sign locally, so a
password-protected identity cannot be used.
2. Name it when you test. Either per command:
pytest --network=local --identity my-project-testing
or once per project, which leaves your existing pytest commands untouched:
export ICPP_PRO_TEST_IDENTITY=my-project-testing
3. Deploy with that same identity, so the caller of a test is the canister's controller:
icp deploy --environment local --yes --identity my-project-testing
4. Delete any icp identity default <name> from your Makefiles, scripts and CI workflows.
Nothing needs to switch any more. If you created an identity called default purely to
satisfy the old identity_default fixture, you can delete that too.
5. Remove any assertion on the literal name, the only code change most projects need:
# no longer true, and never what the test was actually checking
assert identity_default["identity"] == "default"
That is the whole migration. Your test bodies do not change.
What the fixtures do now
| Fixture | 6.0.0 |
|---|---|
identity |
the identity you named |
principal |
its principal |
identity_default |
the identity you named — not an identity called default |
identity_anonymous |
runs the test's calls as anonymous, unchanged |
identity_default keeps its name so existing test signatures keep working.
Calling as a specific identity
call_canister_api, get_canister_id, get_principal and the url helpers take an optional
identity= that overrides the session identity for that one call. This is what you want for a
test that exercises two principals against each other:
response = call_canister_api(
icp_yaml_path=ICP_YAML_PATH,
canister_name=CANISTER_NAME,
canister_method="whoami",
network=network,
identity="some-other-identity",
)
Removed
smoketest.set_identity() and smoketest.get_identity() are gone — they wrote and read the
machine-wide active identity. Use identity= at the call site instead, or run
icp identity default in a shell if you only want to see what yours is.
Why
icp identity default <name> is machine-wide and persistent — not scoped to a process, a
shell, or a project. Choosing a test's identity through it meant:
- a killed run left your active identity pointing somewhere else, with nothing to restore it;
- anything else on your machine that read it mid-run saw the wrong identity;
- and, the reason this is a major release, another process could change it while your tests were running, so the caller could change halfway through a suite.
Saving the old value and restoring it afterwards narrows that last window but cannot close it.
6.0.0 removes the lookup entirely: the name is pinned once, from something you wrote down, and
passed to every icp command as --identity.