Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to mock canister with existing method? #1

Open
Maximkaaa opened this issue Nov 3, 2021 · 0 comments
Open

How to mock canister with existing method? #1

Maximkaaa opened this issue Nov 3, 2021 · 0 comments

Comments

@Maximkaaa
Copy link

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?

@Maximkaaa Maximkaaa changed the title How to mock canister with existing method How to mock canister with existing method? Nov 3, 2021
ozwaldorf pushed a commit that referenced this issue Sep 1, 2022
feat: impl runtime canister stable storage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant