This document describes the current state of the organization of integration tests, along with info on how to run them.
There are commands provided in the Makefile
to make running them easier. To run the current integration test, you should run:
# This will ensure we start from a clean node and client
make reset
# This command will clone the node's repo and generate the accounts and genesis files and lastly start the node and run it on background
make start-node &
# This will run the integration test
make integration-test
# After tests are done, we can kill the node process
make kill-node
The integration test goes through a series of supported flows such as minting and transferring assets which runs against a running node.
Before running the tests though, there is a setup we need to perform to have a
node up and running. This is accomplished with the node
command from the
Makefile
and what it does is:
- Clone the node repo if it doesn't exist.
- Delete previously existing data.
- Generate genesis and account data with
cargo run --release --bin miden-node --features testing -- make-genesis --inputs-path node/genesis.toml
.
After that we can start the node, again done in the start-node
command from the Makefile
To run the integration test you just need to run make integration-test
. It'll
run the rust binary for the integration test and report whether there was an
error or not and the exit code if so. Lastly it kills the node's process.
The current integration test at ./integration/main.rs
goes through the following steps:
- Wait for the node to be reachable (this is mainly so you can run
make start-node
andmake integration-test
in parallel without major issues). This is done with a sync request, although in the future we might use a health check endpoint or similar. - Load accounts (1 regular A, 1 faucet C) created with the
make-genesis
command of the node - Create an extra regular account C
- Sync up the client
- Mint an asset (this creates a note for the regular account A) and sync again
- Consume the note and sync again. (After this point the account A should have an asset from faucet C)
- Run a P2ID transaction to transfer some of the minted asset from account A to B. Sync again
- Consume the P2ID note for account B. Now both accounts should have some of asset from faucet C
- A double-spend is attempted to check that the client does not allow this
In short, we're testing:
- Account importing.
- Account creation.
- Sync and entity tracking.
- Mint tx.
- Consume note tx (both for an imported and a created account).
- P2ID tx.
There is a step for the CI at ../.github/workflows/ci.yml
used to run the integration tests.