Skip to content

Add missing SwapAndDepositRouter test coverage #262

@mattsse

Description

@mattsse

Summary

SwapAndDepositRouter has a passing focused Foundry test suite, but coverage is not sufficient if we want to treat the router as release-ready.

The current tests cover:

  • authorized vs unauthorized messenger access
  • invalid target portal
  • invalid token
  • plaintext same-token deposit
  • plaintext swap path against a mock DEX
  • encrypted same-token deposit
  • encrypted swap path against a mock DEX
  • swap slippage revert

What is missing

1. No end-to-end coverage for the real swap branch

The Rust integration tests only exercise the same-token router path (tokenOut == tokenIn).

Relevant files:

  • crates/tempo-zone/tests/it/utils.rs
  • crates/tempo-zone/tests/it/demo_cross_zone.rs
  • crates/tempo-zone/tests/it/l1_e2e.rs

The existing helper explicitly encodes the no-swap path, so we do not currently have an end-to-end test that proves a routed cross-token transfer actually swaps and deposits successfully.

2. No test that deposit failure reverts the callback

The contract relies on the entire callback reverting on downstream failure so the withdrawal bounces back to the fallback recipient. We currently test swap failure, but not target portal deposit failure.

Missing cases:

  • plaintext deposit() revert
  • encrypted depositEncrypted() revert

3. Important invariants are not pinned

We should add regression coverage for:

  • same-token path ignores minAmountOut
  • malformed callback data reverts cleanly

Proposed work

Rust end-to-end tests

Add at least one real routed cross-token scenario in crates/tempo-zone/tests/it/ that verifies:

  • withdrawal callback reaches the router
  • swap path is taken
  • output token is deposited into the destination zone
  • balances reflect the swap outcome

Acceptance criteria

  • Rust e2e test exercises a real cross-token router flow.

This issue is about closing the remaining release-risk gaps, not fixing a currently failing test.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions