Skip to main content

Implementation & testing

It can be tedious to manually recompile the project after every minor change. You can automate the process of recompiling by executing the following command in a separate terminal:

yarn dev

Alternatively to yarn dev you can run typescript in interpreted mode to achieve the same. This is an example using transpile command:

npx ts-node src transpile example_contracts/ERC20.sol

To start developing warp you can pick a task from project issues.

Testing πŸ©Ίβ€‹

Once you've implemented a change you have to test it. Warp includes three sets of tests:

  • Compilation Tests: These tests ensure that transpiled contracts are valid Cairo code.

  • Behaviour Tests: These tests verify the correct functionality of transpiled contracts.

  • Semantic Tests: These tests involve transpiling Solidity's semantic tests and checking that the runtime behaviour remains consistent.

Compilation Tests​

Start by running the compilation tests to verify that your contribution doesn't break any fundamental features. These tests are also the quickest to execute.

yarn test:examples

Behaviour Tests​

Behaviour tests involve transpiling a set of Solidity contracts and deploying them to a testnet. Each deployed contract undergoes testing for all of its runtime functionality.

  1. Run the setup script (Required only once):
tests/behaviour/setup.sh
  1. In a separate terminal, start a StarkNet testnet server (make sure cairo-lang is installed in the environment):
yarn testnet
  1. Run the tests:
yarn test

To generate benchmarks locally during development:

yarn testnet:benchmark
yarn test
python starknet-testnet/generateMarkdown.py

This saves the benchmarks at benchmark/stats/data.md

Semantic Tests​

Semantic tests involve transpiling each of Solidity's behaviour tests and deploying them. Each test is executed, and its result is compared to the output of its Solidity counterpart.

Execute instructions 1 and 2 from Behaviour Tests if you haven't already. Then:

  1. Run semantic tests:
yarn test:semantic