Skip to content

Commit

Permalink
✅ relocate MaliciousReceiver helper
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Dec 13, 2024
1 parent f6dc00d commit 725470f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 31 deletions.
16 changes: 1 addition & 15 deletions test/Collateral.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
}
18 changes: 2 additions & 16 deletions test/Pay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
}
}
}
18 changes: 18 additions & 0 deletions test/utils/MaliciousReceiver.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 725470f

Please sign in to comment.