diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64544b8..f7f208f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: | diff --git a/CHANGELOG.md b/CHANGELOG.md index 473484d..b8158ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pocket_ic/subnet_config.py b/pocket_ic/subnet_config.py index feb41fc..9b01dec 100644 --- a/pocket_ic/subnet_config.py +++ b/pocket_ic/subnet_config.py @@ -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, } diff --git a/pyproject.toml b/pyproject.toml index 30c73ce..aa680bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ", diff --git a/tests/pocket_ic_test.py b/tests/pocket_ic_test.py index 2260b92..1bcac5e 100644 --- a/tests/pocket_ic_test.py +++ b/tests/pocket_ic_test.py @@ -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)