Use hardhat-exposed to reduce the need for mocks (#3666)
Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
@ -3,7 +3,7 @@ const { toEthSignedMessageHash } = require('../../helpers/sign');
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const ECDSAMock = artifacts.require('ECDSAMock');
|
||||
const ECDSA = artifacts.require('$ECDSA');
|
||||
|
||||
const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin');
|
||||
const WRONG_MESSAGE = web3.utils.sha3('Nope');
|
||||
@ -45,18 +45,18 @@ contract('ECDSA', function (accounts) {
|
||||
const [ other ] = accounts;
|
||||
|
||||
beforeEach(async function () {
|
||||
this.ecdsa = await ECDSAMock.new();
|
||||
this.ecdsa = await ECDSA.new();
|
||||
});
|
||||
|
||||
context('recover with invalid signature', function () {
|
||||
it('with short signature', async function () {
|
||||
await expectRevert(this.ecdsa.recover(TEST_MESSAGE, '0x1234'), 'ECDSA: invalid signature length');
|
||||
await expectRevert(this.ecdsa.$recover(TEST_MESSAGE, '0x1234'), 'ECDSA: invalid signature length');
|
||||
});
|
||||
|
||||
it('with long signature', async function () {
|
||||
await expectRevert(
|
||||
// eslint-disable-next-line max-len
|
||||
this.ecdsa.recover(TEST_MESSAGE, '0x01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),
|
||||
this.ecdsa.$recover(TEST_MESSAGE, '0x01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'),
|
||||
'ECDSA: invalid signature length',
|
||||
);
|
||||
});
|
||||
@ -69,7 +69,7 @@ contract('ECDSA', function (accounts) {
|
||||
const signature = await web3.eth.sign(TEST_MESSAGE, other);
|
||||
|
||||
// Recover the signer address from the generated message and signature.
|
||||
expect(await this.ecdsa.recover(
|
||||
expect(await this.ecdsa.$recover(
|
||||
toEthSignedMessageHash(TEST_MESSAGE),
|
||||
signature,
|
||||
)).to.equal(other);
|
||||
@ -80,7 +80,7 @@ contract('ECDSA', function (accounts) {
|
||||
const signature = await web3.eth.sign(NON_HASH_MESSAGE, other);
|
||||
|
||||
// Recover the signer address from the generated message and signature.
|
||||
expect(await this.ecdsa.recover(
|
||||
expect(await this.ecdsa.$recover(
|
||||
toEthSignedMessageHash(NON_HASH_MESSAGE),
|
||||
signature,
|
||||
)).to.equal(other);
|
||||
@ -88,13 +88,13 @@ contract('ECDSA', function (accounts) {
|
||||
|
||||
it('returns a different address', async function () {
|
||||
const signature = await web3.eth.sign(TEST_MESSAGE, other);
|
||||
expect(await this.ecdsa.recover(WRONG_MESSAGE, signature)).to.not.equal(other);
|
||||
expect(await this.ecdsa.$recover(WRONG_MESSAGE, signature)).to.not.equal(other);
|
||||
});
|
||||
|
||||
it('reverts with invalid signature', async function () {
|
||||
// eslint-disable-next-line max-len
|
||||
const signature = '0x332ce75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e01c';
|
||||
await expectRevert(this.ecdsa.recover(TEST_MESSAGE, signature), 'ECDSA: invalid signature');
|
||||
await expectRevert(this.ecdsa.$recover(TEST_MESSAGE, signature), 'ECDSA: invalid signature');
|
||||
});
|
||||
});
|
||||
|
||||
@ -107,24 +107,53 @@ contract('ECDSA', function (accounts) {
|
||||
it('works with correct v value', async function () {
|
||||
const v = '1b'; // 27 = 1b.
|
||||
const signature = signatureWithoutV + v;
|
||||
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(signer);
|
||||
expect(await this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(signature))).to.equal(signer);
|
||||
expect(await this.ecdsa.recover_r_vs(TEST_MESSAGE, ...split(to2098Format(signature)))).to.equal(signer);
|
||||
expect(await this.ecdsa.$recover(
|
||||
TEST_MESSAGE,
|
||||
signature,
|
||||
)).to.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(signature),
|
||||
)).to.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(to2098Format(signature)),
|
||||
)).to.equal(signer);
|
||||
});
|
||||
|
||||
it('rejects incorrect v value', async function () {
|
||||
const v = '1c'; // 28 = 1c.
|
||||
const signature = signatureWithoutV + v;
|
||||
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.not.equal(signer);
|
||||
expect(await this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(signature))).to.not.equal(signer);
|
||||
expect(await this.ecdsa.recover_r_vs(TEST_MESSAGE, ...split(to2098Format(signature)))).to.not.equal(signer);
|
||||
expect(await this.ecdsa.$recover(
|
||||
TEST_MESSAGE,
|
||||
signature,
|
||||
)).to.not.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(signature),
|
||||
)).to.not.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(to2098Format(signature)),
|
||||
)).to.not.equal(signer);
|
||||
});
|
||||
|
||||
it('reverts wrong v values', async function () {
|
||||
for (const v of ['00', '01']) {
|
||||
const signature = signatureWithoutV + v;
|
||||
await expectRevert(this.ecdsa.recover(TEST_MESSAGE, signature), 'ECDSA: invalid signature');
|
||||
await expectRevert(this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(signature)), 'ECDSA: invalid signature');
|
||||
await expectRevert(
|
||||
this.ecdsa.$recover(TEST_MESSAGE, signature),
|
||||
'ECDSA: invalid signature',
|
||||
);
|
||||
|
||||
await expectRevert(
|
||||
this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](TEST_MESSAGE, ...split(signature)),
|
||||
'ECDSA: invalid signature',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@ -132,7 +161,7 @@ contract('ECDSA', function (accounts) {
|
||||
const v = '1b'; // 27 = 1b.
|
||||
const signature = signatureWithoutV + v;
|
||||
await expectRevert(
|
||||
this.ecdsa.recover(TEST_MESSAGE, to2098Format(signature)),
|
||||
this.ecdsa.$recover(TEST_MESSAGE, to2098Format(signature)),
|
||||
'ECDSA: invalid signature length',
|
||||
);
|
||||
});
|
||||
@ -146,24 +175,53 @@ contract('ECDSA', function (accounts) {
|
||||
it('works with correct v value', async function () {
|
||||
const v = '1c'; // 28 = 1c.
|
||||
const signature = signatureWithoutV + v;
|
||||
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.equal(signer);
|
||||
expect(await this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(signature))).to.equal(signer);
|
||||
expect(await this.ecdsa.recover_r_vs(TEST_MESSAGE, ...split(to2098Format(signature)))).to.equal(signer);
|
||||
expect(await this.ecdsa.$recover(
|
||||
TEST_MESSAGE,
|
||||
signature,
|
||||
)).to.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(signature),
|
||||
)).to.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(to2098Format(signature)),
|
||||
)).to.equal(signer);
|
||||
});
|
||||
|
||||
it('rejects incorrect v value', async function () {
|
||||
const v = '1b'; // 27 = 1b.
|
||||
const signature = signatureWithoutV + v;
|
||||
expect(await this.ecdsa.recover(TEST_MESSAGE, signature)).to.not.equal(signer);
|
||||
expect(await this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(signature))).to.not.equal(signer);
|
||||
expect(await this.ecdsa.recover_r_vs(TEST_MESSAGE, ...split(to2098Format(signature)))).to.not.equal(signer);
|
||||
expect(await this.ecdsa.$recover(
|
||||
TEST_MESSAGE,
|
||||
signature,
|
||||
)).to.not.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(signature),
|
||||
)).to.not.equal(signer);
|
||||
|
||||
expect(await this.ecdsa.methods['$recover(bytes32,bytes32,bytes32)'](
|
||||
TEST_MESSAGE,
|
||||
...split(to2098Format(signature)),
|
||||
)).to.not.equal(signer);
|
||||
});
|
||||
|
||||
it('reverts invalid v values', async function () {
|
||||
for (const v of ['00', '01']) {
|
||||
const signature = signatureWithoutV + v;
|
||||
await expectRevert(this.ecdsa.recover(TEST_MESSAGE, signature), 'ECDSA: invalid signature');
|
||||
await expectRevert(this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(signature)), 'ECDSA: invalid signature');
|
||||
await expectRevert(
|
||||
this.ecdsa.$recover(TEST_MESSAGE, signature),
|
||||
'ECDSA: invalid signature',
|
||||
);
|
||||
|
||||
await expectRevert(
|
||||
this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](TEST_MESSAGE, ...split(signature)),
|
||||
'ECDSA: invalid signature',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@ -171,7 +229,7 @@ contract('ECDSA', function (accounts) {
|
||||
const v = '1c'; // 27 = 1b.
|
||||
const signature = signatureWithoutV + v;
|
||||
await expectRevert(
|
||||
this.ecdsa.recover(TEST_MESSAGE, to2098Format(signature)),
|
||||
this.ecdsa.$recover(TEST_MESSAGE, to2098Format(signature)),
|
||||
'ECDSA: invalid signature length',
|
||||
);
|
||||
});
|
||||
@ -181,9 +239,9 @@ contract('ECDSA', function (accounts) {
|
||||
const message = '0xb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9';
|
||||
// eslint-disable-next-line max-len
|
||||
const highSSignature = '0xe742ff452d41413616a5bf43fe15dd88294e983d3d36206c2712f39083d638bde0a0fc89be718fbc1033e1d30d78be1c68081562ed2e97af876f286f3453231d1b';
|
||||
await expectRevert(this.ecdsa.recover(message, highSSignature), 'ECDSA: invalid signature \'s\' value');
|
||||
await expectRevert(this.ecdsa.$recover(message, highSSignature), 'ECDSA: invalid signature \'s\' value');
|
||||
await expectRevert(
|
||||
this.ecdsa.recover_v_r_s(TEST_MESSAGE, ...split(highSSignature)),
|
||||
this.ecdsa.methods['$recover(bytes32,uint8,bytes32,bytes32)'](TEST_MESSAGE, ...split(highSSignature)),
|
||||
'ECDSA: invalid signature \'s\' value',
|
||||
);
|
||||
expect(() => to2098Format(highSSignature)).to.throw('invalid signature \'s\' value');
|
||||
@ -192,12 +250,12 @@ contract('ECDSA', function (accounts) {
|
||||
|
||||
context('toEthSignedMessageHash', function () {
|
||||
it('prefixes bytes32 data correctly', async function () {
|
||||
expect(await this.ecdsa.methods['toEthSignedMessageHash(bytes32)'](TEST_MESSAGE))
|
||||
expect(await this.ecdsa.methods['$toEthSignedMessageHash(bytes32)'](TEST_MESSAGE))
|
||||
.to.equal(toEthSignedMessageHash(TEST_MESSAGE));
|
||||
});
|
||||
|
||||
it('prefixes dynamic length data correctly', async function () {
|
||||
expect(await this.ecdsa.methods['toEthSignedMessageHash(bytes)'](NON_HASH_MESSAGE))
|
||||
expect(await this.ecdsa.methods['$toEthSignedMessageHash(bytes)'](NON_HASH_MESSAGE))
|
||||
.to.equal(toEthSignedMessageHash(NON_HASH_MESSAGE));
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
const ethSigUtil = require('eth-sig-util');
|
||||
const Wallet = require('ethereumjs-wallet').default;
|
||||
|
||||
const { EIP712Domain, domainSeparator } = require('../../helpers/eip712');
|
||||
const { EIP712Domain, domainSeparator, hashTypedData } = require('../../helpers/eip712');
|
||||
const { getChainId } = require('../../helpers/chainid');
|
||||
|
||||
const EIP712 = artifacts.require('EIP712External');
|
||||
const EIP712Verifier = artifacts.require('$EIP712Verifier');
|
||||
|
||||
contract('EIP712', function (accounts) {
|
||||
const [mailTo] = accounts;
|
||||
@ -12,25 +13,30 @@ contract('EIP712', function (accounts) {
|
||||
const version = '1';
|
||||
|
||||
beforeEach('deploying', async function () {
|
||||
this.eip712 = await EIP712.new(name, version);
|
||||
this.eip712 = await EIP712Verifier.new(name, version);
|
||||
|
||||
// We get the chain id from the contract because Ganache (used for coverage) does not return the same chain id
|
||||
// from within the EVM as from the JSON RPC interface.
|
||||
// See https://github.com/trufflesuite/ganache-core/issues/515
|
||||
this.chainId = await this.eip712.getChainId();
|
||||
this.domain = {
|
||||
name,
|
||||
version,
|
||||
chainId: await getChainId(),
|
||||
verifyingContract: this.eip712.address,
|
||||
};
|
||||
});
|
||||
|
||||
it('domain separator', async function () {
|
||||
expect(
|
||||
await this.eip712.domainSeparator(),
|
||||
).to.equal(
|
||||
await domainSeparator(name, version, this.chainId, this.eip712.address),
|
||||
);
|
||||
const expected = await domainSeparator(this.domain);
|
||||
|
||||
expect(await this.eip712.$_domainSeparatorV4()).to.equal(expected);
|
||||
});
|
||||
|
||||
it('hash digest', async function () {
|
||||
const structhash = web3.utils.randomHex(32);
|
||||
const expected = await hashTypedData(this.domain, structhash);
|
||||
|
||||
expect(await this.eip712.$_hashTypedDataV4(structhash)).to.be.equal(expected);
|
||||
});
|
||||
|
||||
it('digest', async function () {
|
||||
const chainId = this.chainId;
|
||||
const verifyingContract = this.eip712.address;
|
||||
const message = {
|
||||
to: mailTo,
|
||||
contents: 'very interesting',
|
||||
@ -44,7 +50,7 @@ contract('EIP712', function (accounts) {
|
||||
{ name: 'contents', type: 'string' },
|
||||
],
|
||||
},
|
||||
domain: { name, version, chainId, verifyingContract },
|
||||
domain: this.domain,
|
||||
primaryType: 'Mail',
|
||||
message,
|
||||
};
|
||||
|
||||
@ -6,11 +6,11 @@ const keccak256 = require('keccak256');
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
|
||||
const MerkleProof = artifacts.require('$MerkleProof');
|
||||
|
||||
contract('MerkleProof', function () {
|
||||
beforeEach(async function () {
|
||||
this.merkleProof = await MerkleProofWrapper.new();
|
||||
this.merkleProof = await MerkleProof.new();
|
||||
});
|
||||
|
||||
describe('verify', function () {
|
||||
@ -24,15 +24,15 @@ contract('MerkleProof', function () {
|
||||
|
||||
const proof = merkleTree.getHexProof(leaf);
|
||||
|
||||
expect(await this.merkleProof.verify(proof, root, leaf)).to.equal(true);
|
||||
expect(await this.merkleProof.verifyCalldata(proof, root, leaf)).to.equal(true);
|
||||
expect(await this.merkleProof.$verify(proof, root, leaf)).to.equal(true);
|
||||
expect(await this.merkleProof.$verifyCalldata(proof, root, leaf)).to.equal(true);
|
||||
|
||||
// For demonstration, it is also possible to create valid proofs for certain 64-byte values *not* in elements:
|
||||
const noSuchLeaf = keccak256(
|
||||
Buffer.concat([keccak256(elements[0]), keccak256(elements[1])].sort(Buffer.compare)),
|
||||
);
|
||||
expect(await this.merkleProof.verify(proof.slice(1), root, noSuchLeaf)).to.equal(true);
|
||||
expect(await this.merkleProof.verifyCalldata(proof.slice(1), root, noSuchLeaf)).to.equal(true);
|
||||
expect(await this.merkleProof.$verify(proof.slice(1), root, noSuchLeaf)).to.equal(true);
|
||||
expect(await this.merkleProof.$verifyCalldata(proof.slice(1), root, noSuchLeaf)).to.equal(true);
|
||||
});
|
||||
|
||||
it('returns false for an invalid Merkle proof', async function () {
|
||||
@ -48,8 +48,8 @@ contract('MerkleProof', function () {
|
||||
|
||||
const badProof = badMerkleTree.getHexProof(badElements[0]);
|
||||
|
||||
expect(await this.merkleProof.verify(badProof, correctRoot, correctLeaf)).to.equal(false);
|
||||
expect(await this.merkleProof.verifyCalldata(badProof, correctRoot, correctLeaf)).to.equal(false);
|
||||
expect(await this.merkleProof.$verify(badProof, correctRoot, correctLeaf)).to.equal(false);
|
||||
expect(await this.merkleProof.$verifyCalldata(badProof, correctRoot, correctLeaf)).to.equal(false);
|
||||
});
|
||||
|
||||
it('returns false for a Merkle proof of invalid length', async function () {
|
||||
@ -63,8 +63,8 @@ contract('MerkleProof', function () {
|
||||
const proof = merkleTree.getHexProof(leaf);
|
||||
const badProof = proof.slice(0, proof.length - 5);
|
||||
|
||||
expect(await this.merkleProof.verify(badProof, root, leaf)).to.equal(false);
|
||||
expect(await this.merkleProof.verifyCalldata(badProof, root, leaf)).to.equal(false);
|
||||
expect(await this.merkleProof.$verify(badProof, root, leaf)).to.equal(false);
|
||||
expect(await this.merkleProof.$verifyCalldata(badProof, root, leaf)).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
@ -78,8 +78,8 @@ contract('MerkleProof', function () {
|
||||
const proof = merkleTree.getMultiProof(proofLeaves);
|
||||
const proofFlags = merkleTree.getProofFlags(proofLeaves, proof);
|
||||
|
||||
expect(await this.merkleProof.multiProofVerify(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
expect(await this.merkleProof.multiProofVerifyCalldata(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
expect(await this.merkleProof.$multiProofVerify(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
expect(await this.merkleProof.$multiProofVerifyCalldata(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
});
|
||||
|
||||
it('returns false for an invalid Merkle multi proof', async function () {
|
||||
@ -92,9 +92,9 @@ contract('MerkleProof', function () {
|
||||
const badProof = badMerkleTree.getMultiProof(badProofLeaves);
|
||||
const badProofFlags = badMerkleTree.getProofFlags(badProofLeaves, badProof);
|
||||
|
||||
expect(await this.merkleProof.multiProofVerify(badProof, badProofFlags, root, badProofLeaves))
|
||||
expect(await this.merkleProof.$multiProofVerify(badProof, badProofFlags, root, badProofLeaves))
|
||||
.to.equal(false);
|
||||
expect(await this.merkleProof.multiProofVerifyCalldata(badProof, badProofFlags, root, badProofLeaves))
|
||||
expect(await this.merkleProof.$multiProofVerifyCalldata(badProof, badProofFlags, root, badProofLeaves))
|
||||
.to.equal(false);
|
||||
});
|
||||
|
||||
@ -107,7 +107,7 @@ contract('MerkleProof', function () {
|
||||
const root = merkleTree.getRoot();
|
||||
|
||||
await expectRevert(
|
||||
this.merkleProof.multiProofVerify(
|
||||
this.merkleProof.$multiProofVerify(
|
||||
[ leaves[1], fill, merkleTree.layers[1][1] ],
|
||||
[ false, false, false ],
|
||||
root,
|
||||
@ -116,7 +116,7 @@ contract('MerkleProof', function () {
|
||||
'MerkleProof: invalid multiproof',
|
||||
);
|
||||
await expectRevert(
|
||||
this.merkleProof.multiProofVerifyCalldata(
|
||||
this.merkleProof.$multiProofVerifyCalldata(
|
||||
[ leaves[1], fill, merkleTree.layers[1][1] ],
|
||||
[ false, false, false ],
|
||||
root,
|
||||
@ -135,7 +135,7 @@ contract('MerkleProof', function () {
|
||||
const root = merkleTree.getRoot();
|
||||
|
||||
await expectRevert(
|
||||
this.merkleProof.multiProofVerify(
|
||||
this.merkleProof.$multiProofVerify(
|
||||
[ leaves[1], fill, merkleTree.layers[1][1] ],
|
||||
[ false, false, false, false ],
|
||||
root,
|
||||
@ -143,8 +143,9 @@ contract('MerkleProof', function () {
|
||||
),
|
||||
'reverted with panic code 0x32',
|
||||
);
|
||||
|
||||
await expectRevert(
|
||||
this.merkleProof.multiProofVerifyCalldata(
|
||||
this.merkleProof.$multiProofVerifyCalldata(
|
||||
[ leaves[1], fill, merkleTree.layers[1][1] ],
|
||||
[ false, false, false, false ],
|
||||
root,
|
||||
@ -163,8 +164,8 @@ contract('MerkleProof', function () {
|
||||
const proof = merkleTree.getMultiProof(proofLeaves);
|
||||
const proofFlags = merkleTree.getProofFlags(proofLeaves, proof);
|
||||
|
||||
expect(await this.merkleProof.multiProofVerify(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
expect(await this.merkleProof.multiProofVerifyCalldata(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
expect(await this.merkleProof.$multiProofVerify(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
expect(await this.merkleProof.$multiProofVerifyCalldata(proof, proofFlags, root, proofLeaves)).to.equal(true);
|
||||
});
|
||||
|
||||
it('limit case: can prove empty leaves', async function () {
|
||||
@ -172,8 +173,8 @@ contract('MerkleProof', function () {
|
||||
const merkleTree = new MerkleTree(leaves, keccak256, { sort: true });
|
||||
|
||||
const root = merkleTree.getRoot();
|
||||
expect(await this.merkleProof.multiProofVerify([ root ], [], root, [])).to.equal(true);
|
||||
expect(await this.merkleProof.multiProofVerifyCalldata([ root ], [], root, [])).to.equal(true);
|
||||
expect(await this.merkleProof.$multiProofVerify([ root ], [], root, [])).to.equal(true);
|
||||
expect(await this.merkleProof.$multiProofVerifyCalldata([ root ], [], root, [])).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -2,7 +2,7 @@ const { toEthSignedMessageHash } = require('../../helpers/sign');
|
||||
|
||||
const { expect } = require('chai');
|
||||
|
||||
const SignatureCheckerMock = artifacts.require('SignatureCheckerMock');
|
||||
const SignatureChecker = artifacts.require('$SignatureChecker');
|
||||
const ERC1271WalletMock = artifacts.require('ERC1271WalletMock');
|
||||
const ERC1271MaliciousMock = artifacts.require('ERC1271MaliciousMock');
|
||||
|
||||
@ -13,7 +13,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
const [signer, other] = accounts;
|
||||
|
||||
before('deploying', async function () {
|
||||
this.signaturechecker = await SignatureCheckerMock.new();
|
||||
this.signaturechecker = await SignatureChecker.new();
|
||||
this.wallet = await ERC1271WalletMock.new(signer);
|
||||
this.malicious = await ERC1271MaliciousMock.new();
|
||||
this.signature = await web3.eth.sign(TEST_MESSAGE, signer);
|
||||
@ -21,7 +21,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
|
||||
context('EOA account', function () {
|
||||
it('with matching signer and signature', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
signer,
|
||||
toEthSignedMessageHash(TEST_MESSAGE),
|
||||
this.signature,
|
||||
@ -29,7 +29,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
});
|
||||
|
||||
it('with invalid signer', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
other,
|
||||
toEthSignedMessageHash(TEST_MESSAGE),
|
||||
this.signature,
|
||||
@ -37,7 +37,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
});
|
||||
|
||||
it('with invalid signature', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
signer,
|
||||
toEthSignedMessageHash(WRONG_MESSAGE),
|
||||
this.signature,
|
||||
@ -47,7 +47,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
|
||||
context('ERC1271 wallet', function () {
|
||||
it('with matching signer and signature', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
this.wallet.address,
|
||||
toEthSignedMessageHash(TEST_MESSAGE),
|
||||
this.signature,
|
||||
@ -55,7 +55,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
});
|
||||
|
||||
it('with invalid signer', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
this.signaturechecker.address,
|
||||
toEthSignedMessageHash(TEST_MESSAGE),
|
||||
this.signature,
|
||||
@ -63,7 +63,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
});
|
||||
|
||||
it('with invalid signature', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
this.wallet.address,
|
||||
toEthSignedMessageHash(WRONG_MESSAGE),
|
||||
this.signature,
|
||||
@ -71,7 +71,7 @@ contract('SignatureChecker (ERC1271)', function (accounts) {
|
||||
});
|
||||
|
||||
it('with malicious wallet', async function () {
|
||||
expect(await this.signaturechecker.isValidSignatureNow(
|
||||
expect(await this.signaturechecker.$isValidSignatureNow(
|
||||
this.malicious.address,
|
||||
toEthSignedMessageHash(TEST_MESSAGE),
|
||||
this.signature,
|
||||
|
||||
Reference in New Issue
Block a user