Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make tests setup functions virtual #378

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 117 additions & 117 deletions .gas-snapshot

Large diffs are not rendered by default.

112 changes: 79 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/test/Auth.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract OutOfOrderAuthority is Authority {
contract AuthTest is DSTestPlus {
MockAuthChild mockAuthChild;

function setUp() public {
function setUp() public virtual {
mockAuthChild = new MockAuthChild();
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ERC1155.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ contract ERC1155Test is DSTestPlus, ERC1155TokenReceiver {
mapping(address => mapping(uint256 => uint256)) public userMintAmounts;
mapping(address => mapping(uint256 => uint256)) public userTransferOrBurnAmounts;

function setUp() public {
function setUp() public virtual {
token = new MockERC1155();
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/ERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ contract ERC20Test is DSTestPlus {
bytes32 constant PERMIT_TYPEHASH =
keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

function setUp() public {
function setUp() public virtual {
token = new MockERC20("Token", "TKN", 18);
}

Expand Down Expand Up @@ -483,7 +483,7 @@ contract ERC20Invariants is DSTestPlus, DSInvariantTest {
BalanceSum balanceSum;
MockERC20 token;

function setUp() public {
function setUp() public virtual {
token = new MockERC20("Token", "TKN", 18);
balanceSum = new BalanceSum(token);

Expand Down
2 changes: 1 addition & 1 deletion src/test/ERC4626.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract ERC4626Test is DSTestPlus {
MockERC20 underlying;
MockERC4626 vault;

function setUp() public {
function setUp() public virtual {
underlying = new MockERC20("Mock Token", "TKN", 18);
vault = new MockERC4626(underlying, "Mock Token Vault", "vwTKN");
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ERC721.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ contract NonERC721Recipient {}
contract ERC721Test is DSTestPlus {
MockERC721 token;

function setUp() public {
function setUp() public virtual {
token = new MockERC721("Token", "TKN");
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/MultiRolesAuthority.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {MultiRolesAuthority} from "../auth/authorities/MultiRolesAuthority.sol";
contract MultiRolesAuthorityTest is DSTestPlus {
MultiRolesAuthority multiRolesAuthority;

function setUp() public {
function setUp() public virtual {
multiRolesAuthority = new MultiRolesAuthority(address(this), Authority(address(0)));
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/Owned.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {MockOwned} from "./utils/mocks/MockOwned.sol";
contract OwnedTest is DSTestPlus {
MockOwned mockOwned;

function setUp() public {
function setUp() public virtual {
mockOwned = new MockOwned();
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ReentrancyGuard.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ contract RiskyContract is ReentrancyGuard {
contract ReentrancyGuardTest is DSTestPlus {
RiskyContract riskyContract;

function setUp() public {
function setUp() public virtual {
riskyContract = new RiskyContract();
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/RolesAuthority.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {RolesAuthority} from "../auth/authorities/RolesAuthority.sol";
contract RolesAuthorityTest is DSTestPlus {
RolesAuthority rolesAuthority;

function setUp() public {
function setUp() public virtual {
rolesAuthority = new RolesAuthority(address(this), Authority(address(0)));
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/SafeCastLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract SafeCastLibTest is DSTestPlus {
assertEq(SafeCastLib.safeCastTo224(2.5e36), 2.5e36);
assertEq(SafeCastLib.safeCastTo224(2.5e27), 2.5e27);
}

function testSafeCastTo216() public {
assertEq(SafeCastLib.safeCastTo216(2.5e36), 2.5e36);
assertEq(SafeCastLib.safeCastTo216(2.5e27), 2.5e27);
Expand Down Expand Up @@ -396,7 +396,6 @@ contract SafeCastLibTest is DSTestPlus {
assertEq(SafeCastLib.safeCastTo88(x), x);
}


function testSafeCastTo80(uint256 x) public {
x = bound(x, 0, type(uint80).max);

Expand Down
2 changes: 1 addition & 1 deletion src/test/SafeTransferLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract SafeTransferLibTest is DSTestPlus {

MockERC20 erc20;

function setUp() public {
function setUp() public virtual {
reverting = new RevertingToken();
returnsTwo = new ReturnsTwoToken();
returnsFalse = new ReturnsFalseToken();
Expand Down
4 changes: 2 additions & 2 deletions src/test/WETH.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {WETH} from "../tokens/WETH.sol";
contract WETHTest is DSTestPlus {
WETH weth;

function setUp() public {
function setUp() public virtual {
weth = new WETH();
}

Expand Down Expand Up @@ -111,7 +111,7 @@ contract WETHInvariants is DSTestPlus, DSInvariantTest {
WETHTester wethTester;
WETH weth;

function setUp() public {
function setUp() public virtual {
weth = new WETH();
wethTester = new WETHTester{value: address(this).balance}(weth);

Expand Down
2 changes: 1 addition & 1 deletion src/utils/SafeCastLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ library SafeCastLib {

y = uint192(x);
}

function safeCastTo184(uint256 x) internal pure returns (uint184 y) {
require(x < 1 << 184);

Expand Down