From d1c9b667d03630030f55d9e2970371afb05092c5 Mon Sep 17 00:00:00 2001 From: Elias Datler Date: Fri, 3 Nov 2023 17:02:53 +0000 Subject: [PATCH] add doc --- pocket_ic/pocket_ic.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pocket_ic/pocket_ic.py b/pocket_ic/pocket_ic.py index 706fe8b..8a3411b 100644 --- a/pocket_ic/pocket_ic.py +++ b/pocket_ic/pocket_ic.py @@ -129,14 +129,28 @@ def add_cycles(self, canister_id: ic.Principal, amount: int) -> int: return self._instance_post("update/add_cycles", body)["cycles"] def get_stable_memory(self, canister_id: ic.Principal) -> bytes: + """Gets the stable memory of a canister. + + Args: + canister_id (ic.Principal): the ID of the canister + + Returns: + bytes: the stable memory of the canister + """ body = { "canister_id": base64.b64encode(canister_id.bytes).decode(), } response = self._instance_post("read/get_stable_memory", body) return base64.b64decode(response["blob"]) - def set_stable_memory(self, canister_id: ic.Principal, data: bytes, compression = None) -> None: + """Sets the stable memory of a canister. + + Args: + canister_id (ic.Principal): the ID of the canister + data (bytes): the data to set + compression (str, optional): optional gzip compression, efaults to None + """ blob_id = self.server.set_blob_store_entry(data, compression) body = { "canister_id": base64.b64encode(canister_id.bytes).decode(),