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)  # 2T cycles
pic.install_code(...)

# make canister calls
response = pic.update_call(canister_id, method="greet", ...)
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
response = my_canister.greet()
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.2.tar.gz (586.7 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.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file pocket_ic-2.0.2.tar.gz.

File metadata

  • Download URL: pocket_ic-2.0.2.tar.gz
  • Upload date:
  • Size: 586.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for pocket_ic-2.0.2.tar.gz
Algorithm Hash digest
SHA256 76420edfa351f38cd33ed8dd18bc53b6879ad12c2f1043d8d431c49ca12c16fb
MD5 780d392a03576ca2179c9864acea1604
BLAKE2b-256 0aef0830e9a1ea50b4d488f8a73095cfd52eec84ff0dd142f4457c54a8c0776a

See more details on using hashes here.

File details

Details for the file pocket_ic-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: pocket_ic-2.0.2-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.7

File hashes

Hashes for pocket_ic-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e88593bad151a67cc3eca35657d3a19dfb1ac19d26676a30e85d6c95ce55b09
MD5 06844c89c297015eb26611c6bdf71fce
BLAKE2b-256 d50cff3b2017bb2de1f0d8f2ec6e126279faa4e04f3530394cee922703ff8ccf

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