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
Testnet Testing (Arbitrum Sepolia)
Setup
-
Get testnet ETH
-
Deploy your contract
- 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
'Insufficient fee' on createDispute
'Insufficient fee' on createDispute
Arbitration cost changes. Always fetch fresh:
Ruling never arrives
Ruling never arrives
- Dispute may still be in voting/appeal period
- Check dispute status on Kleros Court UI
- Testnet disputes can take days if no jurors
Wrong arbitrator address
Wrong arbitrator address
Verify you’re using the correct network’s KlerosCore address. Testnet ≠ mainnet.
Evidence not showing in UI
Evidence not showing in UI
- Check
Evidenceevent 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