Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install PocketIC server
uses: dfinity/pocketic@main
with:
pocket-ic-server-version: "9.0.1"
pocket-ic-server-version: "10.0.0"

- name: Create python environment and run tests and examples
run: |
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## 3.1.1 - 2025-09-12

### Added
- Support for PocketIC server version 10.0.0



## 3.1.0 - 2025-04-28

### Added
Expand Down
1 change: 0 additions & 1 deletion pocket_ic/subnet_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def _json(self) -> dict:
"verified_application": self.verified_application,
},
"state_dir": self.state_dir,
"nonmainnet_features": False,
"log_level": None,
"bitcoind_addr": None,
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pocket_ic"
version = "3.1.0"
version = "3.1.1"
description = "PocketIC: A Canister Smart Contract Testing Platform"
authors = [
"The Internet Computer Project Developers <dept-testing_&_verification@dfinity.org>",
Expand Down
51 changes: 35 additions & 16 deletions tests/pocket_ic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,32 +202,51 @@ def test_store_restore_state(self):
self.assertEqual(stable_mem2, stable_mem)
self.assertEqual(len(pic2.topology()), 2)

# delete the PocketIC instance
del pic2

# create a new PocketIC instance with only the app subnet copied over
config3 = SubnetConfig()
# clean up
shutil.rmtree(tmp_dir)

# get the app subnet's folder from the state directory
with open(os.path.join(tmp_dir, "topology.json"), "r") as f:
dirs = json.load(f)["subnet_configs"].items()
def test_add_subnet_with_state(self):
# create a PocketIC instance with a state directory
tmp_dir = tempfile.mkdtemp()
config = SubnetConfig(application=1, state_dir=tmp_dir)
pic = PocketIC(config)

# find the app subnet's folder
app_subnet_key = [
k
for k, v in dirs
if v["subnet_config"]["subnet_kind"] == SubnetKind.APPLICATION.value
][0]
# create a canister on app subnet
canister_id = pic.create_canister()
pic.add_cycles(canister_id, 20_000_000_000_000)
pic.install_code(canister_id, b"\x00\x61\x73\x6d\x01\x00\x00\x00", [])

config3.add_subnet_with_state(
# set stable memory of the canister
pic.set_stable_memory(canister_id, b"Hello world!")
stable_mem = pic.get_stable_memory(canister_id)
self.assertTrue(stable_mem.startswith(b"Hello world!"))

# delete the PocketIC instance
del pic

# create a new PocketIC instance with only the app subnet restored from state
config2 = SubnetConfig()

# get the app subnet's folder from the state directory
# (the app subnet's folder is the only subfolder in the state directory)
subfolders = [d for d in os.listdir(tmp_dir) if os.path.isdir(os.path.join(tmp_dir, d))]
self.assertEqual(len(subfolders), 1)
app_subnet_key = subfolders[0]

# add the app subnet with its state
config2.add_subnet_with_state(
SubnetKind.APPLICATION,
os.path.join(tmp_dir, app_subnet_key),
)

# app subnet canister stays, NNS subnet is not there
pic3 = PocketIC(config3)
stable_mem3 = pic3.get_stable_memory(canister_id)
self.assertEqual(stable_mem3, stable_mem2)
self.assertEqual(len(pic3.topology()), 1)
pic2 = PocketIC(config2)
stable_mem2 = pic2.get_stable_memory(canister_id)
self.assertEqual(stable_mem2, stable_mem)
self.assertEqual(len(pic2.topology()), 1)

# clean up
shutil.rmtree(tmp_dir)
Expand Down