Testing cross-chain apps: the fixtures that catch the rare failure
Cross-chain bugs do not show up in happy-path demos. They hide in reorgs, stalled relays, partial deliveries, and state that diverges between chains while your tests run on a single network. Testing a cross-chain app means building fixtures that reproduce those rare states deliberately — because production will find them for you, at a worse time.
Why single-chain tests miss the failures
Most bridge integrations are tested the way most software is tested: deploy, run the happy path, assert the result. Cross-chain systems break that model:
- Two clocks, one action. Source confirmation, relay verification, and destination delivery finish at different times. A test that waits for one stage misses bugs in the others.
- State divergence. The same logical state looks different on each chain mid-transfer. Contracts that assume synchronized state fail exactly when chains disagree.
- Rare events dominate. Reorgs, gas spikes, relayer downtime, and duplicate submissions are low-frequency and high-impact. Happy-path coverage never touches them.
The fixtures worth building
- Forked mainnet states. Fork the destination chain at a block where the bridge contract has real inventory and real history. Run your delivery logic against actual state instead of a fresh deploy, because fresh deploys hide storage-layout and edge-condition bugs.
- Reorg simulation. Force the source chain to reorganize past your transfer's block and assert your app's reaction. Most apps assume confirmation is final; bridges and indexers do not always agree.
- Stalled delivery injection. Simulate a relayer that never submits, submits late, or submits a stale proof. Your app should detect the stall, surface it, and recover — not silently wait.
- Partial failure replays. Crash your service between source confirmation and destination delivery, restart, and assert no double delivery and no lost delivery. Idempotency is the contract here; test it by replaying events out of order.
- Value-boundary cases. Zero amounts, dust amounts, maximum amounts, and tokens with transfer fees or blacklists. Bridges pass these through to destination contracts that may reject them.
Testnets: useful, with caveats
Testnets give you free gas and multiple chains, but they diverge from mainnet in ways that matter:
- Different congestion and fee behavior. A route that is cheap on testnet may be expensive or stalled on mainnet. Benchmark costs separately.
- Different inventory behavior. Testnet bridges have toy inventory. Real bridges have limited pools, and your tests should model pool exhaustion, not assume infinite liquidity.
- Forks of testnet state. For delivery logic, a mainnet fork usually tests more real conditions than a testnet does. Use testnets for integration smoke tests, forks for edge cases.
The testing order that catches the most
- Unit-test each stage: source watch, verification, destination delivery, refund path.
- Integration-test full transfers on testnets, including failure injection.
- Replay rare events against mainnet forks: reorgs, stalls, duplicates, boundary values.
- Run chaos against your own services: restart mid-flow, drop events, duplicate submissions.
The takeaway
Cross-chain testing succeeds by reproducing rare states on purpose: forked mainnet state, forced reorgs, stalled deliveries, partial-failure replays, and value boundaries. Testnets smoke-test integration; forks catch the edge cases. Build the fixtures before launch, because production reproduces every one of them eventually.