Testing Creation of Canister on a subnet using Cycle Minting Canister with PocketIC

Just tried setting this up with pic locally, and when calling the create_canister API of the CMC I’m not specifying a subnet at all (null subnet_selection) and am getting the following error:

Mar 02 21:35:11.802 ERRO s:/n:/ic_execution_environment/canister_manager Unable to generate new canister IDs: Canister ID allocation was consumed
381523021 UTC: [Canister rkp4c-7iaaa-aaaaa-aaaca-cai] [cycles] Creating canister in subnet o5sz6-2cs3n-v2xts-gcvrz-ozndz-2gohh-vchh7-mieh4-vhg4e-z5tp6-vqe failed with code 1: Could not create canister. Subnet has surpassed its canister ID allocation.{additional_help}

This is how my PocketIC is currently set up (picJS)

const pic = await PocketIc.create(process.env.PIC_URL, {
    processingTimeoutMs: 60000,
    application: [
      {
        state: {
          type: SubnetStateType.New,
        },
      },
      {
        state: {
          type: SubnetStateType.New,
        },
      },
    ],
    // Additional configuration if needed
    nns: {
      state: {
        type: SubnetStateType.FromPath,
        path: NNS_STATE_PATH,
        subnetId: Principal.fromText(NNS_SUBNET_ID),
      },
    },
  });

Note that the code I have running to spin up a new canister currently works on mainnet.

Update: confirming that this also works with some of my older dfx tests that are directly hitting the old local full replica, but doesn’t work with the lighter pocket-ic replica.

Please note that using the same pre-configured state for both replica and PocketIC could lead to unexpected results. In other words, state should not be shared between replica and PocketIC.

1 Like