Skip to content

Commit

Permalink
fix: default effective canister id for PocketIC
Browse files Browse the repository at this point in the history
  • Loading branch information
mraszyk committed Jan 8, 2025
1 parent 060e103 commit a6c7acb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
12 changes: 12 additions & 0 deletions e2e/tests-dfx/start.bash
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@ teardown() {
dfx_stop
}

@test "start and stop with specified canister id" {
dfx_start

dfx_new hello
dfx deploy hello_backend --specified-id gt2iw-kiaaa-aaad7-qaaaa-cai

dfx_stop

dfx_start
dfx_stop
}

@test "start and stop with different options" {
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: clean required"
dfx_start --artificial-delay 101
Expand Down
19 changes: 3 additions & 16 deletions src/dfx/src/actors/pocketic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,25 +385,12 @@ async fn initialize_pocketic(
instance_id,
topology,
} => {
let subnets = match replica_config.subnet_type {
ReplicaSubnetType::Application => topology.get_app_subnets(),
ReplicaSubnetType::System => topology.get_system_subnets(),
ReplicaSubnetType::VerifiedApplication => topology.get_verified_app_subnets(),
};
if subnets.len() != 1 {
return Err(anyhow!("Internal error: PocketIC topology contains multiple subnets of the same subnet kind."));
}
let subnet_id = subnets[0];
let subnet_config = topology.subnet_configs.get(&subnet_id).ok_or(anyhow!(
"Internal error: subnet id {} not found in PocketIC topology",
subnet_id
))?;
let effective_canister_id =
Principal::from_slice(&subnet_config.canister_ranges[0].start.canister_id);
let default_effective_canister_id: Principal =
topology.default_effective_canister_id.into();
let effective_config = CachedConfig::pocketic(
replica_config,
replica_rev().into(),
Some(effective_canister_id),
Some(default_effective_canister_id),
);
save_json_file(effective_config_path, &effective_config)?;
instance_id
Expand Down

0 comments on commit a6c7acb

Please sign in to comment.