Skip to main content
This guide covers testing your ZKP2P integrations and understanding the protocol’s test suite.

Overview

The zkp2p-contracts project includes:
  • Hardhat tests: TypeScript-based integration and unit tests
  • Foundry tests: Solidity-based fuzz and invariant tests
  • Test utilities: Helpers for common testing patterns
  • Mock contracts: Simulated external dependencies

Running Protocol Tests

Hardhat Tests

Foundry Tests

Testing Your Integration

Local Development Setup

1

Clone and install

2

Configure environment

3

Start local node

4

Get contract addresses

Testing Deposit Creation

Testing Intent Flow

Testing Custom Hooks

Test Utilities

The protocol provides helpful test utilities:

Intent Hash Calculation

Mock Signatures

Signal Intent Helper

Common Test Patterns

Time Manipulation

Event Testing

Revert Testing

Continuous Integration

Tests run automatically on GitHub Actions:

Coverage Reports

View coverage at codecov.io:
  • Overall coverage: >95%
  • Escrow.sol: 100%
  • Orchestrator.sol: 100%
  • UnifiedPaymentVerifier.sol: 100%

Best Practices

Test Reverts

Always test failure cases and revert conditions, not just happy paths.

Use Beforehooks

Setup common state in beforeEach to keep tests isolated and maintainable.

Check Events

Verify events are emitted with correct parameters for all state changes.

Fuzz Important Functions

Use Foundry fuzz tests for functions with complex input validation.

Resources

Hardhat Docs

Complete Hardhat documentation and guides

Foundry Book

Comprehensive Foundry testing guide

Chai Matchers

Waffle/Chai assertion matchers for Ethereum

Test Repository

Browse the full test suite on GitHub