Skip to main content

Usage

The contract test suite validates all stablecoin functionality against a live Hedera network (testnet or local). Tests follow the arrange-act-assert pattern and are fully self-contained, so they can run in any order or in parallel.


Configuration

Test Accounts

Create a .env file from .env.example and configure two Hedera accounts:

# Private keys in RAW format (not DER)
TESTNET_PRIVATE_KEY_0='0x...'
TESTNET_PRIVATE_KEY_1='0x...'

Both accounts must exist on the target Hedera network and have enough HBAR to cover contract deployments, token creations, and invocations.

AccountVariableRole in Tests
OperatorPRIVATE_KEY_0Deploys the stablecoin, has full rights
Non-operatorPRIVATE_KEY_1No rights unless explicitly granted during the test

Running Tests

All Tests

npm test

Parallel Execution

npm run test:parallel

Tests are organized into two parallel threads (test/Thread0/ and test/Thread1/) for faster CI execution.

Specific Test File

npm run test:kyc

Build and Compile

Before running tests, ensure contracts are compiled:

npm run compile          # Compile modified contracts only
npm run compile:force # Force recompile all contracts and build package
npm run build # Build package without recompiling

Compilation generates a build/typechain-types/ folder with TypeScript bindings:

import { hederaTokenManager__factory } from '@hashgraph/stablecoin-npm-contracts/typechain-types';

Other Commands

CommandDescription
npm run sizeCheck contract sizes in KiB
npm run lint:solLint Solidity code
npm run lint:tsLint TypeScript code
npm run lintLint Solidity and TypeScript
npm run prettierFormat all code
npm run pre-commitRun prettier and lint
npm run slitherRun Slither security analysis
npm run docGenerate contract documentation in Markdown