Skip to content

Commit

Permalink
refactor: remove fallback()
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranquil-Flow committed Mar 22, 2024
1 parent 58ee7dd commit acd2657
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 90 deletions.
10 changes: 0 additions & 10 deletions src/PositionFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,4 @@ contract PositionFactory is Ownable, IPositionFactory {
SafeTransferLib.safeTransfer(ERC20(_token), msg.sender, balance);
}

/**
<<<<<<< HEAD
* @notice Executes when native is sent to this contract through a non-existent function.
*/
fallback() external payable { } // solhint-disable-line no-empty-blocks
=======
* @notice Executes when native is sent to this contract with a plain transaction.
*/
receive() external payable { } // solhint-disable-line no-empty-blocks
>>>>>>> f79c7b55671c8204d3d03bb5efe0ec65e1f85a29
}
11 changes: 0 additions & 11 deletions src/services/AdminService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,6 @@ contract AdminService is IAdminService {
SafeTransferLib.safeTransfer(ERC20(_token), msg.sender, balance);
}

/**
<<<<<<< HEAD
* @notice Executes when native is sent to this contract through a non-existent function.
*/
fallback() external payable { } // solhint-disable-line no-empty-blocks
=======
* @notice Executes when native is sent to this contract with a plain transaction.
*/
receive() external payable { } // solhint-disable-line no-empty-blocks
>>>>>>> f79c7b55671c8204d3d03bb5efe0ec65e1f85a29

/// @notice Check if the caller is the owner of the Position contract
modifier onlyOwner() {
if (msg.sender != OWNER) revert Unauthorized();
Expand Down
23 changes: 0 additions & 23 deletions test/FeeCollector.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -483,27 +483,4 @@ contract FeeCollectorTest is Test, TokenUtils, FeeUtils {
feeCollector.extractERC20(token);
}
}

/// @dev
// - The FeeCollector's native balance should increase by the amount transferred.
function testFuzz_Fallback(uint256 _amount, address _sender) public {
// Assumptions
vm.assume(_amount != 0 && _amount <= 1000 ether);
uint256 gasMoney = 1 ether;
vm.deal(_sender, _amount + gasMoney);

// Pre-Act Data
uint256 preContractBalance = feeCollectorAddr.balance;

// Act
vm.prank(_sender);
(bool success,) = feeCollectorAddr.call{ value: _amount }(abi.encodeWithSignature("nonExistentFn()"));

// Post-Act Data
uint256 postContractBalance = feeCollectorAddr.balance;

// Assertions
assertTrue(success);
assertEq(postContractBalance, preContractBalance + _amount);
}
}
23 changes: 0 additions & 23 deletions test/PositionFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -266,27 +266,4 @@ contract PositionFactoryTest is Test, TokenUtils {
positionFactory.extractERC20(supportedAssets[i]);
}
}

/// @dev
// - The contract's native balance should increase by the amount transferred.
function testFuzz_Fallback(uint256 _amount, address _sender) public {
// Assumptions
vm.assume(_amount != 0 && _amount <= 1000 ether);
uint256 gasMoney = 1 ether;
vm.deal(_sender, _amount + gasMoney);

// Pre-Act Data
uint256 preContractBalance = address(positionFactory).balance;

// Act
vm.prank(_sender);
(bool success,) = address(positionFactory).call{ value: _amount }(abi.encodeWithSignature("nonExistentFn()"));

// Post-Act Data
uint256 postContractBalance = address(positionFactory).balance;

// Assertions
assertTrue(success);
assertEq(postContractBalance, preContractBalance + _amount);
}
}
23 changes: 0 additions & 23 deletions test/services/AdminService.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -138,29 +138,6 @@ contract AdminServiceTest is Test, TokenUtils {
}
}

/// @dev
// - The contract's native balance should increase by the amount transferred.
function testFuzz_Fallback(uint256 _amount, address _sender) public {
// Assumptions
vm.assume(_amount != 0 && _amount <= 1000 ether);
uint256 gasMoney = 1 ether;
vm.deal(_sender, _amount + gasMoney);

// Pre-Act Data
uint256 preContractBalance = positionAddr.balance;

// Act
vm.prank(_sender);
(bool success,) = positionAddr.call{ value: _amount }(abi.encodeWithSignature("nonExistentFn()"));

// Post-Act Data
uint256 postContractBalance = positionAddr.balance;

// Assertions
assertTrue(success);
assertEq(postContractBalance, preContractBalance + _amount);
}

/// @dev Necessary for the owner, address(this), to receive native extractNative tests
receive() external payable { }
}

0 comments on commit acd2657

Please sign in to comment.