Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
b425a72
Replace revert strings with custom errors (#4261)
ernestognw Jun 12, 2023
4c1cd22
Minimal Forwarder
ernestognw Jun 13, 2023
fe08f58
Update README.md (#4335)
zackrw Jun 13, 2023
2432d0d
Add changeset
ernestognw Jun 13, 2023
d6c7cee
Update index.adoc (#4336)
zackrw Jun 13, 2023
6a87cec
Fix ERC2771 tests
ernestognw Jun 14, 2023
6040254
Add EIP-712 `name` and `version` getters (#4303)
RenanSouza2 Jun 14, 2023
7cc2cbf
Cleanup the structure of GovernorTimelockControl.test.js (#4302)
Amxx Jun 14, 2023
5cc1ea0
Add `GUIDELINES.md` for marking `abstract` contracts (#4010)
ernestognw Jun 14, 2023
ef103f3
Replace some uses of abi.encodePacked with more explicit alternatives…
Amxx Jun 14, 2023
ac5480e
Merge release-v4.9 branch (#4352)
ernestognw Jun 14, 2023
2477534
Change behavior of ceilDiv(0, 0) and improve test coverage (#4348)
ernestognw Jun 14, 2023
05ef692
Optimize array access in ERC1155 (#4300)
clauBv23 Jun 15, 2023
ff85c7b
Make ERC1967Upgrades a library instead of an abstract contract (#4325)
Amxx Jun 15, 2023
c014c8f
Use ERC721Holder & ERC1155Holder in the TimelockController (#4284)
Amxx Jun 15, 2023
6724873
Output contract name where storage inconsistency was found (#4357)
Amxx Jun 15, 2023
cd48b3e
Add validation in Governor on ERC-721 or ERC-1155 received (#4314)
clauBv23 Jun 16, 2023
002a7c8
Remove automatic conflict resolution for merge from release branch (#…
frangio Jun 16, 2023
1a77a50
Move upgradeToAndCallUUPS to UUPSUpgradeable (#4356)
Amxx Jun 17, 2023
c95a445
Detect MerkleProof multiproof invariant violation (#4367)
frangio Jun 19, 2023
fc19a79
Change release cycle `prBackExists` definition (#4365)
ernestognw Jun 19, 2023
1f4e33f
Add toStringSigned to Strings.sol (#4330)
balajipachai Jun 19, 2023
1d0dbcf
Make `TransparentUpgradeableProxy` admin immutable (#4354)
ernestognw Jun 20, 2023
365aca6
Improve tests for ERC1155 and ERC721 error handling (#3781)
Amxx Jun 20, 2023
2271e2c
Use clones for testing non ERC1967 proxies (#4371)
Amxx Jun 20, 2023
9fa550c
Fix attempt to delete nonexistent npm tag (#4374)
frangio Jun 20, 2023
b66c77a
Merge branch 'release-v4.9' into master (#4373)
frangio Jun 20, 2023
dac2457
Improve customError testing (#4376)
Amxx Jun 20, 2023
6ddacdb
Cleanup timelockId on execution for gas refund (#4118)
Amxx Jun 20, 2023
16b9ea8
Add batching and better explain gas forwarding check
ernestognw Jun 20, 2023
7c5d038
Lint
ernestognw Jun 20, 2023
5662e35
Applied suggestions
ernestognw Jun 20, 2023
d1c75c8
Fix test
ernestognw Jun 20, 2023
dff9998
Complete tests
ernestognw Jun 21, 2023
8da57ef
Improve testing
ernestognw Jun 21, 2023
1e0e4e2
Do not emit Approval event when calling transferFrom (#4370)
Amxx Jun 22, 2023
a7a94c7
Update comment to reflect code logic in Ownable.sol (#4369)
s-tikhomirov Jun 22, 2023
5978b7e
Rename MinimalForwarder to ERC2771Forwarder
ernestognw Jun 23, 2023
3d5fe68
Avoid revert on nonce mismatch
ernestognw Jun 23, 2023
c781b6b
Use _validate in _execute
ernestognw Jun 23, 2023
da89c43
Pack Governor's ProposalCore into a single slot (#4268)
Amxx Jun 23, 2023
f5987eb
Use timestamp instead of block number
ernestognw Jun 23, 2023
c44c220
Update Ownable2Step docs (#4384)
RenanSouza2 Jun 23, 2023
e59d707
Merge branch 'master' into lib-643-production-ready-minimal-forwarder-2
ernestognw Jun 24, 2023
87e77b1
Apply suggestions
ernestognw Jun 24, 2023
bdd061d
Pack signature into request
ernestognw Jun 24, 2023
376f3b2
Fix ERC2771Context tests
ernestognw Jun 24, 2023
cb4bf95
Add unreleased disclaimer in readme
frangio Jun 24, 2023
8cab922
Rename `ERC1155InsufficientApprovalForAll` to `ERC1155MissingApproval…
ernestognw Jun 26, 2023
f29307c
Add Foundry installation instructions with required warnings (#4389)
frangio Jun 26, 2023
1ba8173
Merge branch 'master' into lib-643-production-ready-minimal-forwarder-2
ernestognw Jun 26, 2023
b94a100
Improve comments in _checkForwardedGas
ernestognw Jun 27, 2023
85acfdf
Remove returndata
ernestognw Jun 27, 2023
74d5961
Fix ETH left
ernestognw Jun 27, 2023
c62d927
Changed note
ernestognw Jun 27, 2023
daafff8
Fix codespell
ernestognw Jun 27, 2023
f3d5b44
Fix ETH left in the contract
ernestognw Jun 27, 2023
cb8690e
Fix nonces
ernestognw Jun 27, 2023
68ce4eb
Avoid reentrancy
ernestognw Jun 27, 2023
99a26c4
Apply suggestion
ernestognw Jun 27, 2023
be93a80
Apply suggestion
ernestognw Jun 27, 2023
5c039ea
Improve tests
ernestognw Jun 28, 2023
b7b985e
Remove flaky test
ernestognw Jun 28, 2023
8f84f4e
Hardcode slither version to 0.9.3
ernestognw Jun 28, 2023
8a03cad
Revert on unsuccessful execute
ernestognw Jun 28, 2023
95bcb57
Implement suggestions
ernestognw Jun 29, 2023
8b7e961
tweak proof wording
frangio Jun 29, 2023
f72c2d5
change ETH -> value
frangio Jun 29, 2023
62d2342
adjust comment after recent change
frangio Jun 29, 2023
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
Prev Previous commit
Next Next commit
Improve customError testing (OpenZeppelin#4376)
  • Loading branch information
Amxx authored Jun 20, 2023
commit dac2457a800aaa3d75b7fc999d0c7c323ec2faff
71 changes: 36 additions & 35 deletions test/helpers/customError.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,43 @@ const { expect } = require('chai');

/** Revert handler that supports custom errors. */
async function expectRevertCustomError(promise, expectedErrorName, args) {
try {
await promise;
expect.fail("Expected promise to throw but it didn't");
} catch (revert) {
if (!Array.isArray(args)) {
expect.fail('Expected 3rd array parameter for error arguments');
}
// The revert message for custom errors looks like:
// VM Exception while processing transaction:
// reverted with custom error 'InvalidAccountNonce("0x70997970C51812dc3A010C7d01b50e0d17dc79C8", 0)'

// We trim out anything inside the single quotes as comma-separated values
const [, error] = revert.message.match(/'(.*)'/);

// Attempt to parse as an error
const match = error.match(/(?<name>\w+)\((?<args>.*)\)/);
if (!match) {
expect.fail(`Couldn't parse "${error}" as a custom error`);
}
// Extract the error name and parameters
const errorName = match.groups.name;
const argMatches = [...match.groups.args.matchAll(/-?\w+/g)];

// Assert error name
expect(errorName).to.be.equal(
expectedErrorName,
`Unexpected custom error name (with found args: [${argMatches.map(([a]) => a)}])`,
);

// Coerce to string for comparison since `arg` can be either a number or hex.
const sanitizedExpected = args.map(arg => arg.toString().toLowerCase());
const sanitizedActual = argMatches.map(([arg]) => arg.toString().toLowerCase());

// Assert argument equality
expect(sanitizedActual).to.have.members(sanitizedExpected, `Unexpected ${errorName} arguments`);
if (!Array.isArray(args)) {
expect.fail('Expected 3rd array parameter for error arguments');
}

await promise.then(
() => expect.fail("Expected promise to throw but it didn't"),
({ message }) => {
// The revert message for custom errors looks like:
// VM Exception while processing transaction:
// reverted with custom error 'InvalidAccountNonce("0x70997970C51812dc3A010C7d01b50e0d17dc79C8", 0)'

// We trim out anything inside the single quotes as comma-separated values
const [, error] = message.match(/'(.*)'/);

// Attempt to parse as an error
const match = error.match(/(?<name>\w+)\((?<args>.*)\)/);
if (!match) {
expect.fail(`Couldn't parse "${error}" as a custom error`);
}
// Extract the error name and parameters
const errorName = match.groups.name;
const argMatches = [...match.groups.args.matchAll(/-?\w+/g)];

// Assert error name
expect(errorName).to.be.equal(
expectedErrorName,
`Unexpected custom error name (with found args: [${argMatches.map(([a]) => a)}])`,
);

// Coerce to string for comparison since `arg` can be either a number or hex.
const sanitizedExpected = args.map(arg => arg.toString().toLowerCase());
const sanitizedActual = argMatches.map(([arg]) => arg.toString().toLowerCase());

// Assert argument equality
expect(sanitizedActual).to.have.members(sanitizedExpected, `Unexpected ${errorName} arguments`);
},
);
}

module.exports = {
Expand Down