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 an alternative path with the POCKET_IC_BIN environment variable.
  • Run python3 -m pip 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.0.tar.gz (584.3 kB view details)

Uploaded Source

Built Distribution

pocket_ic-1.0.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pocket_ic-1.0.0.tar.gz
  • Upload date:
  • Size: 584.3 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.0.tar.gz
Algorithm Hash digest
SHA256 9e4578339d63f57c607830037092c62cfddbb212547e04b03ddd90d9de719cee
MD5 a719ce3d119fec02f0158d053674875d
BLAKE2b-256 c56e9cd782172818dc9259acde1df6aa080406ea3aa2ba360969bee250f31360

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: pocket_ic-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 682dd9ca6b78f6cfc21ff955f61457f6b5c5cc54296d03a7e51fd1d497978510
MD5 a386c529450ea74e42c9eb0d68008cf8
BLAKE2b-256 91053c810baf6bb57df20b95e2441e096e70e9b213cc5ba594ee4229e555ea53

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