Clone the repository and install dependencies:
flow deps installRun lint & tests:
make lint
make testcadence/transactions/andcadence/scripts/— production transactions and scripts onlycadence/tests/transactions/andcadence/tests/scripts/— test-only helpers, not for production use
Tests live in cadence/tests/ as *_test.cdc files.
Use the snapshot pattern to reset blockchain state between tests without redeploying contracts:
import Test
import BlockchainHelpers
access(all) var snapshot: UInt64 = 0
access(all) fun beforeEach() {
if snapshot != getCurrentBlockHeight() {
Test.reset(to: snapshot)
}
}
access(all) fun setup() {
// deploy contracts
// setup code every test case needs
snapshot = getCurrentBlockHeight()
}