mops icon indicating copy to clipboard operation
mops copied to clipboard

Replica test canisterId

Open skilesare opened this issue 8 months ago • 3 comments

Is there an easy way to get/use the ID of the canister that is created to test the replica tests? This will be the caller on the tests and it would be good for tests in case you need to add that principal as an admin on your canister.

skilesare avatar Apr 07 '25 21:04 skilesare

I think you can treat a canister deployer as an admin. Or you can pass the current test canister id from Principal.fromActor(this) when you create your canister within the test.

ZenVoich avatar Apr 08 '25 12:04 ZenVoich

The issue is that the docs specifically say to not give the canister a name:

Make sure your actor doesn't have a name actor {.

Make sure your actor has runTests method.


When I try to give my actor a name and call Principal.fromActor(MyName), my test just passes and isn't really run. I think the name messes it up. the "this" construction requires an actor class I think.

skilesare avatar Apr 22 '25 03:04 skilesare

Added actor class support to 1.7.0

ZenVoich avatar Apr 22 '25 13:04 ZenVoich