Skip to content

Commit

Permalink
test: remove testFail* tests (#643)
Browse files Browse the repository at this point in the history
In preparation to deprecate `testFail*`:
foundry-rs/foundry#9574

- Removes `deployMockERC721` and `deployMockERC20` from `StdUtils` as
their tests includes large amount of `testFail*` tests and is generally
outdated. I haven't been able to find the `deploy*` methods being used
in any public project on Github.
- Implements workaround for other cases

Alternatively we could upstream Solady's mocks and tests (which have
been updated to not use `testFail*` but this feels out of place and
would be incomplete (ERC4626, ERC6909, etc..
https://github.com/Vectorized/solady/tree/main/test/utils/mocks). I
think it is most common for people to rely on the mocks their library
comes with (be it Solmate, Solady or OpenZeppelin) or write their own
wrapper around the token implementation.
  • Loading branch information
zerosnacks authored Jan 31, 2025
1 parent 999be66 commit 4645871
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1,651 deletions.
17 changes: 0 additions & 17 deletions src/StdUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pragma solidity >=0.6.2 <0.9.0;
pragma experimental ABIEncoderV2;

import {IMulticall3} from "./interfaces/IMulticall3.sol";
import {MockERC20} from "./mocks/MockERC20.sol";
import {MockERC721} from "./mocks/MockERC721.sol";
import {VmSafe} from "./Vm.sol";

abstract contract StdUtils {
Expand Down Expand Up @@ -119,21 +117,6 @@ abstract contract StdUtils {
return vm.computeCreate2Address(salt, initCodeHash);
}

/// @dev returns an initialized mock ERC20 contract
function deployMockERC20(string memory name, string memory symbol, uint8 decimals)
internal
returns (MockERC20 mock)
{
mock = new MockERC20();
mock.initialize(name, symbol, decimals);
}

/// @dev returns an initialized mock ERC721 contract
function deployMockERC721(string memory name, string memory symbol) internal returns (MockERC721 mock) {
mock = new MockERC721();
mock.initialize(name, symbol);
}

/// @dev returns the hash of the init code (creation code + no args) used in CREATE2 with no constructor arguments
/// @param creationCode the creation code of a contract C, as returned by type(C).creationCode
function hashInitCode(bytes memory creationCode) internal pure returns (bytes32) {
Expand Down
234 changes: 0 additions & 234 deletions src/mocks/MockERC20.sol

This file was deleted.

Loading

0 comments on commit 4645871

Please sign in to comment.