-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: Apache 2.0 | ||
pragma solidity 0.8.19; | ||
|
||
import {Test} from "forge-std/Test.sol"; | ||
import {IChildBridgeAdaptor} from "../../src/interfaces/child/IChildBridgeAdaptor.sol"; | ||
import {IRootBridgeAdaptor} from "../../src/interfaces/root/IRootBridgeAdaptor.sol"; | ||
|
||
interface MessageReceiver { | ||
function onMessageReceive(bytes calldata data) external; | ||
} | ||
|
||
contract MockAdaptor is Test, IChildBridgeAdaptor, IRootBridgeAdaptor { | ||
|
||
uint256 chainId; | ||
MessageReceiver messageReceiver; | ||
MockAdaptor otherAdaptor; | ||
|
||
constructor() {} | ||
|
||
function initialize(uint256 _chainId, address _messageReceiver, address _otherAdaptor) public { | ||
chainId = _chainId; | ||
messageReceiver = MessageReceiver(_messageReceiver); | ||
otherAdaptor = MockAdaptor(_otherAdaptor); | ||
} | ||
|
||
function sendMessage(bytes calldata payload, address /*refundRecipient*/) external payable override(IChildBridgeAdaptor, IRootBridgeAdaptor) { | ||
otherAdaptor.onMessageReceive(payload); | ||
vm.selectFork(chainId); | ||
} | ||
|
||
function onMessageReceive(bytes calldata data) external { | ||
vm.selectFork(chainId); | ||
messageReceiver.onMessageReceive(data); | ||
} | ||
} |