Summary
- Local testing validates core logic; staging validates real-world behavior
- Deploy to staging early to catch false positives and edge cases
- Real transactions expose scenarios that are difficult to predict locally
- Use backtesting to debug specific transactions with the smallest feedback loop
The Testing Philosophy
The most effective approach to assertion development prioritizes staging over exhaustive local testing. In staging, assertions run against real transactions on a mirrored environment but don’t drop transactions—allowing you to observe behavior safely. In production, assertions actively prevent violations by dropping invalid transactions. Real-world transactions reveal edge cases that would take significant effort to anticipate and mock locally. Why local testing has limits:- You can only think of so many test cases manually
- Complex protocol states are difficult to reproduce
- Setting up realistic testing environments for multi-protocol interactions is time-consuming
- Real usage patterns and transaction diversity
- Edge cases emerge organically from actual user behavior
- Weeks of staging exposure reveals issues that extended local testing might miss
How to Allocate Your Time
| Phase | Effort | Goal |
|---|---|---|
| Local testing | ~20-30% | Validate core logic, catch obvious bugs, verify gas limits |
| Backtesting | ~10-20% | Sanity check before staging; debug specific transactions after |
| Staging | ~50-60% | Discover edge cases, observe real-world behavior, iterate |
What to Test Locally
Focus local testing on:- Happy paths: Verify assertions pass on valid transactions
- Known violation scenarios: Verify assertions catch the specific violations you designed for
- Gas limits: Ensure assertions stay within the 300k gas limit, especially on the happy path (which typically uses more gas since all checks run to completion)
- Exhaustive edge case enumeration
- Complex multi-protocol interaction scenarios
- Simulating every possible user behavior
See Testing Assertions for local testing patterns and Gas Limits for gas considerations.
Backtesting: Two Key Uses
Backtesting serves two distinct purposes in the development workflow:1. Pre-Staging Sanity Check
Before deploying to staging, run a quick backtest against recent transactions:- Verifies no obvious false positives on normal protocol operations
- Catches trigger mismatches (assertion not running when expected)
- Identifies gas issues with realistic transaction complexity
2. Debugging Staging Issues
When staging reveals unexpected behavior, backtesting becomes your debugging tool:- Replay the specific transaction that triggered the issue locally
- Step through assertion logic with full visibility
- Fastest feedback loop for debugging
See Backtesting for configuration and usage details.
The Staging Workflow
Deploy Early
Once local tests pass and backtesting shows no obvious issues, deploy to staging. Don’t wait for “perfect” local coverage—staging will reveal what you missed. Note that deployments have a timelock period before assertions become active, so starting early is beneficial.Monitor Staging Behavior
Check the dApp dashboard regularly for assertion execution status and enable incident notifications to get alerted via Slack or PagerDuty. Look for:- False positives on legitimate operations
- Unexpected assertion behavior or edge cases
Debug with Backtesting
When an issue appears in staging:- Identify the transaction that triggered unexpected behavior
- Use backtesting to replay that exact transaction locally
- Debug with full visibility into assertion execution (
-vvvv) - Fix the issue and redeploy
Recommended Staging Duration
- Minimum: 1-2 weeks before considering production
- High-traffic protocols: More transactions means faster feedback
- Low-traffic protocols: May need longer staging periods
When to Move to Production
Before promoting to production, verify:- No false positives observed on legitimate transactions
- Sufficient transaction diversity to build confidence
- You understand how the assertion behaves across different scenarios

