I’m currently writing tests for Sudograph, using Rust’s built-in testing capabilities (cargo test and such) and proptest. I spin up a local replica and execute my tests as query or update calls into canisters. That works very well for integration tests, as my tests go through the entire motions of creating query and update calls and validating the responses.
But it’s very slow, even if I use --no-artificial-delay, compared to the speed my tests could move at if they were running from within the canister. Instead of performing http requests to call the canister methods, it would be nice if I could run tests from within the canister that could call the methods directly.
How should we go about testing canister code without the overhead of network requests to perform query and update calls?
I personally find it very useful to keep API methods as simple as possible and have a separate place for the main logic, which I can cover with standard rust unit tests.
Hi Senior.joinu
How are you?
I am writing a unit test script in rust using ic_cdk::call.
But I got an error
running 1 test
thread 'users::update::it_works' panicked at 'call_new should only be called inside canisters.', /home/eiten/.cargo/registry/src/github.com-1ecc6299db9ec823/ic0-0.18.9/src/ic0.rs:155:9
stack backtrace: