Skip to content

Commit

Permalink
T
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectorized committed Dec 9, 2024
1 parent 08246b8 commit ee9ae38
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions test/MessageHubV1.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ contract MessagehubV1Test is SoladyTest {

address constant ALICE = address(111);

struct Call {
address target;
uint256 value;
bytes data;
}

function setUp() public {
eid1 = new EndpointV2Mock(1);
eid2 = new EndpointV2Mock(2);
Expand Down Expand Up @@ -77,9 +83,7 @@ contract MessagehubV1Test is SoladyTest {
originalSender,
senderType,
expected,
abi.encodeWithSignature(
"execute(address,uint256,bytes)", address(this), 1 ether, abi.encodeWithSignature("setX(uint256)", newX)
)
_encodeExecuteCalldata(address(this), 1 ether, abi.encodeWithSignature("setX(uint256)", newX))
);

hub.forward{value: 1 ether}(message);
Expand All @@ -88,6 +92,16 @@ contract MessagehubV1Test is SoladyTest {
assertEq(valueDuringSetX, 1 ether);
}

function _encodeExecuteCalldata(address target, uint256 value, bytes memory data) internal returns (bytes memory) {
Call[] memory calls = new Call[](1);
calls[0].target = target;
calls[0].value = value;
calls[0].data = data;
bytes memory executionData = abi.encode(calls);
bytes32 mode = bytes32(bytes1(0x01));
return abi.encodeWithSignature("execute(bytes32,bytes)", mode, executionData);
}

function setX(uint256 value) public payable {
valueDuringSetX = msg.value;
x = value;
Expand Down

0 comments on commit ee9ae38

Please sign in to comment.