pub fn canister_only_accepts_ingress_with_payload(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 {
            // Create a canister that exposes the `canister_inspect_message`
            // method which rejects all ingress messages.
            let wasm_module = wabt::wat2wasm(
                r#"
                 (module
                 (import "ic0" "msg_reply" (func $msg_reply))
                 (import "ic0" "accept_message" (func $accept_message))
                 (import "ic0" "msg_arg_data_size"
                    (func $msg_arg_data_size (result i32)))

                 (func (export "canister_update hello")
                       (call $msg_reply)
                 )
                 (func (export "canister_inspect_message")
                   (if (i32.ne (i32.const 0) (call $msg_arg_data_size))
                       (call $accept_message))
                 )
                 (memory 1)
               )"#,
            )
            .unwrap();

            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 canister_id = create_and_install(&agent, &wasm_module).await;

            // Send the canister an ingress message without payload.  It should fail.
            assert_http_submit_fails(
                agent.update(&canister_id, "hello").call().await,
                StatusCode::FORBIDDEN,
            );

            // Send the canister an ingress message with payload.  It should succeed.
            agent
                .update(&canister_id, "hello")
                .with_arg(vec![1])
                .call_and_wait(delay())
                .await
                .expect("should succeed");
        }
    })
}
/// Defining a `canister_inspect_message` that only accepts messages with
/// payload.
Defining a `canister_inspect_message` that only accepts messages with
payload.
Defining a ` canister_inspect_message ` that only accepts messages with payload .
pub fn canister_only_accepts_ingress_with_payload(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 {
            // Create a canister that exposes the `canister_inspect_message`
            // method which rejects all ingress messages.
            let wasm_module = wabt::wat2wasm(
                r#"
                 (module
                 (import "ic0" "msg_reply" (func $msg_reply))
                 (import "ic0" "accept_message" (func $accept_message))
                 (import "ic0" "msg_arg_data_size"
                    (func $msg_arg_data_size (result i32)))
                 (func (export "canister_update hello")
                       (call $msg_reply)
                 )
                 (func (export "canister_inspect_message")
                   (if (i32.ne (i32.const 0) (call $msg_arg_data_size))
                       (call $accept_message))
                 )
                 (memory 1)
               )"#,
            )
            .unwrap();
            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 canister_id = create_and_install(&agent, &wasm_module).await;
            // Send the canister an ingress message without payload.  It should fail.
            assert_http_submit_fails(
                agent.update(&canister_id, "hello").call().await,
                StatusCode::FORBIDDEN,
            );
            // Send the canister an ingress message with payload.  It should succeed.
            agent
                .update(&canister_id, "hello")
                .with_arg(vec![1])
                .call_and_wait(delay())
                .await
                .expect("should succeed");
        }
    })
}
pub fn canister_only_accepts_ingress_with_payload ( 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 { // Create a canister that exposes the `canister_inspect_message` // method which rejects all ingress messages. let wasm_module = wabt :: wat2wasm ( r#"
                 (module
                 (import "ic0" "msg_reply" (func $msg_reply))
                 (import "ic0" "accept_message" (func $accept_message))
                 (import "ic0" "msg_arg_data_size"
                    (func $msg_arg_data_size (result i32)))

                 (func (export "canister_update hello")
                       (call $msg_reply)
                 )
                 (func (export "canister_inspect_message")
                   (if (i32.ne (i32.const 0) (call $msg_arg_data_size))
                       (call $accept_message))
                 )
                 (memory 1)
               )"# , ) . unwrap ( ) ; 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 canister_id = create_and_install ( & agent , & wasm_module ) . await ; // Send the canister an ingress message without payload.  It should fail. assert_http_submit_fails ( agent . update ( & canister_id , " " ) . call ( ) . await , StatusCode :: FORBIDDEN , ) ; // Send the canister an ingress message with payload.  It should succeed. agent . update ( & canister_id , " " ) . with_arg ( vec ! [ 1 ] ) . call_and_wait ( delay ( ) ) . await . expect ( " " ) ; } } ) }
Defining a `canister_inspect_message` that only accepts messages with
payload.
Defining a ` canister_inspect_message ` that only accepts messages with payload .
handle
IcHandle
ctx
&ic_fondue::pot::Context
handle
IcHandle
ctx
&ic_fondue::pot::Context