Skip to content

Commit b94390a

Browse files
authored
fix(PocketIC): Support for new server version 2.0.1 (#52)
- Support for PocketIC server version 2.0.1 - When the PocketIC binary is not found, the error now points to the PocketIC repo instead of the download link
1 parent 3629dbd commit b94390a

File tree

7 files changed

+27
-48
lines changed

7 files changed

+27
-48
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9+
## 2.0.1 - 2023-11-23
10+
11+
### Added
12+
- Support for PocketIC server version 2.0.1
13+
14+
15+
### Changed
16+
- When the PocketIC binary is not found, the error now points to the PocketIC repo instead of the download link
17+
18+
19+
920
## 2.0.0 - 2023-11-21
1021

1122
### Added

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
66
flake-utils.url = "github:numtide/flake-utils";
77
pocket-ic-darwin-gz = {
8-
url = "https://download.dfinity.systems/ic/29ec86dc9f9ca4691d4d4386c8b2aa41e14d9d16/openssl-static-binaries/x86_64-darwin/pocket-ic.gz";
8+
url = "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-darwin/pocket-ic.gz";
99
flake = false;
1010
};
1111
pocket-ic-linux-gz = {
12-
url = "https://download.dfinity.systems/ic/29ec86dc9f9ca4691d4d4386c8b2aa41e14d9d16/openssl-static-binaries/x86_64-linux/pocket-ic.gz";
12+
url = "https://download.dfinity.systems/ic/69e1408347723dbaa7a6cd2faa9b65c42abbe861/openssl-static-binaries/x86_64-linux/pocket-ic.gz";
1313
flake = false;
1414
};
1515
};

pocket_ic/pocket_ic.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -316,22 +316,6 @@ def create_canister(
316316
Returns:
317317
ic.Principal: the ID of the created canister
318318
"""
319-
320-
if canister_id:
321-
subnet_id = self.get_subnet(canister_id)
322-
if not subnet_id:
323-
raise ValueError("Canister ID not contained in any subnet")
324-
325-
topology = {k.to_str(): v for k, v in self.topology.items()}
326-
subnet_kind = topology[subnet_id.to_str()]
327-
if (
328-
subnet_kind == SubnetKind.APPLICATION
329-
or subnet_kind == SubnetKind.SYSTEM
330-
):
331-
raise ValueError(
332-
"Creating a canister with ID is only supported on Bitcoin, Fiduciary, II, SNS and NNS subnets"
333-
)
334-
335319
record = Types.Record(
336320
{
337321
"settings": Types.Opt(

pocket_ic/pocket_ic_server.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ def __init__(self) -> None:
4242
The PocketIC binary could not be found at "{bin_path}". Please specify the path to the binary with the POCKET_IC_BIN environment variable, \
4343
or place it in your current working directory (you are running PocketIC from {os.getcwd()}).
4444
45-
Run the following commands to get the binary:
46-
curl -sLO https://download.dfinity.systems/ic/29ec86dc9f9ca4691d4d4386c8b2aa41e14d9d16/openssl-static-binaries/x86_64-$platform/pocket-ic.gz
47-
gzip -d pocket-ic.gz
48-
chmod +x pocket-ic
49-
where $platform is 'linux' for Linux and 'darwin' for Intel/rosetta-enabled Darwin.
45+
To download the binary, please visit https://github.com/dfinity/pocketic.
5046
"""
5147
)
5248

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pocket_ic"
3-
version = "2.0.0"
3+
version = "2.0.1"
44
description = "PocketIC: A Canister Smart Contract Testing Platform"
55
authors = [
66
"The Internet Computer Project Developers <dept-testing_&[email protected]>",

tests/pocket_ic_test.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,6 @@
1313

1414

1515
class PocketICTests(unittest.TestCase):
16-
def test_create_canister_with_id_failures(self):
17-
pic = PocketIC(SubnetConfig(application=1))
18-
existing_canister_id = pic.create_canister()
19-
with self.assertRaises(ValueError) as ex:
20-
pic.create_canister(canister_id=existing_canister_id)
21-
self.assertEqual(
22-
ex.exception.args[0],
23-
"Creating a canister with ID is only supported on Bitcoin, Fiduciary, II, SNS and NNS subnets",
24-
)
25-
26-
pic = PocketIC(SubnetConfig(nns=True))
27-
canister_id = ic.Principal.anonymous()
28-
with self.assertRaises(ValueError) as ex:
29-
pic.create_canister(canister_id=canister_id)
30-
self.assertEqual(
31-
ex.exception.args[0], "Canister ID not contained in any subnet"
32-
)
33-
3416
def test_create_canister_with_id(self):
3517
pic = PocketIC(SubnetConfig(nns=True))
3618
canister_id = ic.Principal.from_str("rwlgt-iiaaa-aaaaa-aaaaa-cai")
@@ -49,6 +31,12 @@ def test_create_canister_with_id(self):
4931
new_canister_id = pic.create_canister()
5032
self.assertNotEqual(new_canister_id.bytes, canister_id.bytes)
5133

34+
# Creating a canister with an ID that is not hosted by any subnet fails.
35+
canister_id = ic.Principal.anonymous()
36+
with self.assertRaises(ValueError) as ex:
37+
pic.create_canister(canister_id=canister_id)
38+
self.assertIn("CanisterNotHostedBySubnet", ex.exception.args[0])
39+
5240
def test_large_config_and_deduplication(self):
5341
pic = PocketIC(
5442
SubnetConfig(

0 commit comments

Comments
 (0)