A canister testing library
Project description
PocketIC: A Canister Testing Platform
PocketIC is a local canister testing platform for the Internet Computer.
It consists of the PocketIC binary, which handles different IC instances, and a Python library (this repo) which allows you to interact with your local IC instances and the canisters thereon.
With PocketIC, you can test your canisters with just a few lines of Python code, either by interacting with an IC instance:
from pocket_ic import PocketIC
pic = PocketIC()
canister_id = pic.create_canister()
# use PocketIC to interact with your canisters
pic.add_cycles(canister_id, 1_000_000)
response = pic.update_call(canister_id, method="greeting", ...)
assert(response == 'Hello, PocketIC!')
... or even directly with a canister object:
my_canister = pic.create_and_install_canister_with_candid(...)
# call your canister functions with native Python syntax
respone = my_canister.greeting()
assert(response == 'Hello, PocketIC!')
Getting Started
Quickstart
- Download the PocketIC binary for Linux or macOS, unzip and make it executable.
- Leave the binary in your current working directory, or specify the path to the binary by setting the
POCKET_IC_BINenvironment variable before running your tests. - Run
pip3 install pocket-icin your (virtual) environment to get the Python library. - Use
from pocket_ic import PocketICin your Python code and start testing!
For a more detailed installation guide, see INSTALLATION.md.
Examples
To see some working code, see the examples/ folder, or check out the how to use this library guide.
To run an example, clone this repo and run python3 examples/counter_canister/counter_canister_test.py from the repository's root directory.
Documentation
Contributing
See CONTRIBUTING.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pocket_ic-1.0.1.tar.gz.
File metadata
- Download URL: pocket_ic-1.0.1.tar.gz
- Upload date:
- Size: 584.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c64cc5df65f63883a27719a9e76565f337571cba9e6fba2a82a98498786563cf
|
|
| MD5 |
4415dc22265747b954675e20400c4b43
|
|
| BLAKE2b-256 |
cc5f755f5fce03a39d0d94195e1a98b30ed0268989c36c0cd3f7c6d743b4277d
|
File details
Details for the file pocket_ic-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pocket_ic-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c4400bc72662d6fa5ac5b348706b62c9317ceee73f4c02e10f04ea64460c684
|
|
| MD5 |
f72cfc5f1c7da693f23c059b72f95f8a
|
|
| BLAKE2b-256 |
6ea0f529ce9396c2f39634a2651b870bb8a0fe482e9f687b6734b5b5805bac63
|