-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Migrate Ownable tests #4657
Merged
Merged
Migrate Ownable tests #4657
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
cf3c377
migrate Ownable tests to ethers
Amxx 673ff79
fix lint
Amxx c9b4e8d
Update hardhat.config.js
Amxx c46a45e
add Ownable2Step
Amxx 328a344
remove deploy helper
Amxx 7c12232
add deprecation notices
Amxx 517ad87
up
Amxx 9002e5f
up
Amxx 74558f8
remove .address when doing ethers call that support addressable
Amxx 9ea2db1
Fix flaky test in ERC2981.behavior
ernestognw fd7100a
Update test/access/Ownable.test.js
Amxx 1a9a046
Update test/access/Ownable.test.js
Amxx b569ca8
Fix lint
ernestognw b24fec4
Fix upgradeable tests
ernestognw 5e96021
redesign signers/fixture
Amxx f382329
Fix vanilla tests by overriding require and readArtifact with sync an…
ernestognw 95be46d
Revert "redesign signers/fixture"
Amxx 55b0406
Optimize ethers.getSigners call by passing a promise to use within fi…
ernestognw e45e482
Slice ethers accounts
ernestognw b391c2f
rename
Amxx 74bab81
override hre.ethers.getSigners
Amxx 98e5ecd
unify coding style/naming between env-contracts.js and env-artifacts.js
Amxx 4db1800
Attempt to fix tests by avoid overriding `this` in Truffle require
ernestognw 0a8a69d
Revert "Attempt to fix tests by avoid overriding `this` in Truffle re…
Amxx ec3bfc5
Merge branch 'master' into test/migration/ownable
Amxx 5d5a150
Force compile on upgradeable and coverage workflows
Amxx 300fa1e
use cached getSigners() in fixtures
Amxx ae4381e
use describe instead of contract for ethers test that don't need the …
Amxx b02770e
add enviornment sanity check
Amxx 4e6a1ca
skip signer slice when running coverage
Amxx 69b91a0
up
Amxx 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
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
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
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,24 +1,40 @@ | ||
extendEnvironment(env => { | ||
const { contract } = env; | ||
// Remove the default account from the accounts list used in tests, in order | ||
// to protect tests against accidentally passing due to the contract | ||
// deployer being used subsequently as function caller | ||
// | ||
// This operation affects: | ||
// - the accounts (and signersAsPromise) parameters of `contract` blocks | ||
// - the return of hre.ethers.getSigners() | ||
extendEnvironment(hre => { | ||
// TODO: replace with a mocha root hook. | ||
// (see https://github.com/sc-forks/solidity-coverage/issues/819#issuecomment-1762963679) | ||
if (!process.env.COVERAGE) { | ||
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. Honestly I don't see how to use these hooks because they require using a |
||
// override hre.ethers.getSigner() | ||
// note that we don't just discard the first signer, we also cache the value to improve speed. | ||
const originalGetSigners = hre.ethers.getSigners; | ||
const filteredSignersAsPromise = originalGetSigners().then(signers => signers.slice(1)); | ||
hre.ethers.getSigners = () => filteredSignersAsPromise; | ||
} | ||
|
||
env.contract = function (name, body) { | ||
const { takeSnapshot } = require('@nomicfoundation/hardhat-network-helpers'); | ||
|
||
contract(name, accounts => { | ||
// reset the state of the chain in between contract test suites | ||
// override hre.contract | ||
const originalContract = hre.contract; | ||
hre.contract = function (name, body) { | ||
originalContract.call(this, name, accounts => { | ||
let snapshot; | ||
|
||
before(async function () { | ||
// reset the state of the chain in between contract test suites | ||
// TODO: this should be removed when migration to ethers is over | ||
const { takeSnapshot } = require('@nomicfoundation/hardhat-network-helpers'); | ||
snapshot = await takeSnapshot(); | ||
}); | ||
|
||
after(async function () { | ||
// reset the state of the chain in between contract test suites | ||
// TODO: this should be removed when migration to ethers is over | ||
await snapshot.restore(); | ||
}); | ||
|
||
// remove the default account from the accounts list used in tests, in order | ||
// to protect tests against accidentally passing due to the contract | ||
// deployer being used subsequently as function caller | ||
body(accounts.slice(1)); | ||
}); | ||
}; | ||
|
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.
I don't think this is needed because the
solcover.js
config specifies thatcompileCommand: 'npm run compile'
. Are you sure this actually did something?Just curious, we can leave if it'll be removed at the end of the migration
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.
I'm not sure it actually does somthing. I just added that to all workflows
Lets see if we can remove them after the migration.