Skip to main content

Overview

NullGraph uses Anchor’s testing framework with TypeScript and Mocha to verify the full protocol lifecycle. The test suite covers protocol initialization, NKA submission, bounty creation, submission matching, approval, and closure.

Running Tests

Run tests against a local Solana validator that starts and stops automatically:
This command:
  1. Starts a local Solana validator
  2. Deploys the program
  3. Runs all tests in tests/nullgraph.ts
  4. Stops the validator after completion
The local validator provides a clean, isolated testing environment and is the recommended approach for development.

Existing Devnet Deployment

Run tests against an existing devnet deployment (skips local validator):
Testing against devnet requires devnet SOL and will execute real transactions on the devnet cluster.

Test Suite Coverage

The test suite in tests/nullgraph.ts covers the complete protocol lifecycle:

Phase 1: Protocol Initialization

Verifies:
  • ProtocolState singleton created with correct authority
  • Counters initialized at zero
  • Fee rate set to 250 basis points (2.5%)
  • Treasury address configured
  • Duplicate initialization rejected (PDA already exists)

Phase 2: Null Knowledge Asset Submission

Verifies:
  • NullResult PDA created with all metadata fields
  • Auto-incrementing specimen number (NKA-0001, NKA-0002, etc.)
  • Global nka_counter increments correctly
  • Multiple researchers can submit independently
  • Data hash stored correctly (SHA-256 fingerprint)

Phase 3: Bounty Marketplace

1

Bounty Creation + Escrow

Verifies: Bounty PDA and vault created, BIO tokens escrowed, counter increments
2

Bounty Submission

Verifies: BountySubmission PDA created, bounty transitions to Matched
3

Invalid Submission Rejection

Verifies: Cannot submit to already-matched bounty (status guard)
4

Approval + Payout

Verifies: 97.5% to researcher, 2.5% to treasury, vault emptied, statuses updated
5

Bounty Closure + Refund

Verifies: Full vault balance returned to creator, bounty status becomes Closed
6

Close Fulfilled Bounty Rejection

Verifies: Cannot close already-fulfilled bounty (status guard)

Test Coverage Summary

Test Data Setup

The test suite uses mock SPL tokens to simulate BIO token transfers:
All token operations use the SPL Token Interface (@solana/spl-token), ensuring compatibility with any SPL-compliant token including BIO.

Running Specific Tests

To run a specific test by name:
To run tests with verbose output:

Test Scripts

The root package.json defines test scripts:
  • npm test - Run all tests with 1000-second timeout
  • npm run lint - Check code formatting
  • npm run lint:fix - Auto-fix formatting issues

Next Steps