/// Creates canister C without a wasm module. Canister A keeps sending requests
/// to canister C from its heartbeat execution. While A is sending C messages, a
/// wasm module is installed on C.  We try to stop A and it should stop.
Creates canister C without a wasm module. Canister A keeps sending requests
to canister C from its heartbeat execution. While A is sending C messages, a
wasm module is installed on C.  We try to stop A and it should stop.
Creates canister C without a wasm module . Canister A keeps sending requests to canister C from its heartbeat execution . While A is sending C messages a wasm module is installed on C . We try to stop A and it should stop .
pub fn canister_heartbeat_can_stop(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 = util::get_random_node_endpoint(&handle, &mut rng);
            endpoint.assert_ready(ctx).await;
            let agent = util::assert_create_agent(endpoint.url.as_str()).await;
            let mgr = ManagementCanister::create(&agent);
            let canister_a = util::UniversalCanister::new(&agent).await;
            let canister_c = mgr
                .create_canister()
                .as_provisional_create_with_amount(None)
                .call_and_wait(util::delay())
                .await
                .unwrap()
                .0;
            // Send a request to C, C doesn't exist.
            canister_a
                .update(
                    wasm()
                        .set_heartbeat(
                            wasm().debug_print(b"calling heartbeat").inter_update(
                                canister_c,
                                call_args()
                                    .other_side(wasm().trap())
                                    .on_reply(wasm().noop()),
                            ),
                        )
                        .reply(),
                )
                .await
                .unwrap();
            // Wait a few seconds for the heartbeat to be invoked.
            std::thread::sleep(std::time::Duration::from_secs(10));
            eprintln!("installing canister");
            // Install the universal canister.
            mgr.install_code(&canister_c, UNIVERSAL_CANISTER_WASM)
                .with_raw_arg(vec![])
                .call_and_wait(util::delay())
                .await
                .unwrap();
            std::thread::sleep(std::time::Duration::from_secs(10));
            // Try stopping canister A
            eprintln!("Trying to stop the canister");
            mgr.stop_canister(&canister_a.canister_id())
                .call_and_wait(util::delay())
                .await
                .expect("Couldn't stop canister");
        }
    });
}
pub fn canister_heartbeat_can_stop ( 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 = util :: get_random_node_endpoint ( & handle , & mut rng ) ; endpoint . assert_ready ( ctx ) . await ; let agent = util :: assert_create_agent ( endpoint . url . as_str ( ) ) . await ; let mgr = ManagementCanister :: create ( & agent ) ; let canister_a = util :: UniversalCanister :: new ( & agent ) . await ; let canister_c = mgr . create_canister ( ) . as_provisional_create_with_amount ( None ) . call_and_wait ( util :: delay ( ) ) . await . unwrap ( ) . 0 ; // Send a request to C, C doesn't exist. canister_a . update ( wasm ( ) . set_heartbeat ( wasm ( ) . debug_print ( b" " ) . inter_update ( canister_c , call_args ( ) . other_side ( wasm ( ) . trap ( ) ) . on_reply ( wasm ( ) . noop ( ) ) , ) , ) . reply ( ) , ) . await . unwrap ( ) ; // Wait a few seconds for the heartbeat to be invoked. std :: thread :: sleep ( std :: time :: Duration :: from_secs ( 10 ) ) ; eprintln ! ( " " ) ; // Install the universal canister. mgr . install_code ( & canister_c , UNIVERSAL_CANISTER_WASM ) . with_raw_arg ( vec ! [ ] ) . call_and_wait ( util :: delay ( ) ) . await . unwrap ( ) ; std :: thread :: sleep ( std :: time :: Duration :: from_secs ( 10 ) ) ; // Try stopping canister A eprintln ! ( " " ) ; mgr . stop_canister ( & canister_a . canister_id ( ) ) . call_and_wait ( util :: delay ( ) ) . await . expect ( " " ) ; } } ) ; }
Creates canister C without a wasm module.
Creates canister C without a wasm module .
handle
IcHandle
ctx
&ic_fondue::pot::Context