PocketIC: A Canister Smart Contract Testing Platform
Project description
PocketIC Python: A Canister Testing Library
PocketIC is a local canister testing solution for the Internet Computer.
This testing library works together with the PocketIC server, allowing you to interact with your local IC instances and the canisters thereon.
With PocketIC Python, you can test your canisters with just a few lines of code, either by interacting with an IC instance:
from pocket_ic import PocketIC
pic = PocketIC()
canister_id = pic.create_canister()
pic.add_cycles(canister_id, 2_000_000_000_000)
# make canister calls
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 methods with native Python syntax
respone = my_canister.greeting()
assert(response == 'Hello, PocketIC!')
Getting Started
Quickstart
- Download the latest PocketIC server from the PocketIC repo.
- 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!
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-2.0.1.tar.gz.
File metadata
- Download URL: pocket_ic-2.0.1.tar.gz
- Upload date:
- Size: 586.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dddc5ef56e75fccd227f17f94d81f0973d43af3507e6841af1fafb365c9b884
|
|
| MD5 |
2429ce589254c4d25b6e476cab27f8da
|
|
| BLAKE2b-256 |
c943533119e7c91fead3bb091e02808aad7a6de10f074b505132ecdb32decc80
|
File details
Details for the file pocket_ic-2.0.1-py3-none-any.whl.
File metadata
- Download URL: pocket_ic-2.0.1-py3-none-any.whl
- Upload date:
- Size: 12.9 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 |
76cdf1d400f3c2760693c2b1a435314ceb4c49432997e2978363b5207b8e3642
|
|
| MD5 |
71ec966812a959cd66d08730169f9a77
|
|
| BLAKE2b-256 |
87adba0d93ec4b8fc706e04f596c8e03ca166aa978e5d11816c60dddcbc528b2
|