/// A test to ensure that controller and controllee canisters can exist on
/// different subnets and they can still control each other.
A test to ensure that controller and controllee canisters can exist on
different subnets and they can still control each other.
A test to ensure that controller and controllee canisters can exist on different subnets and they can still control each other .
pub fn controller_and_controllee_on_different_subnets(
    handle: IcHandle,
    ctx: &ic_fondue::pot::Context,
) {
    let mut rng = ctx.rng.clone();
    let rt = tokio::runtime::Runtime::new().expect("Could not create tokio runtime.");
    rt.block_on({
        async move {
            let endpoint_0 = get_random_verified_app_node_endpoint(&handle, &mut rng);
            endpoint_0.assert_ready(ctx).await;
            let endpoint_1 = get_random_application_node_endpoint(&handle, &mut rng);
            endpoint_1.assert_ready(ctx).await;
            let combinations = vec![
                (endpoint_0.url.clone(), endpoint_1.url.clone()),
                (endpoint_1.url.clone(), endpoint_0.url.clone()),
            ];
            async fn install_via_cr(
                cr: &UniversalCanister<'_>,
                target: Principal,
            ) -> Result<Vec<u8>, AgentError> {
                cr.update(
                    wasm().call(
                        management::install_code(target, UNIVERSAL_CANISTER_WASM.to_vec())
                            .with_mode(management::InstallMode::Reinstall),
                    ),
                )
                .await
            }
            for (cr, ce) in combinations {
                let controller_agent = assert_create_agent(cr.as_str()).await;
                let controllee_agent = assert_create_agent(ce.as_str()).await;
                let controller = UniversalCanister::new(&controller_agent).await;
                let controllee = UniversalCanister::new(&controllee_agent).await;
                // before setting the controller, this call must fail.
                assert_reject(
                    install_via_cr(&controller, controllee.canister_id()).await,
                    RejectCode::CanisterReject,
                );
                set_controller(
                    &controllee.canister_id(),
                    &controller.canister_id(),
                    &controllee_agent,
                )
                .await;
                let mgr = ManagementCanister::create(&controllee_agent);
                assert_http_submit_fails(
                    mgr.stop_canister(&controllee.canister_id()).call().await,
                    StatusCode::FORBIDDEN,
                );
                install_via_cr(&controller, controllee.canister_id())
                    .await
                    .unwrap();
                controller
                    .update(wasm().call(management::stop_canister(controllee.canister_id())))
                    .await
                    .unwrap();
                controller
                    .update(wasm().call(management::delete_canister(controllee.canister_id())))
                    .await
                    .unwrap();
            }
        }
    })
}
pub fn controller_and_controllee_on_different_subnets ( handle : IcHandle , ctx : & ic_fondue :: pot :: Context , ) { let mut rng = ctx . rng . clone ( ) ; let rt = tokio :: runtime :: Runtime :: new ( ) . expect ( " " ) ; rt . block_on ( { async move { let endpoint_0 = get_random_verified_app_node_endpoint ( & handle , & mut rng ) ; endpoint_0 . assert_ready ( ctx ) . await ; let endpoint_1 = get_random_application_node_endpoint ( & handle , & mut rng ) ; endpoint_1 . assert_ready ( ctx ) . await ; let combinations = vec ! [ ( endpoint_0 url clone ( ) endpoint_1 url clone ( ) ) ( endpoint_1 url clone ( ) endpoint_0 url clone ( ) ) ] ; async fn install_via_cr ( cr : & UniversalCanister < ' _ > , target : Principal , ) -> Result < Vec < u8 > , AgentError > { cr . update ( wasm ( ) . call ( management :: install_code ( target , UNIVERSAL_CANISTER_WASM . to_vec ( ) ) . with_mode ( management :: InstallMode :: Reinstall ) , ) , ) . await } for ( cr , ce ) in combinations { let controller_agent = assert_create_agent ( cr . as_str ( ) ) . await ; let controllee_agent = assert_create_agent ( ce . as_str ( ) ) . await ; let controller = UniversalCanister :: new ( & controller_agent ) . await ; let controllee = UniversalCanister :: new ( & controllee_agent ) . await ; // before setting the controller, this call must fail. assert_reject ( install_via_cr ( & controller , controllee . canister_id ( ) ) . await , RejectCode :: CanisterReject , ) ; set_controller ( & controllee . canister_id ( ) , & controller . canister_id ( ) , & controllee_agent , ) . await ; let mgr = ManagementCanister :: create ( & controllee_agent ) ; assert_http_submit_fails ( mgr . stop_canister ( & controllee . canister_id ( ) ) . call ( ) . await , StatusCode :: FORBIDDEN , ) ; install_via_cr ( & controller , controllee . canister_id ( ) ) . await . unwrap ( ) ; controller . update ( wasm ( ) . call ( management :: stop_canister ( controllee . canister_id ( ) ) ) ) . await . unwrap ( ) ; controller . update ( wasm ( ) . call ( management :: delete_canister ( controllee . canister_id ( ) ) ) ) . await . unwrap ( ) ; } } } ) }
A test to ensure that controller and controllee canisters can exist on
different subnets and they can still control each other.
A test to ensure that controller and controllee canisters can exist on different subnets and they can still control each other .
handle
IcHandle
ctx
&ic_fondue::pot::Context