Skip to content

How to mock canister with existing method? #1

@Maximkaaa

Description

@Maximkaaa

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions