diff --git a/package.json b/package.json index 9b6f4fd8..2a48299e 100644 --- a/package.json +++ b/package.json @@ -32,14 +32,13 @@ "package.json": "sort-package-json" }, "dependencies": { - "ds-test": "github:dapphub/ds-test#e282159", - "forge-std": "github:foundry-rs/forge-std#v1.7.3", - "isolmate": "github:defi-wonderland/isolmate#59e1804", - "prb/test": "github:paulrberg/prb-test#v0.6.5" + "isolmate": "github:defi-wonderland/isolmate#59e1804" }, "devDependencies": { "@commitlint/cli": "17.0.3", "@commitlint/config-conventional": "17.0.3", + "ds-test": "github:dapphub/ds-test#e282159", + "forge-std": "github:foundry-rs/forge-std#v1.7.3", "husky": ">=8", "lint-staged": ">=10", "solhint": "3.6.2", diff --git a/remappings.txt b/remappings.txt index 89bb6bd4..83b675a3 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,5 +1,4 @@ ds-test/=node_modules/ds-test/src -prb/test/=node_modules/prb/test/src/ forge-std/=node_modules/forge-std/src isolmate/=node_modules/isolmate/src diff --git a/solidity/test/integration/IntegrationBase.sol b/solidity/test/integration/IntegrationBase.sol index 2c1646dc..43e6a470 100644 --- a/solidity/test/integration/IntegrationBase.sol +++ b/solidity/test/integration/IntegrationBase.sol @@ -1,17 +1,17 @@ // SPDX-License-Identifier: MIT pragma solidity =0.8.19; -import {DSTestFull} from 'test/utils/DSTestFull.sol'; import {IERC20} from 'isolmate/interfaces/tokens/IERC20.sol'; +import {Test} from 'forge-std/Test.sol'; import {Greeter, IGreeter} from 'contracts/Greeter.sol'; -contract IntegrationBase is DSTestFull { +contract IntegrationBase is Test { uint256 internal constant _FORK_BLOCK = 15_452_788; string internal _initialGreeting = 'hola'; - address internal _user = _label('user'); - address internal _owner = _label('owner'); + address internal _user = makeAddr('user'); + address internal _owner = makeAddr('owner'); address internal _daiWhale = 0x42f8CA49E88A8fd8F0bfA2C739e648468b8f9dec; IERC20 internal _dai = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F); IGreeter internal _greeter; diff --git a/solidity/test/unit/Greeter.t.sol b/solidity/test/unit/Greeter.t.sol index 729aa2bb..42e328bd 100644 --- a/solidity/test/unit/Greeter.t.sol +++ b/solidity/test/unit/Greeter.t.sol @@ -2,17 +2,19 @@ pragma solidity =0.8.19; import {IERC20} from 'isolmate/interfaces/tokens/IERC20.sol'; -import {DSTestFull} from 'test/utils/DSTestFull.sol'; +import {Test} from 'forge-std/Test.sol'; import {Greeter, IGreeter} from 'contracts/Greeter.sol'; -abstract contract Base is DSTestFull { - address internal _owner = _label('owner'); - IERC20 internal _token = IERC20(_mockContract('token')); +abstract contract Base is Test { + address internal _owner = makeAddr('owner'); + + IERC20 internal _token = IERC20(makeAddr('token')); string internal _initialGreeting = 'hola'; bytes32 internal _emptyString = keccak256(bytes('')); Greeter internal _greeter; function setUp() public virtual { + vm.etch(address(_token), new bytes(0x1)); // etch bytecode to avoid address collision problems vm.prank(_owner); _greeter = new Greeter(_initialGreeting, _token); } @@ -74,7 +76,7 @@ contract UnitGreeterSetGreeting is Base { function test_EmitEvent(string memory _greeting) public { vm.assume(keccak256(bytes(_greeting)) != _emptyString); - _expectEmitNoIndex(); + vm.expectEmit(true, true, true, true, address(_greeter)); emit GreetingSet(_greeting); _greeter.setGreeting(_greeting); diff --git a/solidity/test/utils/DSTestFull.sol b/solidity/test/utils/DSTestFull.sol deleted file mode 100644 index c1bd8568..00000000 --- a/solidity/test/utils/DSTestFull.sol +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity =0.8.19; - -import {PRBTest} from 'prb/test/PRBTest.sol'; - -contract DSTestFull is PRBTest { - // Seed for the generation of pseudorandom addresses - bytes32 private _nextAddressSeed = keccak256(abi.encodePacked('address')); - - /** - * @dev Creates a new pseudorandom address and labels it with the given label - * @param _name Name of the label. - * @return _address The address generated and labeled - */ - function _label(string memory _name) internal returns (address _address) { - return _label(_newAddress(), _name); - } - - /** - * @dev Labels the given address and returns it - * - * @param _addy Address to label. - * @param _name Name of the label. - * - * @return _address The address Labeled address - */ - function _label(address _addy, string memory _name) internal returns (address _address) { - vm.label(_addy, _name); - return _addy; - } - - /** - * @dev Creates a mock contract in a pseudorandom address and labels it. - * @param _name Label for the mock contract. - * @return _address The address of the mock contract. - */ - function _mockContract(string memory _name) internal returns (address _address) { - return _mockContract(_newAddress(), _name); - } - - /** - * @dev Creates a mock contract in a specified address and labels it. - * - * @param _addy Address for the mock contract. - * @param _name Label for the mock contract. - * - * @return _address The address of the mock contract. - */ - function _mockContract(address _addy, string memory _name) internal returns (address _address) { - vm.etch(_addy, new bytes(0x1)); - return _label(_addy, _name); - } - - /** - * @dev Creates a pseudorandom address. - * @return _address The address of the mock contract. - */ - function _newAddress() internal returns (address _address) { - address payable _nextAddress = payable(address(uint160(uint256(_nextAddressSeed)))); - _nextAddressSeed = keccak256(abi.encodePacked(_nextAddressSeed)); - _address = _nextAddress; - } - - function _expectEmitNoIndex() internal { - vm.expectEmit(false, false, false, true); - } -} diff --git a/yarn.lock b/yarn.lock index 41d9c4fe..d31d5ebb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1067,6 +1067,9 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== +"forge-std@github:foundry-rs/forge-std#v1.7.3": + version "1.7.3" + resolved "https://codeload.github.com/foundry-rs/forge-std/tar.gz/2f112697506eab12d433a65fdc31a639548fe365" "forge-std@github:foundry-rs/forge-std#v1.7.3": version "1.7.3" resolved "https://codeload.github.com/foundry-rs/forge-std/tar.gz/2f112697506eab12d433a65fdc31a639548fe365" @@ -1920,10 +1923,6 @@ pluralize@^8.0.0: resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1" integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA== -"prb/test@github:paulrberg/prb-test#v0.6.5": - version "0.6.5" - resolved "https://codeload.github.com/paulrberg/prb-test/tar.gz/2ece8755d9afe7d66440ef9ca19b8a9dab40164b" - prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"