// Sets the available memory to quite a low number to force a
// `HypervisorError::OutOfMemory`.
Sets the available memory to quite a low number to force a
`HypervisorError::OutOfMemory`.
Sets the available memory to quite a low number to force a ` HypervisorError :: OutOfMemory ` .
fn sys_api_call_update_available_memory_1() {
    with_hypervisor(|hypervisor, tmp_path| {
        assert_eq!(
            execute_update_with_cycles_memory_time(
                &hypervisor,
                r#"
                (module
                  (func (;0;)
                    i32.const 10
                    memory.grow ;; Try to grow by 10 wasm pages
                    drop
                  )
                  (memory (;0;) 1 20)
                  (export "memory" (memory 0))
                  (export "canister_update test" (func 0)))"#,
                "test",
                EMPTY_PAYLOAD,
                None,
                MAX_NUM_INSTRUCTIONS,
                // Only 9 pages available
                ic_replicated_state::num_bytes_from(NumWasmPages::from(9)),
                mock_time(),
                tmp_path,
            )
            .2,
            CallContextAction::Fail {
                error: HypervisorError::OutOfMemory,
                refund: Cycles::from(0),
            }
        );
    });
}
fn sys_api_call_update_available_memory_1 ( ) { with_hypervisor ( | hypervisor , tmp_path | { assert_eq ! ( execute_update_with_cycles_memory_time ( hypervisor r#"
                (module
                  (func (;0;)
                    i32.const 10
                    memory.grow ;; Try to grow by 10 wasm pages
                    drop
                  )
                  (memory (;0;) 1 20)
                  (export "memory" (memory 0))
                  (export "canister_update test" (func 0)))"# " " EMPTY_PAYLOAD None MAX_NUM_INSTRUCTIONS // Only 9 pages available ic_replicated_state num_bytes_from ( NumWasmPages from ( 9 ) ) mock_time ( ) tmp_path ) 2 CallContextAction Fail { error HypervisorError OutOfMemory refund Cycles from ( 0 ) } ) ; } ) ; }
Sets the available memory to quite a low number to force a
`HypervisorError::OutOfMemory`.
Sets the available memory to quite a low number to force a ` HypervisorError :: OutOfMemory ` .