Pocket-ic support for management canister calls and timers?

In the init() of a canister, I set up a random number generator, like this:

    ic_cdk_timers::set_timer(Duration::ZERO, || {
        ic_cdk::spawn(async {
            let (seed,): ([u8; 32],) =
                ic_cdk::call(Principal::management_canister(), "raw_rand", ())
            RNG.with_borrow_mut(|rng| *rng = Some(ChaCha20Rng::from_seed(seed)));

Now I want to test this canister using pocket-ic. RNG don’t seem to be initialized though. Is it the case that pocket-ic doesn’t support timers and/or management canister calls?


PocketIC supports timer and mgmt canister calls, but you need to call tick() a few times to see the effects (on the IC mainnet, it’d also take a few rounds of execution to see the effects). In case, the timer has a positive duration, you might also need to advance time on PocketIC to trigger the timer.


We are facing kind of similar issue with pocket_ic. Does anyone have an idea how to resolve this?

1 Like