i’m running into the following error when running tests with pocket-ic on the most recent versions;
After upgrading from;
dfx version: 0.26.0
ic-cdk: 0.17.1
pocket-ic: 0.7.0
pocket-ic-server: 0.8.0
to;
dfx version: 0.26.0
ic-cdk: 0.18.0
pocket-ic: 0.8.0
pocket-ic-server: 0.9.0 (also tried 0.8.0)
> also had to include the "ic-management-canister-types" crate
im getting the following error;
2025-04-28T20:50:19.099242Z INFO pocket_ic_server: The PocketIC server is listening on port 61676
thread 'tokio-runtime-worker' panicked at rs/state_manager/src/lib.rs:1437:21:
Failed to load checkpoint @9200: /Users/rem.codes/Documents/rem.codes/toolkit/toolkit_services/src/test_helper/nns_state/checkpoints/00000000000023f0/canister_states/00000000000000000101: failed to deserialize canister_states[rwlgt-iiaaa-aaaaa-aaaaa-cai]::canister_state_bits: Value out of range for type OnLowWasmMemoryHookStatus: Unexpected value of status of on low wasm memory hook: Unspecified
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at rs/pocket_ic_server/src/state_api/state.rs:756:14:
Failed to create PocketIC instance: JoinError::Panic(Id(21), "Failed to load checkpoint @9200: /Users/rem.codes/Documents/rem.codes/toolkit/toolkit_services/src/test_helper/nns_state/checkpoints/00000000000023f0/canister_states/00000000000000000101: failed to deserialize canister_states[rwlgt-iiaaa-aaaaa-aaaaa-cai]::canister_state_bits: Value out of range for type OnLowWasmMemoryHookStatus: Unexpected value of status of on low wasm memory hook: Unspecified", ...)
test test_get_config ... FAILED
code
impl Context {
pub fn new() -> Self {
let nns_state_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
.parent()
.expect("Failed to get parent dir")
.join("test_helper/nns_state");
let owner_account = Account::from(Principal::from_text(OWNER_PRINCIPAL).unwrap());
let default_install_settings: Option<CanisterSettings> = Some(CanisterSettings {
controllers: Some(vec![owner_account.owner]),
compute_allocation: None,
memory_allocation: None,
freezing_threshold: None,
reserved_cycles_limit: None,
log_visibility: None,
wasm_memory_limit: None,
});
if !PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap())
.parent()
.expect("Failed to get parent dir")
.join("test_helper/nns_state")
.exists()
{
panic!("NNS state not found. Please run `bash scripts/prepare_test.sh` to load the NNS state.");
}
let pic = PocketIcBuilder::new()
.with_application_subnet()
.with_nns_subnet()
.with_nns_state(nns_state_path) // this first included state is the nns subnet id
.build();
let toolkit_services_canister =
pic.create_canister_with_settings(None, default_install_settings.clone());
pic.add_cycles(toolkit_services_canister, 2_000_000_000_000);
let toolkit_services_wasm_bytes = include_bytes!("../../wasm/toolkit_services.wasm.gz");
pic.install_canister(
toolkit_services_canister,
toolkit_services_wasm_bytes.to_vec(),
encode_args(()).unwrap(),
Some(owner_account.owner),
);
Context {
pic,
owner_account,
toolkit_services_canister,
}
}
pub fn toolkit_services_query<T: DeserializeOwned + CandidType>(
&self,
sender: Sender,
method: &str,
args: Option<Vec<u8>>,
) -> Result<T, String> {
let args = args.unwrap_or(encode_args(()).unwrap());
let res = self
.pic
.query_call(
self.toolkit_services_canister,
sender.principal(),
method,
args,
)
.expect("Failed to call canister");
Decode!(res.as_slice(), T).map_err(|e| e.to_string())
}
}
test;
#[test]
fn test_get_config() -> Result<(), String> {
let context = Context::new();
// fetch the config
let config_result = context.toolkit_services_query::<CanisterResult<Config>>(
Sender::Owner,
"get_config",
None,
)?;
println!("config_result: {:?}", config_result);
assert!(config_result.is_ok());
Ok(())
}
thanks in advance