PocketIC persistent state?

Can PocketIC store deployed canisters, stable memory and network topology between restarts?

For example I’ve started PocketIC server and set up some network topology T, also I’ve deployed canister A and canister B, and filled the stable memory. Then I’ve stopped the PocketIC server.
Is it possible to start it with already deployed canister A and B, and persisted stable memory (or even general memory) from the last run?

Where does PocketIC store it’s state? If a current versions of DFX uses PocketIC how DFX solves storing state between restarts?

I found nothing in a docs and on the forum

UPD:
I’ve found with_state and with_state_dir functions in client library sources: ic/packages/pocket-ic/src/lib.rs at master · dfinity/ic · GitHub

But there are absolutely no documentation. Can anybody explain how to use it?

When using the PocketIC Rust library, you can create a PocketIC instance with the with_state_dir method, as described in the Persisting state of a PocketIC instance.
This way, you can specify the path you want PocketIC to persist the state to.

3 Likes

There are tutorials on how to use common features.

1 Like

Thank you pointing the Persisting state of a PocketIC instance chapter. Missed this chapter in tutorial.

Moreover it saves and restores topology when state_dir is provided and uses it, but not from new instance create request parameters.