Skip to content
Draft
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
16 changes: 15 additions & 1 deletion rs/tests/driver/src/util/delegations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,17 +358,31 @@ struct CaptchaConfig {
pub captcha_trigger: CaptchaTrigger,
}

#[derive(CandidType, Serialize)]
pub struct DummyAuthConfig {
pub prompt_for_index: bool,
}

#[derive(CandidType, Serialize)]
struct InternetIdentityInit {
pub captcha_config: Option<CaptchaConfig>,
pub dummy_auth: Option<Option<DummyAuthConfig>>,
}

pub fn build_internet_identity_backend_install_arg() -> Vec<u8> {
pub fn build_internet_identity_backend_install_arg(dummy_auth: bool) -> Vec<u8> {
let dummy_auth = if dummy_auth {
Some(Some(DummyAuthConfig {
prompt_for_index: true,
}))
} else {
None
};
candid::encode_one(&InternetIdentityInit {
captcha_config: Some(CaptchaConfig {
max_unsolved_captchas: 50,
captcha_trigger: CaptchaTrigger::Static(StaticCaptchaTrigger::CaptchaDisabled),
}),
dummy_auth,
})
.unwrap()
}
Expand Down
46 changes: 43 additions & 3 deletions rs/tests/nns/nns_dapp/nns_dapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use ic_system_test_driver::driver::{
};
use ic_system_test_driver::nns::set_authorized_subnetwork_list;
use ic_system_test_driver::sns_client::add_subnet_to_sns_deploy_whitelist;
use ic_system_test_driver::util::delegations::build_internet_identity_backend_install_arg;
use ic_system_test_driver::util::delegations::{
DummyAuthConfig, build_internet_identity_backend_install_arg,
};
use ic_system_test_driver::util::{block_on, create_canister, install_canister, runtime_from_url};
use icp_ledger::AccountIdentifier;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -117,23 +119,33 @@ struct InternetIdentityFrontendInitArgs {
related_origins: Option<Vec<String>>,
fetch_root_key: Option<bool>,
dev_csp: Option<bool>,
dummy_auth: Option<Option<DummyAuthConfig>>,
}

fn install_ii_canisters(
env: &TestEnv,
node: &IcNodeSnapshot,
ic_gateway_domain: &str,
dummy_auth: bool,
) -> (Principal, Principal) {
let backend_canister_id = node.create_and_install_canister_with_arg(
&env::var("II_BACKEND_WASM_PATH").expect("II_BACKEND_WASM_PATH not set"),
Some(build_internet_identity_backend_install_arg()),
Some(build_internet_identity_backend_install_arg(dummy_auth)),
);

// Create the II frontend canister first to get its canister ID
let agent = node.build_default_agent();
let frontend_canister_id =
block_on(async { create_canister(&agent, node.effective_canister_id()).await });

let dummy_auth_config = if dummy_auth {
Some(Some(DummyAuthConfig {
prompt_for_index: true,
}))
} else {
None
};

// Install code into the II frontend canister.
let frontend_wasm =
load_wasm(env::var("II_FRONTEND_WASM_PATH").expect("II_FRONTEND_WASM_PATH not set"));
Expand All @@ -145,6 +157,7 @@ fn install_ii_canisters(
)]),
fetch_root_key: Some(true),
dev_csp: Some(true),
dummy_auth: dummy_auth_config,
})
.unwrap();
let logger = env.logger();
Expand Down Expand Up @@ -176,13 +189,40 @@ pub fn install_ii_nns_dapp_and_subnet_rental(
env: &TestEnv,
ic_gateway_url: &Url,
sns_aggregator_canister_id: Option<Principal>,
) -> (Principal, Principal) {
install_ii_nns_dapp_and_subnet_rental_impl(
env,
ic_gateway_url,
sns_aggregator_canister_id,
false,
)
}

pub fn install_ii_nns_dapp_and_subnet_rental_with_dummy_auth(
env: &TestEnv,
ic_gateway_url: &Url,
sns_aggregator_canister_id: Option<Principal>,
) -> (Principal, Principal) {
install_ii_nns_dapp_and_subnet_rental_impl(
env,
ic_gateway_url,
sns_aggregator_canister_id,
true,
)
}

