Code Monkey home page Code Monkey logo

pocketic-py's Introduction

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. To see a minimalistic setup of PocketIC in a Motoko project, check out the ICP Hello World Motoko repository.

Documentation

Contributing

See CONTRIBUTING.md

pocketic-py's People

Contributors

basvandijk avatar dependabot[bot] avatar fxgst avatar michael-weigelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pocketic-py's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.