Skip to content

Commit

Permalink
Create MockAdaptor.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
wcgcyx committed Feb 19, 2024
1 parent 8a0d25a commit 19c21b9
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/invariant/MockAdaptor.sol
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);
}
}

0 comments on commit 19c21b9

Please sign in to comment.