Skip to content

Commit 85d9566

Browse files
authored
fix: old repo tests (#338)
* fix: update old tests for foundry 1.0 * fix: update integration tests to 1.0
1 parent 3407298 commit 85d9566

File tree

5 files changed

+23
-31
lines changed

5 files changed

+23
-31
lines changed

script/integration/InspectIntegration.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ pragma solidity 0.8.17;
33

44
import {IntegrationTest} from "../../test/utils/IntegrationTest.sol";
55

6-
import {console, Script} from "forge-std/Script.sol";
6+
import {console2, Script} from "forge-std/Script.sol";
77

88
contract InspectIntegration is Script {
99
function run(string memory testContractName) external {
1010
IntegrationTest testContract = IntegrationTest(deployCode(testContractName));
1111
// Log chain and contract name. Also log the "run-if-deployed" flag.
12-
console.log(
12+
console2.log(
1313
"%s %s %s",
1414
testContract.chainName(),
1515
testContract.contractName(),

test/messaging/AuthVerifier.t.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ contract AuthVerifierTest is Test {
2020
assertEq(authVerifier.nodegroup(), address(7331));
2121
}
2222

23-
function testFailUnauthorizedNodeGroupSet() public {
23+
function testUnauthorizedNodeGroupSetRevert() public {
24+
vm.expectRevert("Ownable: caller is not the owner");
2425
vm.prank(address(9999));
2526
authVerifier.setNodeGroup(address(7331));
2627
}

test/messaging/GasFeePricing.t.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ contract GasFeePricingTest is Test {
2525
gasFeePricing = new GasFeePricing();
2626
}
2727

28-
function testFailSetCostAsNotOwner() public {
28+
function testSetCostAsNotOwnerRevert() public {
29+
vm.expectRevert("Ownable: caller is not the owner");
2930
vm.prank(address(0));
3031
gasFeePricing.setCostPerChain(expectedDstChainId, expectedDstGasPrice, expectedGasTokenPriceRatio);
3132
}
@@ -85,15 +86,12 @@ contract GasFeePricingTest is Test {
8586
assertEq(dstAddress, _address);
8687
}
8788

88-
function testFailRevertNoDstNativeAddress() public {
89+
function testNoDstNativeAddressRevert() public {
8990
bytes memory options = gasFeePricing.encodeOptions(2, 300000, 100000000000000000, bytes32(0));
90-
91+
vm.expectRevert("dstNativeAddress empty");
9192
(uint16 txType, uint256 gasLimit, uint256 dstAirdrop, bytes32 dstAddress) = gasFeePricing.decodeOptions(
9293
options
9394
);
94-
assertEq(txType, 2);
95-
assertEq(gasLimit, 300000);
96-
assertEq(dstAirdrop, 100000000000000000);
9795
}
9896

9997
function testEstimateFeeWithOptionsTypeOne(uint64 _gasLimit) public {

test/messaging/MessageBusSender.t.sol

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,35 @@ contract MessageBusSenderTest is Test {
5050
}
5151

5252
// Test fee query on an unset dstChain
53-
function testFailUnsetEstimateFee() public {
53+
function testUnsetEstimateFeeRevert() public {
54+
vm.expectRevert("Fee not set");
5455
messageBusSender.estimateFee(1, bytes(""));
5556
}
5657

57-
function testFailSendMessageWrongChainID() public {
58+
function testSendMessageWrongChainIDRevert() public {
5859
bytes32 receiverAddress = addressToBytes32(address(1337));
5960
// 99 is default foundry chain id
61+
vm.expectRevert("Fee not set");
6062
messageBusSender.sendMessage(receiverAddress, 99, bytes(""), bytes(""));
6163
}
6264

6365
// Enforce fees above returned fee amount from fee calculator
64-
function testFailSendMessageWithLowFees() public {
65-
uint256 estimatedFee = messageBusSender.estimateFee(gasFeePricingTest.expectedDstChainId(), bytes(""));
66+
function testSendMessageWithLowFeesRevert() public {
67+
uint256 dstChainId = gasFeePricingTest.expectedDstChainId();
68+
uint256 estimatedFee = messageBusSender.estimateFee(dstChainId, bytes(""));
6669
bytes32 receiverAddress = addressToBytes32(address(1337));
67-
messageBusSender.sendMessage{value: estimatedFee - 1}(
68-
receiverAddress,
69-
gasFeePricingTest.expectedDstChainId(),
70-
bytes(""),
71-
bytes("")
72-
);
70+
vm.expectRevert("Insuffient gas fee");
71+
messageBusSender.sendMessage{value: estimatedFee - 1}(receiverAddress, dstChainId, bytes(""), bytes(""));
7372
}
7473

7574
// Fee calculator reverts upon 0 fees (Fee is unset)
76-
function testFailMessageOnUnsetFees() public {
77-
uint256 estimatedFee = messageBusSender.estimateFee(gasFeePricingTest.expectedDstChainId() - 1, bytes(""));
75+
function testMessageOnUnsetFeesRevert() public {
76+
uint256 dstChainId = gasFeePricingTest.expectedDstChainId() - 1;
77+
vm.expectRevert("Fee not set");
78+
uint256 estimatedFee = messageBusSender.estimateFee(dstChainId, bytes(""));
7879
bytes32 receiverAddress = addressToBytes32(address(1337));
79-
messageBusSender.sendMessage{value: estimatedFee}(
80-
receiverAddress,
81-
gasFeePricingTest.expectedDstChainId() - 1,
82-
bytes(""),
83-
bytes("")
84-
);
80+
vm.expectRevert("Fee not set");
81+
messageBusSender.sendMessage{value: estimatedFee}(receiverAddress, dstChainId, bytes(""), bytes(""));
8582
}
8683

8784
// Send message without reversion, pay correct amount of fees, emit correct event

test/router/libs/UniversalTokenLib.t.sol

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ contract UniversalTokenLibraryTest is Test {
3838
// Should not revert, as the transfer is a noop due to the same recipient
3939
libHarness.universalTransfer(address(token), address(libHarness), amount);
4040
assertEq(token.balanceOf(address(libHarness)), amount);
41-
// Trying to transfer to the harness should still revert
42-
token.mint(address(this), amount);
43-
vm.expectRevert("Disabled transfers to harness");
44-
token.transfer(address(libHarness), amount);
4541
}
4642

4743
function testUniversalTransferETH() public {

0 commit comments

Comments
 (0)