Merge branch 'master' into typo-fixes

pull/5510/head^2
Hadrien Croubois 5 days ago committed by GitHub
commit 64954d83da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/gorgeous-apes-jam.md
  2. 2
      contracts/governance/TimelockController.sol
  3. 1
      hardhat.config.js
  4. 12
      test/helpers/precompiles.js
  5. 28
      test/utils/cryptography/SignatureChecker.test.js

@ -0,0 +1,5 @@
---
'openzeppelin-solidity': minor
---
`TimelockController`: Receive function is now virtual.

@ -152,7 +152,7 @@ contract TimelockController is AccessControl, ERC721Holder, ERC1155Holder {
/**
* @dev Contract might receive/hold ETH as part of the maintenance process.
*/
receive() external payable {}
receive() external payable virtual {}
/**
* @dev See {IERC165-supportsInterface}.

@ -90,7 +90,6 @@ module.exports = {
'initcode-size': 'off',
},
'*': {
'code-size': true,
'unused-param': !argv.coverage, // coverage causes unused-param warnings
'transient-storage': false,
default: 'error',

@ -0,0 +1,12 @@
module.exports = {
ecRecover: '0x0000000000000000000000000000000000000001',
SHA2_256: '0x0000000000000000000000000000000000000002',
RIPEMD_160: '0x0000000000000000000000000000000000000003',
identity: '0x0000000000000000000000000000000000000004',
modexp: '0x0000000000000000000000000000000000000005',
ecAdd: '0x0000000000000000000000000000000000000006',
ecMul: '0x0000000000000000000000000000000000000007',
ecPairing: '0x0000000000000000000000000000000000000008',
blake2f: '0x0000000000000000000000000000000000000009',
pointEvaluation: '0x000000000000000000000000000000000000000a',
};

@ -2,6 +2,8 @@ const { ethers } = require('hardhat');
const { expect } = require('chai');
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers');
const precompile = require('../../helpers/precompiles');
const TEST_MESSAGE = ethers.id('OpenZeppelin');
const TEST_MESSAGE_HASH = ethers.hashMessage(TEST_MESSAGE);
@ -25,15 +27,18 @@ describe('SignatureChecker (ERC1271)', function () {
describe('EOA account', function () {
it('with matching signer and signature', async function () {
expect(await this.mock.$isValidSignatureNow(this.signer, TEST_MESSAGE_HASH, this.signature)).to.be.true;
await expect(this.mock.$isValidSignatureNow(this.signer, TEST_MESSAGE_HASH, this.signature)).to.eventually.be
.true;
});
it('with invalid signer', async function () {
expect(await this.mock.$isValidSignatureNow(this.other, TEST_MESSAGE_HASH, this.signature)).to.be.false;
await expect(this.mock.$isValidSignatureNow(this.other, TEST_MESSAGE_HASH, this.signature)).to.eventually.be
.false;
});
it('with invalid signature', async function () {
expect(await this.mock.$isValidSignatureNow(this.signer, WRONG_MESSAGE_HASH, this.signature)).to.be.false;
await expect(this.mock.$isValidSignatureNow(this.signer, WRONG_MESSAGE_HASH, this.signature)).to.eventually.be
.false;
});
});
@ -41,19 +46,28 @@ describe('SignatureChecker (ERC1271)', function () {
for (const fn of ['isValidERC1271SignatureNow', 'isValidSignatureNow']) {
describe(fn, function () {
it('with matching signer and signature', async function () {
expect(await this.mock.getFunction(`$${fn}`)(this.wallet, TEST_MESSAGE_HASH, this.signature)).to.be.true;
await expect(this.mock.getFunction(`$${fn}`)(this.wallet, TEST_MESSAGE_HASH, this.signature)).to.eventually.be
.true;
});
it('with invalid signer', async function () {
expect(await this.mock.getFunction(`$${fn}`)(this.mock, TEST_MESSAGE_HASH, this.signature)).to.be.false;
await expect(this.mock.getFunction(`$${fn}`)(this.mock, TEST_MESSAGE_HASH, this.signature)).to.eventually.be
.false;
});
it('with identity precompile', async function () {
await expect(this.mock.getFunction(`$${fn}`)(precompile.identity, TEST_MESSAGE_HASH, this.signature)).to
.eventually.be.false;
});
it('with invalid signature', async function () {
expect(await this.mock.getFunction(`$${fn}`)(this.wallet, WRONG_MESSAGE_HASH, this.signature)).to.be.false;
await expect(this.mock.getFunction(`$${fn}`)(this.wallet, WRONG_MESSAGE_HASH, this.signature)).to.eventually
.be.false;
});
it('with malicious wallet', async function () {
expect(await this.mock.getFunction(`$${fn}`)(this.malicious, TEST_MESSAGE_HASH, this.signature)).to.be.false;
await expect(this.mock.getFunction(`$${fn}`)(this.malicious, TEST_MESSAGE_HASH, this.signature)).to.eventually
.be.false;
});
});
}

Loading…
Cancel
Save