This repository contains an example project for testing a simple adder
contract using the Komet tool. Komet is a property testing and verification tool for Soroban smart contracts, allowing developers to write property-based tests and run them via fuzzing or symbolic execution.
The project consists of two contracts:
adder
: A simple contract that takes two numbers and returns their sum.test_adder
: A test contract for theadder
contract, using Komet for testing and verification.
.
├── contracts
│ ├── adder
│ │ ├── src
│ │ │ └── lib.rs
│ │ └── Cargo.toml
│ └── test_adder
│ ├── src
│ │ ├── lib.rs
│ │ └── komet.rs
│ ├── Cargo.toml
│ └── kasmer.json
├── Cargo.toml
└── README.md
Komet can be installed using the kup
package manager. To install kup
, run the following command:
bash <(curl https://kframework.org/install)
Once kup
is installed, you can install Komet by running:
kup install komet
After installation, verify it by checking the help menu:
komet --help
Navigate to the root directory of the project and build the contracts using the following command:
soroban contract build
Change directories into the test_adder
contract folder:
cd contracts/test_adder/
To run the tests using fuzzing, execute the following command:
komet test
This will run the test with randomized inputs.
To run the tests using symbolic execution, use this command:
komet prove run
To see more options for proving (such as saving proof data or viewing the proof tree), use:
komet prove --help