Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: Francisco Giordano <fg@frang.io> Co-authored-by: Joseph Delong <joseph@delong.me> Co-authored-by: Arr00 <13561405+arr00@users.noreply.github.com> Co-authored-by: Renan Souza <renan.rodrigues.souza1@gmail.com>
This commit is contained in:
@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -204,6 +204,7 @@ contract MathTest is Test {
|
||||
assertEq(xyLo, qdRemLo);
|
||||
}
|
||||
|
||||
/// forge-config: default.allow_internal_expect_revert = true
|
||||
function testMulDivDomain(uint256 x, uint256 y, uint256 d) public {
|
||||
(uint256 xyHi, ) = _mulHighLow(x, y);
|
||||
|
||||
@ -216,6 +217,7 @@ contract MathTest is Test {
|
||||
}
|
||||
|
||||
// MOD EXP
|
||||
/// forge-config: default.allow_internal_expect_revert = true
|
||||
function testModExp(uint256 b, uint256 e, uint256 m) public {
|
||||
if (m == 0) {
|
||||
vm.expectRevert(stdError.divisionError);
|
||||
@ -236,6 +238,7 @@ contract MathTest is Test {
|
||||
}
|
||||
}
|
||||
|
||||
/// forge-config: default.allow_internal_expect_revert = true
|
||||
function testModExpMemory(uint256 b, uint256 e, uint256 m) public {
|
||||
if (m == 0) {
|
||||
vm.expectRevert(stdError.divisionError);
|
||||
|
||||
Reference in New Issue
Block a user