Skip to main content

Testing Strategy

Testing arbitrable contracts requires simulating the full dispute lifecycle. You can’t just unit test you need to interact with Kleros contracts.

Unit Testing with Mock Arbitrator

Create a minimal mock to test your contract’s logic:

Foundry Test Example

Run with:

Testnet Testing (Arbitrum Sepolia)

Setup

  1. Get testnet ETH
  2. Deploy your contract
  3. Verify contract addresses Check kleros-v2 deployments for testnet addresses.

Creating a Test Dispute

Monitoring Dispute Progress

Test Scenarios Checklist

Happy Path

  • Create transaction
  • Raise dispute with correct fee
  • Evidence submission emits event
  • Ruling executes correct outcome
  • Funds transfer to correct party

Edge Cases

  • Insufficient arbitration fee reverts
  • Non-party cannot raise dispute
  • Cannot dispute already-disputed transaction
  • Cannot rule on non-existent dispute
  • Ruling 0 (refuse to rule) handled correctly
  • Excess fee is refunded

Security

  • Only arbitrator can call rule()
  • Cannot call rule() twice
  • Invalid ruling value reverts
  • Reentrancy protection works

Gas Optimization

  • Measure gas for createDispute()
  • Measure gas for rule() with transfer
  • Compare with/without evidence submission

Debugging Tips

Common Issues

Arbitration cost changes. Always fetch fresh:
  • Dispute may still be in voting/appeal period
  • Check dispute status on Kleros Court UI
  • Testnet disputes can take days if no jurors
Verify you’re using the correct network’s KlerosCore address. Testnet ≠ mainnet.
  • Check Evidence event was emitted with correct _evidenceGroupID
  • Verify JSON is valid
  • IPFS content may take time to propagate

Event Debugging

Mainnet Fork Testing

Test against production state without spending real ETH:

Next Steps

Production Checklist

Pre-deployment security and operational checklist