feat: add entire flow test for escrow input settler#149
feat: add entire flow test for escrow input settler#149aalimsahin wants to merge 2 commits intoopenintentsframework:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Note
|
| Cohort / File(s) | Change Summary |
|---|---|
Cross-chain Escrow Integration Teststest/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.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
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
📒 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
ExportedMessagesmock appropriately exposes the protectedstoreGuardianSetfunction and provides a minimalpublishMessageimplementation that emits the expected event for test verification. The constant return value of0is acceptable since sequence number verification isn't part of these tests.
52-78: LGTM!State variables are well-organized with clear section comments. The
uint32type forONE_DAYcorrectly fits the value of86400seconds. The mixed typing ofinputSettlerEscrowasaddress(requiring interface casts) versusoutputSettlerSimpleas 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
encodeMessagewrapper usingexternalvisibility withcalldataparams is a clean pattern for calling viathis.encodeMessage(). Guardian set initialization with quorum validation (line 131) is good defensive practice.Also applies to: 161-198
203-221: LGTM!The
test_openfunction correctly verifies the escrow opening flow with proper balance assertions. Usingpublicvisibility 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. Thevm.expectCallassertion on lines 274-282 properly verifies that the oracle'sefficientRequireProvenfunction 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 thePackagePublishedevent ensures the Wormhole integration is properly exercised.
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
foundry.tomlsrc/oracles/[oracle-type]/external/[protocol-name]/Additional Notes
There are no changes to the existing codebase. Only new tests have been added.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.