Skip to main content

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_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!

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


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-1.0.1.tar.gz (584.4 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-1.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

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

Hashes for pocket_ic-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c64cc5df65f63883a27719a9e76565f337571cba9e6fba2a82a98498786563cf
MD5 4415dc22265747b954675e20400c4b43
BLAKE2b-256 cc5f755f5fce03a39d0d94195e1a98b30ed0268989c36c0cd3f7c6d743b4277d

See more details on using hashes here.

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

Hashes for pocket_ic-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c4400bc72662d6fa5ac5b348706b62c9317ceee73f4c02e10f04ea64460c684
MD5 f72cfc5f1c7da693f23c059b72f95f8a
BLAKE2b-256 6ea0f529ce9396c2f39634a2651b870bb8a0fe482e9f687b6734b5b5805bac63

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