Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: default effective canister id for PocketIC #4059

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading