Skip to main content

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_BIN environment variable before running your tests.
  • Run pip3 install pocket-ic in your (virtual) environment to get the Python library.
  • Use from pocket_ic import PocketIC in 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pocket_ic-2.0.1.tar.gz (586.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pocket_ic-2.0.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

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

Hashes for pocket_ic-2.0.1.tar.gz
Algorithm Hash digest
SHA256 3dddc5ef56e75fccd227f17f94d81f0973d43af3507e6841af1fafb365c9b884
MD5 2429ce589254c4d25b6e476cab27f8da
BLAKE2b-256 c943533119e7c91fead3bb091e02808aad7a6de10f074b505132ecdb32decc80

See more details on using hashes here.

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

Hashes for pocket_ic-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 76cdf1d400f3c2760693c2b1a435314ceb4c49432997e2978363b5207b8e3642
MD5 71ec966812a959cd66d08730169f9a77
BLAKE2b-256 87adba0d93ec4b8fc706e04f596c8e03ca166aa978e5d11816c60dddcbc528b2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page