From 725470fff53a69c72b2636a91a025c36afeb68ca Mon Sep 17 00:00:00 2001 From: Andrew Chiaramonte Date: Fri, 13 Dec 2024 14:25:24 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20relocate=20MaliciousReceiver=20help?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/Collateral.t.sol | 16 +--------------- test/Pay.t.sol | 18 ++---------------- test/utils/MaliciousReceiver.sol | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 31 deletions(-) create mode 100644 test/utils/MaliciousReceiver.sol diff --git a/test/Collateral.t.sol b/test/Collateral.t.sol index 2f812962..70f0042c 100644 --- a/test/Collateral.t.sol +++ b/test/Collateral.t.sol @@ -4,6 +4,7 @@ pragma solidity 0.8.27; import {IEngine} from "src/interfaces/IEngine.sol"; import {Bootstrap} from "test/utils/Bootstrap.sol"; import {Pay} from "src/utils/Pay.sol"; +import {MaliciousReceiver} from "test/utils/MaliciousReceiver.sol"; contract CollateralTest is Bootstrap { function setUp() public { @@ -649,18 +650,3 @@ contract WithdrawCollateral is CollateralTest { vm.stopPrank(); } } - -// Helper contract that rejects ETH transfers -contract MaliciousReceiver { - receive() external payable { - revert(); - } - - function onERC721Received(address, address, uint256, bytes calldata) - external - pure - returns (bytes4) - { - return 0x150b7a02; - } -} diff --git a/test/Pay.t.sol b/test/Pay.t.sol index 80c6b180..8bf5ec48 100644 --- a/test/Pay.t.sol +++ b/test/Pay.t.sol @@ -2,6 +2,7 @@ pragma solidity 0.8.27; import {Bootstrap} from "test/utils/Bootstrap.sol"; +import {MaliciousReceiver} from "test/utils/MaliciousReceiver.sol"; import {Pay} from "src/utils/Pay.sol"; import {IWETH} from "src/interfaces/tokens/IWETH.sol"; @@ -91,19 +92,4 @@ contract PayTest is Bootstrap { payFork.unwrapAndPay(amount, to); assertEq(to.balance, balanceBefore + amount); } -} - -// Helper contract that rejects ETH transfers -contract MaliciousReceiver { - receive() external payable { - revert(); - } - - function onERC721Received(address, address, uint256, bytes calldata) - external - pure - returns (bytes4) - { - return 0x150b7a02; - } -} +} \ No newline at end of file diff --git a/test/utils/MaliciousReceiver.sol b/test/utils/MaliciousReceiver.sol new file mode 100644 index 00000000..08b840f5 --- /dev/null +++ b/test/utils/MaliciousReceiver.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +pragma solidity 0.8.27; + +/// @notice Helper contract that rejects ETH transfers +/// @author cmontecoding +contract MaliciousReceiver { + receive() external payable { + revert(); + } + + function onERC721Received(address, address, uint256, bytes calldata) + external + pure + returns (bytes4) + { + return 0x150b7a02; + } +}