ic-kit
ic-kit copied to clipboard
How to mock canister with existing method?
Hi. Amazing library! Can you please provide some insight on how to mock a canister with existing methods.
Say, I have a method
#[update]
async fn do_nothing(my_arg: u64) -> Result<(), String> {
Ok(())
}
How would I create a Canister
mock with the method above? I've tried to use RawHandler
, but cannot figure out how to transfer arguments correctly.
The way I want to use it later is like so:
let canister = Canister::new(mock_principals::alice())
.method("do_nothing", ...);
let ctx = canister.context().inject();
ic::call_with_payment(mock_principals::alice(), "do_nothing", (1000), 100);
Is it even possible with the current implementation?