Create Canister with exact Id using PocketIc on a subnet

Sometimes we have a check based on constant value of Principal. Example: check if the call coming from particular canister. Testing these scenarios becomes extremely difficult as mocking those const values is difficult and there is no way to actually create canister with particular Id in a given subnet using pocket-ic. Is there any way to tackle this situation for now?

1 Like

If you are using Rust there is create_canister_with_id but it says

The canister ID must be contained in the Bitcoin, Fiduciary, II, SNS or NNS subnet range, it is not intended to be used on regular app or system subnets, where it can lead to conflicts on which the function panics.

@michael-weigelt, any ideas?

1 Like