fn install_ii_nns_dapp_and_subnet_rental_impl(
env: &TestEnv,
ic_gateway_url: &Url,
sns_aggregator_canister_id: Option<Principal>,
dummy_auth: bool,
) -> (Principal, Principal) {
let ic_gateway_domain = ic_gateway_url.domain().unwrap().to_string();

// deploy the II canister
let topology = env.topology_snapshot();
let nns_node = topology.root_subnet().nodes().next().unwrap();
let (_, ii_canister_id) = install_ii_canisters(env, &nns_node, &ic_gateway_domain);
let (_, ii_canister_id) = install_ii_canisters(env, &nns_node, &ic_gateway_domain, dummy_auth);

// create the NNS dapp canister so that its canister ID is allocated
// and the Subnet Rental Canister gets its mainnet canister ID in the next step
Expand Down
42 changes: 31 additions & 11 deletions rs/tests/testnets/cloud_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@
use anyhow::Result;

use ic_consensus_system_test_utils::rw_message::install_nns_with_customizations_and_check_progress;
use ic_protobuf::registry::dc::v1::{DataCenterRecord, Gps};
use ic_protobuf::registry::{
dc::v1::{DataCenterRecord, Gps},
node::v1::NodeRewardType,
};
use ic_registry_subnet_type::SubnetType;
use ic_system_test_driver::driver::{
farm::HostFeature,
Expand All @@ -48,9 +51,10 @@ use ic_system_test_driver::driver::{
test_env::TestEnv,
test_env_api::HasTopologySnapshot,
};
use ic_types::PrincipalId;
use ic_types::{Height, PrincipalId};
use nns_dapp::{
install_ii_nns_dapp_and_subnet_rental, nns_dapp_customizations, set_authorized_subnets,
install_ii_nns_dapp_and_subnet_rental_with_dummy_auth, nns_dapp_customizations,
set_authorized_subnets,
};
use std::collections::BTreeMap;
use std::net::Ipv4Addr;
Expand Down Expand Up @@ -112,11 +116,16 @@ pub fn setup(env: TestEnv) {

let mut ic = InternetComputer::new()
.with_required_host_features(dm1_dmz_features.clone())
.add_subnet(Subnet::new(SubnetType::System).add_nodes(1));
.add_subnet(
Subnet::new(SubnetType::System)
.add_nodes(1)
// To speed up subnet creation
.with_dkg_interval_length(Height::from(10)),
);

// Build CloudEngine subnet and unassigned nodes distributed across 4 datacenters.
// Each datacenter gets its own node operator with 1 CloudEngine node + 1 unassigned node.
let mut cloud_engine_subnet = Subnet::new(SubnetType::CloudEngine);
// let mut cloud_engine_subnet = Subnet::new(SubnetType::CloudEngine);
for (i, dc) in DATA_CENTERS.iter().enumerate() {
let operator_principal = PrincipalId::new_user_test_id(1000 + i as u64);
let provider_principal = PrincipalId::new_user_test_id(2000 + i as u64);
Expand All @@ -141,16 +150,27 @@ pub fn setup(env: TestEnv) {
});

// 1 CloudEngine node per DC
cloud_engine_subnet = cloud_engine_subnet
.add_node(Node::new().with_node_operator_principal_id(operator_principal));
// cloud_engine_subnet = cloud_engine_subnet.add_node(
// Node::new()
// .with_node_operator_principal_id(operator_principal)
// .with_node_reward_type(NodeRewardType::Type4),
// );

// 1 unassigned node per DC
ic = ic
.with_unassigned_node(Node::new().with_node_operator_principal_id(operator_principal));
ic = ic.with_unassigned_node(
Node::new()
.with_node_operator_principal_id(operator_principal)
.with_node_reward_type(NodeRewardType::Type4),
);
ic = ic.with_unassigned_node(
Node::new()
.with_node_operator_principal_id(operator_principal)
.with_node_reward_type(NodeRewardType::Type4),
);
}

ic = ic
.add_subnet(cloud_engine_subnet)
//.add_subnet(cloud_engine_subnet)
.with_api_boundary_nodes_playnet(1);

ic.setup_and_start(&env)
Expand Down Expand Up @@ -185,5 +205,5 @@ pub fn setup(env: TestEnv) {
set_authorized_subnets(&env);

// install II, NNS dapp, and Subnet Rental Canister
install_ii_nns_dapp_and_subnet_rental(&env, &ic_gateway_url, None);
install_ii_nns_dapp_and_subnet_rental_with_dummy_auth(&env, &ic_gateway_url, None);
}
Loading