pub fn creating_canisters_fails_if_limit_of_allowed_canisters_is_reached(
    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 = get_random_node_endpoint(&handle, &mut rng);
            endpoint.assert_ready(ctx).await;
            let agent = assert_create_agent(endpoint.url.as_str()).await;

            let mgr = ManagementCanister::create(&agent);
            // Create 3 canisters when 3 are allowed, should succeed.
            mgr.create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(delay())
                .await
                .unwrap();
            mgr.create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(delay())
                .await
                .unwrap();
            let canister = UniversalCanister::new(&agent).await;

            // Attempt to create a fourth canister when only 3 are allowed, should fail.
            let res = mgr
                .create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(delay())
                .await;
            assert_reject(res, RejectCode::SysFatal);

            // Creating a canister via another canister would also fail since we're at
            // limit.
            assert_reject(
                canister
                    .update(wasm().call(management::create_canister(100_000_000_000)))
                    .await,
                RejectCode::CanisterReject,
            );
        }
    })
}
/// This test assumes it's being executed using
/// `config_max_number_of_canisters`, which limits the allowed canisters on the
/// subnet to be 3.
This test assumes it's being executed using
`config_max_number_of_canisters`, which limits the allowed canisters on the
subnet to be 3.
This test assumes it ' s being executed using ` config_max_number_of_canisters ` which limits the allowed canisters on the subnet to be 3 .
pub fn creating_canisters_fails_if_limit_of_allowed_canisters_is_reached(
    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 = get_random_node_endpoint(&handle, &mut rng);
            endpoint.assert_ready(ctx).await;
            let agent = assert_create_agent(endpoint.url.as_str()).await;
            let mgr = ManagementCanister::create(&agent);
            // Create 3 canisters when 3 are allowed, should succeed.
            mgr.create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(delay())
                .await
                .unwrap();
            mgr.create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(delay())
                .await
                .unwrap();
            let canister = UniversalCanister::new(&agent).await;
            // Attempt to create a fourth canister when only 3 are allowed, should fail.
            let res = mgr
                .create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(delay())
                .await;
            assert_reject(res, RejectCode::SysFatal);
            // Creating a canister via another canister would also fail since we're at
            // limit.
            assert_reject(
                canister
                    .update(wasm().call(management::create_canister(100_000_000_000)))
                    .await,
                RejectCode::CanisterReject,
            );
        }
    })
}
pub fn creating_canisters_fails_if_limit_of_allowed_canisters_is_reached ( 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 = get_random_node_endpoint ( & handle , & mut rng ) ; endpoint . assert_ready ( ctx ) . await ; let agent = assert_create_agent ( endpoint . url . as_str ( ) ) . await ; let mgr = ManagementCanister :: create ( & agent ) ; // Create 3 canisters when 3 are allowed, should succeed. mgr . create_canister ( ) . as_provisional_create_with_amount ( None ) . call_and_wait ( delay ( ) ) . await . unwrap ( ) ; mgr . create_canister ( ) . as_provisional_create_with_amount ( None ) . call_and_wait ( delay ( ) ) . await . unwrap ( ) ; let canister = UniversalCanister :: new ( & agent ) . await ; // Attempt to create a fourth canister when only 3 are allowed, should fail. let res = mgr . create_canister ( ) . as_provisional_create_with_amount ( None ) . call_and_wait ( delay ( ) ) . await ; assert_reject ( res , RejectCode :: SysFatal ) ; // Creating a canister via another canister would also fail since we're at // limit. assert_reject ( canister . update ( wasm ( ) . call ( management :: create_canister ( 100_000_000_000 ) ) ) . await , RejectCode :: CanisterReject , ) ; } } ) }
This test assumes it's being executed using
`config_max_number_of_canisters`, which limits the allowed canisters on the
subnet to be 3.
This test assumes it ' s being executed using ` config_max_number_of_canisters ` which limits the allowed canisters on the subnet to be 3 .
handle
IcHandle
ctx
&ic_fondue::pot::Context
handle
IcHandle
ctx
&ic_fondue::pot::Context