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

test: replace DSTestFull with Test #38

Merged
merged 7 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
622 changes: 311 additions & 311 deletions out/Greeter.sol/Greeter.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@
},
"dependencies": {
"ds-test": "github:dapphub/ds-test#e282159",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be remove as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot, because forge-std/Test.sol depends on this one

"forge-std": "github:foundry-rs/forge-std#v1.5.6",
"isolmate": "github:defi-wonderland/isolmate#59e1804",
"prb/test": "github:paulrberg/prb-test#a245c71"
"forge-std": "github:foundry-rs/forge-std#v1.7.3",
"isolmate": "github:defi-wonderland/isolmate#59e1804"
},
"devDependencies": {
"@commitlint/cli": "17.0.3",
Expand Down
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ds-test/=node_modules/ds-test/src
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, should we remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, it doesn't work

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but why?

because of the import in Test.sol
image

prb/test/=node_modules/prb/test/src/
forge-std/=node_modules/forge-std/src
isolmate/=node_modules/isolmate/src

Expand Down
8 changes: 4 additions & 4 deletions solidity/test/integration/IntegrationBase.sol
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 7 additions & 5 deletions solidity/test/unit/Greeter.t.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity =0.8.19;

Check warning on line 2 in solidity/test/unit/Greeter.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (16.x)

Found more than One contract per file. 4 contracts found!

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);
}
Expand Down Expand Up @@ -74,7 +76,7 @@
function test_EmitEvent(string memory _greeting) public {
vm.assume(keccak256(bytes(_greeting)) != _emptyString);

_expectEmitNoIndex();
vm.expectEmit(false, false, false, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't hurt to always check the indexed parameters and the source of the event.

Suggested change
vm.expectEmit(false, false, false, true);
vm.expectEmit(true, true, true, true, address(_greeter));

emit GreetingSet(_greeting);

_greeter.setGreeting(_greeting);
Expand Down
67 changes: 0 additions & 67 deletions solidity/test/utils/DSTestFull.sol

This file was deleted.

10 changes: 3 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1073,9 +1073,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.5.6":
version "1.5.6"
resolved "https://codeload.github.com/foundry-rs/forge-std/tar.gz/e8a047e3f40f13fa37af6fe14e6e06283d9a060e"
"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"

fs-extra@^11.0.0:
version "11.1.1"
Expand Down Expand Up @@ -1942,10 +1942,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#a245c71":
version "0.6.0"
resolved "https://codeload.github.com/paulrberg/prb-test/tar.gz/a245c71edc07643aedfe27df4cc7b21048aa8824"

prelude-ls@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
Expand Down