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

feat: support application subnets for PocketIC #159

Merged
merged 1 commit into from
Nov 14, 2024
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
1 change: 1 addition & 0 deletions extensions/nns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased] - ReleaseDate
- Fixed a bug where `dfx nns install` and `dfx nns import` would fail if a canister type in dfx.json was defined by an extension.
- Added support for application subnets for `dfx start --pocketic`.

## [0.4.7] - 2024-11-08
- Added support for `dfx start --pocketic`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"local": {
"replica": {
"subnet_type": "application"
}
}
}
16 changes: 16 additions & 0 deletions extensions/nns/e2e/tests/nns.bash
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ assert_nns_canister_id_matches() {
#assert_nns_canister_id_matches nns-dapp
}

@test "dfx nns install on application subnet" {
echo Setting up...
install_shared_asset subnet_type/shared_network_settings/application
dfx_start_for_nns_install

run dfx nns install

if [[ "$USE_POCKET_IC" ]]
then
assert_success
else
assert_failure
assert_output --partial "The replica subnet_type needs to be 'system' to run NNS canisters."
fi
}

@test "dfx nns install runs" {

echo Setting up...
Expand Down
14 changes: 13 additions & 1 deletion extensions/nns/src/install_nns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,19 @@ pub async fn install_nns(
logger: &Logger,
) -> anyhow::Result<()> {
eprintln!("Checking out the environment...");
verify_local_replica_type_is_system(network, networks_config)?;
// check if we're talking to PocketIC defaulting to false if we aren't sure
let is_pocketic = if let Some(descriptor) = &network.local_server_descriptor {
// PocketIC server has `/_/topology` endpoint while the replica does not
let endpoint = format!("http://{}/_/topology", descriptor.bind_address);
let status = reqwest::get(endpoint).await?.status();
status.is_success()
} else {
false
};
// PocketIC has multiple subnets and thus supports default application subnet type.
if !is_pocketic {
verify_local_replica_type_is_system(network, networks_config)?;
}
verify_nns_canister_ids_are_available(agent).await?;
let provider_url = get_and_check_provider(network)?;
let nns_url = provider_url.clone();
Expand Down
2 changes: 1 addition & 1 deletion extensions/sns/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::commands::{download::SnsDownloadOpts, import::SnsImportOpts};
use clap::Parser;
use ic_sns_cli::{
add_sns_wasm_for_tests, deploy_testflight,
health::{self, HealthArgs},
init_config_file::{self, InitConfigFileArgs},
list::{self, ListArgs},
health::{self, HealthArgs},
neuron_id_to_candid_subaccount::{self, NeuronIdToCandidSubaccountArgs},
prepare_canisters::{self, PrepareCanistersArgs},
propose::{self, ProposeArgs},
Expand Down
Loading