Skip to content

A unified framework for Cardano Smart Contract testing and benchmarking m

Notifications You must be signed in to change notification settings

OpShin/plutus-bench

Repository files navigation

A person with the Cardano logo as face, lifting heavy weights

Plutus-Bench

Test and benchmark Plutus Smart Contracts. This project enables you to construct entire smart contract transactions against a mock environment, and measure the correctness (i.e. unit test) and performance of your smart contracts.

Plutus Bench creates a mock ledger with an arbitrary UTxO set specified by the user. It then hosts a mock blockfrost API to interact with the ledger, supporting popular off-chain tooling like translucent and pycardano.

Note: Plutus Bench is currently a Work In Progress, and is not yet ready for production use.

Why Plutus Bench?

  • Compatability: Plutus Bench is written in Python, and is compatible with popular off-chain tooling relying on BlockFrost APIs. Ogmios mocking is also planned.
  • Holistic Testing: Plutus Bench allows you to test the entire lifecycle of a smart contract, from minting to consuming, in a single test.
  • Simple: Plutus Bench is designed to be simple to use, and easy to integrate with your existing infrastructure.

Installation and running

# install the plutus-bench package
git clone https://github.com/OpShin/plutus-bench.git
cd plutus-bench
# install the package
pip install .
# run the mock server
uvicorn plutus_bench.mockfrost.server:app 

After running these commands, a mock blockfrost server will be running on http://localhost:8000. Head to http://localhost:8000/docs to see the API documentation.

Usage

Generally the workflow is as follows:

  • Create a new session with the /session/create endpoint. You receive a session ID.
  • Initialize a BlockFrost client in your off-chain code, and point it to the mock server. The base url is http://localhost:8000/<session-id>/api/v1. Project id is not required.

That's it! You can now interact with the mock ledger using the BlockFrost client.

You may further manipulate the ledger using the /<session-id>/ledger endpoints.

Similar Projects

What about the language comparison?

The language comparison has been moved to contest. It is planned to expand to cover different implementations of the same contract in different languages and the same language, tailored for performance optimizations.

About

A unified framework for Cardano Smart Contract testing and benchmarking m

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •