Skip to content

Commit

Permalink
Upgrade forge-std + Extend checkModifier + Fix tests for Optimism Mai…
Browse files Browse the repository at this point in the history
…n after Bedrock
  • Loading branch information
sunbreak1211 committed Jul 21, 2023
1 parent 754d7ab commit 3939ae1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/DssTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ abstract contract DssTest is Test {
function checkModifier(address _base, string memory _revertMsg, bytes4[] memory _fsigs) internal {
for (uint256 i = 0; i < _fsigs.length; i++) {
bytes4 fsig = _fsigs[i];
uint256 p = 0;
uint256[] memory p = new uint256[](20);
// Pad the abi call with 0s to fill all the args (it's okay to supply more than the function requires)
assertRevert(_base, abi.encodePacked(fsig, p, p, p, p, p, p), _revertMsg);
assertRevert(_base, abi.encodePacked(fsig, p), _revertMsg);
}
}
function checkModifier(address _base, string memory _revertMsg, bytes4[1] memory _fsigs) internal {
Expand Down
12 changes: 6 additions & 6 deletions src/domains/Domain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ contract Domain {
vm.makePersistent(address(this));
}

function readConfigString(string memory key) public view returns (string memory) {
function readConfigString(string memory key) public returns (string memory) {
return config.readString(string.concat(".domains.", _details.chainAlias, ".", key));
}

function readConfigAddress(string memory key) public view returns (address) {
function readConfigAddress(string memory key) public returns (address) {
return config.readAddress(string.concat(".domains.", _details.chainAlias, ".", key));
}

function readConfigUint(string memory key) public view returns (uint256) {
function readConfigUint(string memory key) public returns (uint256) {
return config.readUint(string.concat(".domains.", _details.chainAlias, ".", key));
}

function readConfigInt(string memory key) public view returns (int256) {
function readConfigInt(string memory key) public returns (int256) {
return config.readInt(string.concat(".domains.", _details.chainAlias, ".", key));
}

function readConfigBytes32(string memory key) public view returns (bytes32) {
function readConfigBytes32(string memory key) public returns (bytes32) {
return config.readBytes32(string.concat(".domains.", _details.chainAlias, ".", key));
}

Expand All @@ -67,7 +67,7 @@ contract Domain {
return out;
}

function readConfigBytes32FromString(string memory key) public view returns (bytes32) {
function readConfigBytes32FromString(string memory key) public returns (bytes32) {
return bytesToBytes32(bytes(readConfigString(key)));
}

Expand Down
19 changes: 2 additions & 17 deletions src/domains/OptimismDomain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,6 @@ interface MessengerLike {
bytes memory message,
uint32 gasLimit
) external;
function relayMessage(
address _target,
address _sender,
bytes memory _message,
uint256 _messageNonce
) external;
}

interface BedrockMessengerLike {
function relayMessage(
uint256 _nonce,
address _sender,
Expand Down Expand Up @@ -81,14 +72,8 @@ contract OptimismDomain is BridgedDomain {
if (log.topics[0] == SENT_MESSAGE_TOPIC && log.emitter == address(l1Messenger)) {
address target = address(uint160(uint256(log.topics[1])));
(address sender, bytes memory message, uint256 nonce, uint256 gasLimit) = abi.decode(log.data, (address, bytes, uint256, uint256));
vm.startPrank(malias);
if (isGoerli()) {
// Goerli has been upgraded to bedrock which has a new relay interface
BedrockMessengerLike(address(l2Messenger)).relayMessage(nonce, sender, target, 0, gasLimit, message);
} else {
l2Messenger.relayMessage(target, sender, message, nonce);
}
vm.stopPrank();
vm.prank(malias);
l2Messenger.relayMessage(nonce, sender, target, 0, gasLimit, message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ export FOUNDRY_ROOT_CHAINID
if [[ -z "$1" ]]; then
forge test
else
forge test --match "$1" -vvvvv
forge test --match-test "$1" -vvvvv
fi

0 comments on commit 3939ae1

Please sign in to comment.