-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor and test: bridging contracts #118
Conversation
kupermind
commented
Feb 28, 2024
- Addressing internal audit;
- Adding tests
/// @author Aleksandr Kuperman - <[email protected]> | ||
/// @author Andrey Lebedev - <[email protected]> | ||
/// @author Mariapia Moscatiello - <[email protected]> | ||
abstract contract BridgeMessenger is IBridgeErrors { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just extracts the data processing that is the same everywhere.
/// @dev Interface to the CrossDomainMessenger (CDM) Contract Proxy. | ||
interface ICrossDomainMessenger { | ||
function xDomainMessageSender() external returns (address); | ||
} | ||
|
||
/// @dev Provided zero address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted into its own IBridgeErrors.sol
file.
} | ||
|
||
// Unpack and process the data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted into BridgeMessenger
contract
@@ -1,85 +1,37 @@ | |||
// SPDX-License-Identifier: MIT | |||
pragma solidity ^0.8.23; | |||
|
|||
/// @dev Provided zero address. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted into IBridgeErrors.sol
@@ -154,54 +100,8 @@ contract WormholeMessenger { | |||
} | |||
mapDeliveryHashes[deliveryHash] = true; | |||
|
|||
// Check for the correct data length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted into BridgeMessenger
contract
/// @author Aleksandr Kuperman - <[email protected]> | ||
/// @author Andrey Lebedev - <[email protected]> | ||
/// @author Mariapia Moscatiello - <[email protected]> | ||
contract MockL2Relayer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mock contract to account for all messenger contracts testing.
const sendPayloadSelector = "0x8fecdd02"; | ||
const sendPayloadSelector = "0x4b5ca6f4"; | ||
const timelockPayload = await wormholeRelayer.interface.encodeFunctionData(sendPayloadSelector, [targetChain, | ||
wormholeMessengerAddress, data, 0, minGasLimit]); | ||
wormholeMessengerAddress, data, 0, minGasLimit, targetChain, wormholeMessengerAddress]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function usage is better for wormhole as it allows to collect undelivered funds.
@@ -408,4 +409,27 @@ describe("buOLAS", function () { | |||
).to.be.revertedWithCustomError(bu, "NonTransferable"); | |||
}); | |||
}); | |||
|
|||
context("Time sensitive functions.", async function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to fix that testing a long time ago - now it's merged into the main buOLAS.js
testing file.
@@ -1,41 +0,0 @@ | |||
/*global describe, context, beforeEach, it*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This became obsolete now.