developer
Testing
Test suite and development workflow
Test Suite#
Mini Veil uses ts-mocha with Chai assertions. Run all tests:
# From project root
yarn test
# Or with Anchor
anchor test
Test Structure#
Tests are in the tests/ directory at the project root. Each file covers a specific protocol area:
Day 1: Core Infrastructure#
ts-mocha tests/day1.ts
- Key generation via
@mini-veil/core(generateVeilKeys) - On-chain key registration (
register_keys) - 2-of-3 multisig initialization and root updates (
update_root) - Mixer pool initialization
Day 2: Full Mixer Lifecycle#
ts-mocha tests/day2.ts
- Init pool for each denomination
- Shield (deposit) with commitment
- Admin root update (pre-multisig)
- Unshield with Groth16 proof verification
- Double-spend prevention (replay same nullifier)
- Recipient binding (wrong address rejected)
- Wrong denomination rejection
- Wrong Merkle root rejection
- Multiple deposits and withdrawals
Day 3: Encrypted Transfer Accounts (ETA)#
ts-mocha tests/day3.ts
ts-mocha tests/day3_simple.ts
- ETA creation with encrypted zero balance
- Balance updates with Groth16 proof (1 SOL → 0.5 SOL)
- Tampered ciphertext rejection
- Over-withdrawal rejection
- Non-owner signer rejection
- Encryption/decryption roundtrip validation
Day 4: Stealth Addresses#
ts-mocha tests/day4.ts
ts-mocha tests/day4-compressed.ts
- Stealth address generation and key derivation consistency
- Full send: shield → unshield → announce → scan → claim
- View tag filtering
- Multiple stealth payments
- Wrong viewing key rejection
- KeyRegistry integration
- Compressed nullifier variant with cost comparison (~0.000875 SOL savings)
Day 5: SPL Tokens#
ts-mocha tests/day5.ts
ts-mocha tests/day5-compressed.ts
ts-mocha tests/day5-webhook.ts
- Token mixer initialization
- SPL token deposit and withdrawal with Groth16 proof
- Compressed nullifier for tokens
- Helius webhook relayer integration
- Deposit event parsing and root update triggers
Test Configuration#
From Anchor.toml:
[scripts]
test = "yarn ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
Tests use a 1,000,000ms timeout (16.7 minutes) to accommodate proof generation and on-chain confirmation.
Development Workflow#
Local Validator#
solana-test-validator
Deploy Program#
anchor build
anchor deploy
Start Relayer#
cd packages/relayer
npm run start
Start Frontend#
cd packages/frontend
npm run dev
All-in-One#
./dev.sh
Writing New Tests#
Tests use Anchor's ProgramTest or direct Provider interaction:
import * as anchor from "@coral-xyz/anchor";
import { expect } from "chai";
import { createDeposit, generateWithdrawalProof, packG1, packG2, packPublicSignals } from "../packages/core/src/mixer";
describe("my test", () => {
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const program = anchor.workspace.MiniVeil as anchor.Program;
it("does something", async () => {
// ... test logic
});
});