-
Notifications
You must be signed in to change notification settings - Fork 375
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
refactor(tests/e2e-evm): Restructure ABI tests for extensibility & reduce duplication #2031
Open
drklee3
wants to merge
11
commits into
nd-implement-basic-precompile-calling
Choose a base branch
from
dl-e2e-abi-tests-refactor
base: nd-implement-basic-precompile-calling
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dd9b489
refactor: Initial restructure of ABI basic function tests
drklee3 5737b3b
refactor: Restructure of ABI fallback tests
drklee3 b184907
fix: Use separate shouldRun fn signatures for fallback tests
drklee3 815415c
fix: Resolve use of type assertions, enforcing types
drklee3 7ec0ffe
refactor: Rename unused params in test cases
drklee3 4df0c17
refactor: Dynamic generation basic ABI test cases
drklee3 cd15cde
refactor: Resolve ABI disabled types & errors
drklee3 0f248d2
refactor: Only test receive, fallback funcs when available
drklee3 8a90bbc
lint: Ignore solhint issues for mock contracts
drklee3 1d98340
refactor: Remove unused empty ContractTestCase generic brackets
drklee3 70f72d8
chore: Disable chai assertion error truncation
drklee3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": "solhint:recommended" | ||
"extends": "solhint:recommended", | ||
"rules": { | ||
"func-visibility": ["warn", { "ignoreConstructors": true }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,10 @@ contract Caller { | |
(bool success, bytes memory result) = to.call{value: msg.value}(data); | ||
|
||
if (!success) { | ||
if (result.length == 0) revert(); | ||
// solhint-disable-next-line gas-custom-errors | ||
if (result.length == 0) revert("reverted with no reason"); | ||
|
||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
revert(add(32, result), mload(result)) | ||
} | ||
|
@@ -24,11 +26,14 @@ contract Caller { | |
// TODO: Callcode | ||
|
||
function functionDelegateCall(address to, bytes calldata data) external { | ||
// solhint-disable-next-line avoid-low-level-calls | ||
(bool success, bytes memory result) = to.delegatecall(data); | ||
|
||
if (!success) { | ||
if (result.length == 0) revert(); | ||
// solhint-disable-next-line gas-custom-errors | ||
if (result.length == 0) revert("reverted with no reason"); | ||
|
||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
revert(add(32, result), mload(result)) | ||
} | ||
|
@@ -39,8 +44,10 @@ contract Caller { | |
(bool success, bytes memory result) = to.staticcall(data); | ||
|
||
if (!success) { | ||
if (result.length == 0) revert(); | ||
// solhint-disable-next-line gas-custom-errors | ||
if (result.length == 0) revert("reverted with no reason"); | ||
|
||
// solhint-disable-next-line no-inline-assembly | ||
assembly { | ||
revert(add(32, result), mload(result)) | ||
} | ||
|
@@ -52,7 +59,7 @@ contract Caller { | |
// High level caller | ||
// | ||
contract NoopCaller { | ||
NoopNoReceiveNoFallback target; | ||
NoopNoReceiveNoFallback private target; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice reduction in scope 👍 |
||
|
||
constructor(NoopNoReceiveNoFallback _target) { | ||
target = _target; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "./ABI_BasicTests.sol"; | ||
import "./ABI_BasicTests.sol" as ABI_BasicTests; | ||
|
||
// | ||
// Disabled contract that is payable and callable with any calldata (receive + fallback) | ||
// | ||
contract NoopDisabledMock is NoopReceivePayableFallback{ | ||
contract NoopDisabledMock is ABI_BasicTests.NoopReceivePayableFallback { | ||
// solc-ignore-next-line func-mutability | ||
function noopNonpayable() external { | ||
mockRevert(); | ||
mockRevert(); | ||
} | ||
function noopPayable() external payable { | ||
mockRevert(); | ||
mockRevert(); | ||
} | ||
// solc-ignore-next-line func-mutability | ||
function noopView() external view { | ||
mockRevert(); | ||
mockRevert(); | ||
} | ||
function noopPure() external pure { | ||
mockRevert(); | ||
mockRevert(); | ||
} | ||
receive() external payable { | ||
mockRevert(); | ||
mockRevert(); | ||
} | ||
fallback() external payable { | ||
mockRevert(); | ||
mockRevert(); | ||
} | ||
|
||
// | ||
// Mimic revert + revert reason | ||
// | ||
function mockRevert() private pure { | ||
revert("call not allowed to disabled contract"); | ||
// solhint-disable-next-line reason-string, gas-custom-errors | ||
revert("call not allowed to disabled contract"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import "hardhat-ignore-warnings"; | |
// Chai setup | ||
// | ||
chai.use(chaiAsPromised); | ||
chai.config.truncateThreshold = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ Idk why I didn't find this setting, so much nicer without any truncation |
||
|
||
// | ||
// Load HRE extensions | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true for Solidity >=0.7.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tyty I did not know about this configuration