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.0.tar.gz (586.9 kB view details)

Uploaded Source

Built Distribution

pocket_ic-2.0.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pocket_ic-2.0.0.tar.gz
  • Upload date:
  • Size: 586.9 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.0.tar.gz
Algorithm Hash digest
SHA256 a66c3fba75f5a77d578fc6151007812157ceefb185168d0ad50019add8655c44
MD5 fff26ee7eaf4d05186638605a832a4f4
BLAKE2b-256 5e2fa7aa23f26bd352cbf5539c9beafb1b8f7e31857c821066a5142d443cfe25

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pocket_ic-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff6a411d4406e5f481f225947af063c4bee279522afc28bb1ae9bc4dd1a64e7a
MD5 c598439a753117c23dcbcd244bff1881
BLAKE2b-256 660478cbc02e505efddb3c9add8f9a818fce686f8fd1aca0bcacd0b8316d9e83

See more details on using hashes here.

Provenance

Supported by

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