Skip to content

feat: add entire flow test for escrow input settler#149

Open
aalimsahin wants to merge 2 commits intoopenintentsframework:mainfrom
aalimsahin:escrow-entire-flow
Open

feat: add entire flow test for escrow input settler#149
aalimsahin wants to merge 2 commits intoopenintentsframework:mainfrom
aalimsahin:escrow-entire-flow

Conversation

@aalimsahin
Copy link
Copy Markdown

@aalimsahin aalimsahin commented Oct 20, 2025

Description

This PR adds new tests that include the entire flow using inputSettlerEscrow, wormhole oracle, and outputSettlerSimple.

Related Issues

There is no related issue.

Third-Party Integration Checklist

⚠️ CRITICAL: All third-party integrations must follow strict dependency guidelines

  • No external library imports - Confirmed no new dependencies added to foundry.toml
  • Interfaces copied locally - All required interfaces copied to src/oracles/[oracle-type]/external/[protocol-name]/
  • Proper documentation - Each copied interface includes source header with:
    • Protocol name and version
    • Original source URL
    • Commit hash and copy date
    • List of any modifications made
  • Self-contained - Integration works with only repository code
  • Minimal interfaces - Only copied the specific methods/events needed

Additional Notes

There are no changes to the existing codebase. Only new tests have been added.

Summary by CodeRabbit

  • Tests
    • Added comprehensive integration test suite for cross-chain escrow settlement.
    • Introduced end-to-end testing for escrow operations including opening, refunding, and finalization with oracle validation.
    • Enabled validation of cross-chain message processing workflows.

✏️ Tip: You can customize this high-level summary in your review settings.

@reednaa reednaa self-requested a review October 20, 2025 12:12
@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 26, 2025

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'enabled'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

Adds a comprehensive integration test suite for cross-chain escrow settlement. Introduces the ExportedMessages test helper contract to simulate Wormhole message pathways and InputSettlerEscrowTestCrossChain with setup utilities and end-to-end test scenarios for escrow operations including token transfers and oracle validation.

Changes

Cohort / File(s) Change Summary
Cross-chain Escrow Integration Tests
test/integration/SettlerEscrow.crosschain.t.sol
Added comprehensive integration test suite with ExportedMessages mock contract exposing public wrappers for guardian-set storage and message publishing, InputSettlerEscrowTestCrossChain test contract with setUp orchestrating core and mock contract deployments, private helper _setupWormholeOracle for oracle and guardian configuration, message encoding utilities (encodeMessage, _makeValidVAA, _createOrder, _createSolveParams), and end-to-end test cases (test_open, test_open_and_refund, test_open_and_finalise, test_entire_flow) verifying escrow opening, refunding, finalisation, and cross-chain settlement with VAA proof submission

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hoppy hop, the tests now flow,
Cross-chains dancing, watch them go,
Wormholes woven, VAAs bright,
Escrows settle—what a sight! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding comprehensive end-to-end flow tests for the escrow input settler with cross-chain functionality.
Description check ✅ Passed The description covers the main purpose of the PR and completes all required sections of the template including Related Issues and Third-Party Integration Checklist with appropriate responses.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
test/integration/SettlerEscrow.crosschain.t.sol (1)

145-158: Consider adding brief comments for magic hex values.

The hardcoded hex values in the VAA construction represent Wormhole VAA structure fields. Adding brief inline comments would improve maintainability for future readers.

🔎 Suggested documentation
     function _makeValidVAA(
         uint16 emitterChainId,
         bytes32 emitterAddress,
         bytes memory message
     ) internal view returns (bytes memory validVM) {
+        // VAA body: timestamp (4 bytes), nonce (4 bytes), emitterChainId, emitterAddress, sequence (8 bytes), consistencyLevel (1 byte)
         bytes memory preMessage = abi.encodePacked(
-            hex"000003e8" hex"00000001", emitterChainId, emitterAddress, hex"0000000000000539" hex"0f"
+            hex"000003e8",    // timestamp: 1000
+            hex"00000001",    // nonce: 1
+            emitterChainId,
+            emitterAddress,
+            hex"0000000000000539", // sequence: 1337
+            hex"0f"           // consistencyLevel: 15 (finalized)
         );
         bytes memory postvalidVM = abi.encodePacked(preMessage, message);
         bytes32 vmHash = keccak256(abi.encodePacked(keccak256(postvalidVM)));
         (uint8 v, bytes32 r, bytes32 s) = vm.sign(testGuardianPrivateKey, vmHash);

+        // VAA header: version (1), guardianSetIndex (4), numSignatures (1), guardianIndex (1), r, s, v
         validVM = abi.encodePacked(hex"01" hex"00000000" hex"01", uint8(0), r, s, v - 27, postvalidVM);
     }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 035fa57 and b33e467.

📒 Files selected for processing (1)
  • test/integration/SettlerEscrow.crosschain.t.sol
🔇 Additional comments (9)
test/integration/SettlerEscrow.crosschain.t.sol (9)

1-24: LGTM!

Imports are well-organized and all appear to be used within the test file. License and pragma are appropriate.


26-45: LGTM!

The ExportedMessages mock appropriately exposes the protected storeGuardianSet function and provides a minimal publishMessage implementation that emits the expected event for test verification. The constant return value of 0 is acceptable since sequence number verification isn't part of these tests.


52-78: LGTM!

State variables are well-organized with clear section comments. The uint32 type for ONE_DAY correctly fits the value of 86400 seconds. The mixed typing of inputSettlerEscrow as address (requiring interface casts) versus outputSettlerSimple as concrete type is reasonable given different usage patterns.


82-112: LGTM!

Setup is thorough with proper contract deployments, actor creation, token minting, and approvals. Each test runs with fresh state in Forge, so the exact approval amount on line 105 is appropriate.


117-142: LGTM!

Helper functions are well-implemented. The encodeMessage wrapper using external visibility with calldata params is a clean pattern for calling via this.encodeMessage(). Guardian set initialization with quorum validation (line 131) is good defensive practice.

Also applies to: 161-198


203-221: LGTM!

The test_open function correctly verifies the escrow opening flow with proper balance assertions. Using public visibility and returning the order enables clean test composition in dependent tests.


224-254: LGTM!

The refund test properly exercises the expiry path by warping time past the deadline, verifying the order status transitions, and confirming the user receives their tokens back. Good use of vm.expectEmit() for event verification.


257-290: LGTM!

Solid finalization test with AlwaysYesOracle. The vm.expectCall assertion on lines 274-282 properly verifies that the oracle's efficientRequireProven function is invoked with the expected parameters, ensuring the proof validation path is exercised.


293-348: Excellent end-to-end integration test!

This test comprehensively validates the complete cross-chain escrow flow through all five steps: order opening, output filling, Wormhole proof submission, VAA reception, and finalization with solver payment. The use of vm.expectEmit() for the PackagePublished event ensures the Wormhole integration is properly exercised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant