From 02fd5b5035d5988954055902c046eac1c517aa97 Mon Sep 17 00:00:00 2001 From: Roman Melnikov Date: Fri, 14 Feb 2025 11:39:53 +0100 Subject: [PATCH] fixup! sns-testing: check that NNS canisters exist before deploying --- rs/sns/testing/src/nns_dapp.rs | 13 +++++-------- rs/sns/testing/src/sns.rs | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/rs/sns/testing/src/nns_dapp.rs b/rs/sns/testing/src/nns_dapp.rs index ceb80eb1ed0e..ef27e0729a46 100644 --- a/rs/sns/testing/src/nns_dapp.rs +++ b/rs/sns/testing/src/nns_dapp.rs @@ -30,7 +30,7 @@ async fn validate_subnet_setup(pocket_ic: &PocketIc) { let _sns_subnet_id = topology.get_nns().expect("SNS subnet not found"); let _ii_subnet_id = topology.get_ii().expect("II subnet not found"); let app_subnet_ids = topology.get_app_subnets(); - assert!(app_subnet_ids.len() > 0, "No application subnets found"); + assert!(!app_subnet_ids.is_empty(), "No application subnets found"); } async fn check_canister_exists(pocket_ic: &PocketIc, canister_id: &CanisterId) -> bool { @@ -52,16 +52,11 @@ pub async fn bootstrap_nns(pocket_ic: &PocketIc) { let canisters_exist = join_all( ALL_NNS_CANISTER_IDS .iter() - .map(|canister_id| async { check_canister_exists(pocket_ic, *canister_id).await }), + .map(|canister_id| async { check_canister_exists(pocket_ic, canister_id).await }), ) .await; - // Don't do anything if all NNS canister are already installed - if canisters_exist.iter().all(|exists| *exists) { - (); - } else if canisters_exist.iter().any(|exists| *exists) { - panic!("Some NNS canisters are missing, we cannot fix this automatically at the moment"); - } else { + if !canisters_exist.iter().any(|exists| *exists) { // TODO @rvem: at some point in the future we might want to use // non-default 'initial_balances' as well as 'neurons_fund_hotkeys' to provide // tokens and neuron hotkeys for user-provided indentities. @@ -72,6 +67,8 @@ pub async fn bootstrap_nns(pocket_ic: &PocketIc) { nns_installer.with_index_canister(); nns_installer.install(pocket_ic).await; add_wasms_to_sns_wasm(pocket_ic, false).await.unwrap(); + } else if !canisters_exist.iter().all(|exists| *exists) { + panic!("Some NNS canisters are missing, we cannot fix this automatically at the moment"); } install_frontend_nns_canisters(pocket_ic).await; diff --git a/rs/sns/testing/src/sns.rs b/rs/sns/testing/src/sns.rs index d361034fd8d7..141209a9849f 100644 --- a/rs/sns/testing/src/sns.rs +++ b/rs/sns/testing/src/sns.rs @@ -71,7 +71,7 @@ pub async fn create_sns( .await .expect("Expecting the swap to be open after creation"); smoke_test_participate_and_finalize(pocket_ic, sns.swap.canister_id, swap_parameters).await; - await_swap_lifecycle(&pocket_ic, sns.swap.canister_id, Lifecycle::Committed) + await_swap_lifecycle(pocket_ic, sns.swap.canister_id, Lifecycle::Committed) .await .expect("Expecting the swap to be commited after creation and swap completion"); (sns, proposal_id)