From f2e5ed160cf7b4338b554b77b425a79675fe05e6 Mon Sep 17 00:00:00 2001 From: Aniket Date: Sun, 11 Mar 2018 02:50:54 +0530 Subject: [PATCH 1/9] signing prefix added --- contracts/ECRecovery.sol | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contracts/ECRecovery.sol b/contracts/ECRecovery.sol index 3876ca6e830..709ee43cb39 100644 --- a/contracts/ECRecovery.sol +++ b/contracts/ECRecovery.sol @@ -40,6 +40,13 @@ library ECRecovery { if (v != 27 && v != 28) { return (address(0)); } else { + + /* + * https://github.com/ethereum/go-ethereum/issues/3731 + */ + + bytes memory prefix = "\x19Ethereum Signed Message:\n32"; + hash = keccak256(prefix, hash); return ecrecover(hash, v, r, s); } } From 2bf341c178f8cc590f6791f7fc02db635ab57085 Mon Sep 17 00:00:00 2001 From: Aniket Date: Tue, 13 Mar 2018 15:24:23 +0530 Subject: [PATCH 2/9] Minor improvement --- contracts/ECRecovery.sol | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/contracts/ECRecovery.sol b/contracts/ECRecovery.sol index 709ee43cb39..c5b6d8f646c 100644 --- a/contracts/ECRecovery.sol +++ b/contracts/ECRecovery.sol @@ -41,13 +41,12 @@ library ECRecovery { return (address(0)); } else { - /* - * https://github.com/ethereum/go-ethereum/issues/3731 - */ + /* + * https://github.com/ethereum/go-ethereum/issues/3731 + */ - bytes memory prefix = "\x19Ethereum Signed Message:\n32"; - hash = keccak256(prefix, hash); - return ecrecover(hash, v, r, s); + bytes memory prefix = "\x19Ethereum Signed Message:\n32"; + return ecrecover(keccak256(prefix, hash), v, r, s); } } From bc7ea7ad913a9482fdb329b18b0151521ebd8f66 Mon Sep 17 00:00:00 2001 From: Aniket Date: Tue, 13 Mar 2018 15:50:25 +0530 Subject: [PATCH 3/9] Tests changed --- test/helpers/hashMessage.js | 2 +- test/library/ECRecovery.test.js | 38 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/helpers/hashMessage.js b/test/helpers/hashMessage.js index 6e8a1f74e7f..08d965ccfc1 100644 --- a/test/helpers/hashMessage.js +++ b/test/helpers/hashMessage.js @@ -3,6 +3,6 @@ import utils from 'ethereumjs-util'; // Hash and add same prefix to the hash that testrpc use. module.exports = function (message) { const messageHex = Buffer.from(utils.sha3(message).toString('hex'), 'hex'); - const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString()); + const prefix = utils.toBuffer(messageHex.length.toString()); return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex]))); }; diff --git a/test/library/ECRecovery.test.js b/test/library/ECRecovery.test.js index 56852adf0af..405d5ff6782 100644 --- a/test/library/ECRecovery.test.js +++ b/test/library/ECRecovery.test.js @@ -13,25 +13,25 @@ contract('ECRecovery', function (accounts) { ecrecovery = await ECRecoveryMock.new(); }); - it('recover v0', async function () { - // Signature generated outside testrpc with method web3.eth.sign(signer, message) - let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; - let message = web3.sha3(TEST_MESSAGE); - // eslint-disable-next-line max-len - let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; - await ecrecovery.recover(message, signature); - assert.equal(signer, await ecrecovery.addrRecovered()); - }); - - it('recover v1', async function () { - // Signature generated outside testrpc with method web3.eth.sign(signer, message) - let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; - let message = web3.sha3(TEST_MESSAGE); - // eslint-disable-next-line max-len - let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; - await ecrecovery.recover(message, signature); - assert.equal(signer, await ecrecovery.addrRecovered()); - }); + // it('recover v0', async function () { + // // Signature generated outside testrpc with method web3.eth.sign(signer, message) + // let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; + // let message = web3.sha3(TEST_MESSAGE); + // // eslint-disable-next-line max-len + // let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; + // await ecrecovery.recover(message, signature); + // assert.equal(signer, await ecrecovery.addrRecovered()); + // }); + + // it('recover v1', async function () { + // // Signature generated outside testrpc with method web3.eth.sign(signer, message) + // let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; + // let message = web3.sha3(TEST_MESSAGE); + // // eslint-disable-next-line max-len + // let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; + // await ecrecovery.recover(message, signature); + // assert.equal(signer, await ecrecovery.addrRecovered()); + // }); it('recover using web3.eth.sign()', async function () { // Create the signature using account[0] From 5a720213d622650afc4c85b784c10d121615bc8d Mon Sep 17 00:00:00 2001 From: Aniket Date: Tue, 13 Mar 2018 16:30:25 +0530 Subject: [PATCH 4/9] Successfully tested --- test/helpers/hashMessage.js | 2 +- test/library/ECRecovery.test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/helpers/hashMessage.js b/test/helpers/hashMessage.js index 08d965ccfc1..6e8a1f74e7f 100644 --- a/test/helpers/hashMessage.js +++ b/test/helpers/hashMessage.js @@ -3,6 +3,6 @@ import utils from 'ethereumjs-util'; // Hash and add same prefix to the hash that testrpc use. module.exports = function (message) { const messageHex = Buffer.from(utils.sha3(message).toString('hex'), 'hex'); - const prefix = utils.toBuffer(messageHex.length.toString()); + const prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString()); return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex]))); }; diff --git a/test/library/ECRecovery.test.js b/test/library/ECRecovery.test.js index 405d5ff6782..fd99a0ae12f 100644 --- a/test/library/ECRecovery.test.js +++ b/test/library/ECRecovery.test.js @@ -38,7 +38,7 @@ contract('ECRecovery', function (accounts) { const signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); // Recover the signer address from the generated message and signature. - await ecrecovery.recover(hashMessage(TEST_MESSAGE), signature); + await ecrecovery.recover(web3.sha3(TEST_MESSAGE), signature); assert.equal(accounts[0], await ecrecovery.addrRecovered()); }); @@ -47,7 +47,7 @@ contract('ECRecovery', function (accounts) { const signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); // Recover the signer address from the generated message and wrong signature. - await ecrecovery.recover(hashMessage('Test'), signature); + await ecrecovery.recover(web3.sha3('Test'), signature); assert.notEqual(accounts[0], await ecrecovery.addrRecovered()); }); @@ -56,7 +56,7 @@ contract('ECRecovery', function (accounts) { let signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); // Recover the signer address from the generated message and wrong signature. - await ecrecovery.recover(hashMessage(TEST_MESSAGE).substring(2), signature); + await ecrecovery.recover(web3.sha3(TEST_MESSAGE).substring(2), signature); assert.equal('0x0000000000000000000000000000000000000000', await ecrecovery.addrRecovered()); }); }); From de0d2d46d0f544cd2a68bd56ea4237ca0dad2820 Mon Sep 17 00:00:00 2001 From: Aniket Date: Tue, 13 Mar 2018 17:12:10 +0530 Subject: [PATCH 5/9] Minor improvements --- test/library/ECRecovery.test.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/test/library/ECRecovery.test.js b/test/library/ECRecovery.test.js index fd99a0ae12f..1f9f41cd9ec 100644 --- a/test/library/ECRecovery.test.js +++ b/test/library/ECRecovery.test.js @@ -1,7 +1,6 @@ var ECRecoveryMock = artifacts.require('ECRecoveryMock'); var ECRecoveryLib = artifacts.require('ECRecovery'); -var hashMessage = require('../helpers/hashMessage.js'); contract('ECRecovery', function (accounts) { let ecrecovery; @@ -13,26 +12,6 @@ contract('ECRecovery', function (accounts) { ecrecovery = await ECRecoveryMock.new(); }); - // it('recover v0', async function () { - // // Signature generated outside testrpc with method web3.eth.sign(signer, message) - // let signer = '0x2cc1166f6212628a0deef2b33befb2187d35b86c'; - // let message = web3.sha3(TEST_MESSAGE); - // // eslint-disable-next-line max-len - // let signature = '0x5d99b6f7f6d1f73d1a26497f2b1c89b24c0993913f86e9a2d02cd69887d9c94f3c880358579d811b21dd1b7fd9bb01c1d81d10e69f0384e675c32b39643be89200'; - // await ecrecovery.recover(message, signature); - // assert.equal(signer, await ecrecovery.addrRecovered()); - // }); - - // it('recover v1', async function () { - // // Signature generated outside testrpc with method web3.eth.sign(signer, message) - // let signer = '0x1e318623ab09fe6de3c9b8672098464aeda9100e'; - // let message = web3.sha3(TEST_MESSAGE); - // // eslint-disable-next-line max-len - // let signature = '0x331fe75a821c982f9127538858900d87d3ec1f9f737338ad67cad133fa48feff48e6fa0c18abc62e42820f05943e47af3e9fbe306ce74d64094bdf1691ee53e001'; - // await ecrecovery.recover(message, signature); - // assert.equal(signer, await ecrecovery.addrRecovered()); - // }); - it('recover using web3.eth.sign()', async function () { // Create the signature using account[0] const signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); From 7f32e5ceaa62a458fd68591fe895e4d43685411d Mon Sep 17 00:00:00 2001 From: Aniket Date: Tue, 13 Mar 2018 17:17:29 +0530 Subject: [PATCH 6/9] Minor improvements --- test/library/ECRecovery.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/library/ECRecovery.test.js b/test/library/ECRecovery.test.js index 1f9f41cd9ec..ef354a76f05 100644 --- a/test/library/ECRecovery.test.js +++ b/test/library/ECRecovery.test.js @@ -1,7 +1,6 @@ var ECRecoveryMock = artifacts.require('ECRecoveryMock'); var ECRecoveryLib = artifacts.require('ECRecovery'); - contract('ECRecovery', function (accounts) { let ecrecovery; const TEST_MESSAGE = 'OpenZeppelin'; From 68de8409c2599a2617a78b2c856072e4d85a5881 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 1 Oct 2018 15:49:33 +0530 Subject: [PATCH 7/9] Revert "Dangling commas are now required. (#1359)" This reverts commit a6889776f46adca374b6ebf014aa7b0038112a9d. --- .eslintrc | 2 +- test/crowdsale/AllowanceCrowdsale.test.js | 2 +- test/crowdsale/Crowdsale.test.js | 4 ++-- test/crowdsale/MintedCrowdsale.behavior.js | 2 +- test/payment/Escrow.behavior.js | 4 ++-- test/token/ERC20/ERC20.test.js | 14 +++++++------- .../ERC20/behaviors/ERC20Burnable.behavior.js | 4 ++-- .../ERC20/behaviors/ERC20Mintable.behavior.js | 2 +- test/token/ERC721/ERC721.behavior.js | 14 +++++++------- test/token/ERC721/ERC721MintBurn.behavior.js | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.eslintrc b/.eslintrc index c15a4d51515..117135b36f9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,7 +25,7 @@ // Code style "camelcase": ["error", {"properties": "always"}], - "comma-dangle": ["error", "always-multiline"], + "comma-dangle": ["warn", "always-multiline"], "comma-spacing": ["error", {"before": false, "after": true}], "dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}], "eol-last": ["error", "always"], diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index c0ff4cd91ba..8e57a841b24 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -46,7 +46,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW purchaser: investor, beneficiary: investor, value: value, - amount: expectedTokenAmount, + amount: expectedTokenAmount }); }); diff --git a/test/crowdsale/Crowdsale.test.js b/test/crowdsale/Crowdsale.test.js index 4113f7cb428..f691c951576 100644 --- a/test/crowdsale/Crowdsale.test.js +++ b/test/crowdsale/Crowdsale.test.js @@ -87,7 +87,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { purchaser: investor, beneficiary: investor, value: value, - amount: expectedTokenAmount, + amount: expectedTokenAmount }); }); @@ -111,7 +111,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { purchaser: purchaser, beneficiary: investor, value: value, - amount: expectedTokenAmount, + amount: expectedTokenAmount }); }); diff --git a/test/crowdsale/MintedCrowdsale.behavior.js b/test/crowdsale/MintedCrowdsale.behavior.js index ab8dc8259cc..c55850cd9a4 100644 --- a/test/crowdsale/MintedCrowdsale.behavior.js +++ b/test/crowdsale/MintedCrowdsale.behavior.js @@ -25,7 +25,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate purchaser: investor, beneficiary: investor, value: value, - amount: expectedTokenAmount, + amount: expectedTokenAmount }); }); diff --git a/test/payment/Escrow.behavior.js b/test/payment/Escrow.behavior.js index 57f1fe5d0ac..fce4bd69217 100644 --- a/test/payment/Escrow.behavior.js +++ b/test/payment/Escrow.behavior.js @@ -34,7 +34,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { const { logs } = await this.escrow.deposit(payee1, { from: primary, value: amount }); expectEvent.inLogs(logs, 'Deposited', { payee: payee1, - weiAmount: amount, + weiAmount: amount }); }); @@ -87,7 +87,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { const { logs } = await this.escrow.withdraw(payee1, { from: primary }); expectEvent.inLogs(logs, 'Withdrawn', { payee: payee1, - weiAmount: amount, + weiAmount: amount }); }); }); diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index e991c2ae6d1..283e8752a09 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -65,7 +65,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Transfer', { from: owner, to: to, - value: amount, + value: amount }); }); }); @@ -93,7 +93,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount, + value: amount }); }); @@ -127,7 +127,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount, + value: amount }); }); @@ -197,7 +197,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Transfer', { from: owner, to: to, - value: amount, + value: amount }); }); }); @@ -272,7 +272,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: 0, + value: 0 }); }); @@ -329,7 +329,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount, + value: amount }); }); @@ -363,7 +363,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount, + value: amount }); }); diff --git a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js index c52594d1876..9c7bada7acc 100644 --- a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js @@ -32,7 +32,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, - value: amount, + value: amount }); }); } @@ -78,7 +78,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, - value: amount, + value: amount }); }); } diff --git a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js index dbda9eeedbc..07b3837b086 100644 --- a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js @@ -38,7 +38,7 @@ function shouldBehaveLikeERC20Mintable (minter, [anyone]) { expectEvent.inLogs(this.logs, 'Transfer', { from: ZERO_ADDRESS, to: anyone, - value: amount, + value: amount }); }); } diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index ce56747def3..d2cefe743c7 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -92,7 +92,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: this.toWhom, - tokenId: tokenId, + tokenId: tokenId }); }); } else { @@ -100,7 +100,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: this.toWhom, - tokenId: tokenId, + tokenId: tokenId }); }); } @@ -165,7 +165,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: owner, - tokenId: tokenId, + tokenId: tokenId }); }); @@ -341,7 +341,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Approval', { owner: owner, approved: address, - tokenId: tokenId, + tokenId: tokenId }); }); }; @@ -451,7 +451,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'ApprovalForAll', { owner: owner, operator: operator, - approved: true, + approved: true }); }); }); @@ -473,7 +473,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'ApprovalForAll', { owner: owner, operator: operator, - approved: true, + approved: true }); }); @@ -501,7 +501,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'ApprovalForAll', { owner: owner, operator: operator, - approved: true, + approved: true }); }); }); diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index 8aeccd5d8b7..a4289d27a74 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -45,7 +45,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: ZERO_ADDRESS, to: newOwner, - tokenId: thirdTokenId, + tokenId: thirdTokenId }); }); }); @@ -90,7 +90,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, - tokenId: tokenId, + tokenId: tokenId }); }); }); From 75bc3107fcae9c4aa9d37b3afc28192d2d1d493c Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 1 Oct 2018 22:00:42 +0530 Subject: [PATCH 8/9] updates --- .eslintrc | 2 +- contracts/ECRecovery.sol | 53 --------------------------------- test/library/ECRecovery.test.js | 40 ------------------------- 3 files changed, 1 insertion(+), 94 deletions(-) delete mode 100644 contracts/ECRecovery.sol delete mode 100644 test/library/ECRecovery.test.js diff --git a/.eslintrc b/.eslintrc index 117135b36f9..c15a4d51515 100644 --- a/.eslintrc +++ b/.eslintrc @@ -25,7 +25,7 @@ // Code style "camelcase": ["error", {"properties": "always"}], - "comma-dangle": ["warn", "always-multiline"], + "comma-dangle": ["error", "always-multiline"], "comma-spacing": ["error", {"before": false, "after": true}], "dot-notation": ["error", {"allowKeywords": true, "allowPattern": ""}], "eol-last": ["error", "always"], diff --git a/contracts/ECRecovery.sol b/contracts/ECRecovery.sol deleted file mode 100644 index c5b6d8f646c..00000000000 --- a/contracts/ECRecovery.sol +++ /dev/null @@ -1,53 +0,0 @@ -pragma solidity ^0.4.18; - - -/** - * @title Eliptic curve signature operations - * - * @dev Based on https://gist.github.com/axic/5b33912c6f61ae6fd96d6c4a47afde6d - */ - -library ECRecovery { - - /** - * @dev Recover signer address from a message by using his signature - * @param hash bytes32 message, the hash is the signed message. What is recovered is the signer address. - * @param sig bytes signature, the signature is generated using web3.eth.sign() - */ - function recover(bytes32 hash, bytes sig) public pure returns (address) { - bytes32 r; - bytes32 s; - uint8 v; - - //Check the signature length - if (sig.length != 65) { - return (address(0)); - } - - // Divide the signature in r, s and v variables - assembly { - r := mload(add(sig, 32)) - s := mload(add(sig, 64)) - v := byte(0, mload(add(sig, 96))) - } - - // Version of signature should be 27 or 28, but 0 and 1 are also possible versions - if (v < 27) { - v += 27; - } - - // If the version is correct return the signer address - if (v != 27 && v != 28) { - return (address(0)); - } else { - - /* - * https://github.com/ethereum/go-ethereum/issues/3731 - */ - - bytes memory prefix = "\x19Ethereum Signed Message:\n32"; - return ecrecover(keccak256(prefix, hash), v, r, s); - } - } - -} diff --git a/test/library/ECRecovery.test.js b/test/library/ECRecovery.test.js deleted file mode 100644 index ef354a76f05..00000000000 --- a/test/library/ECRecovery.test.js +++ /dev/null @@ -1,40 +0,0 @@ -var ECRecoveryMock = artifacts.require('ECRecoveryMock'); -var ECRecoveryLib = artifacts.require('ECRecovery'); - -contract('ECRecovery', function (accounts) { - let ecrecovery; - const TEST_MESSAGE = 'OpenZeppelin'; - - before(async function () { - const ecRecoveryLib = await ECRecoveryLib.new(); - ECRecoveryMock.link('ECRecovery', ecRecoveryLib.address); - ecrecovery = await ECRecoveryMock.new(); - }); - - it('recover using web3.eth.sign()', async function () { - // Create the signature using account[0] - const signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); - - // Recover the signer address from the generated message and signature. - await ecrecovery.recover(web3.sha3(TEST_MESSAGE), signature); - assert.equal(accounts[0], await ecrecovery.addrRecovered()); - }); - - it('recover using web3.eth.sign() should return wrong signer', async function () { - // Create the signature using account[0] - const signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); - - // Recover the signer address from the generated message and wrong signature. - await ecrecovery.recover(web3.sha3('Test'), signature); - assert.notEqual(accounts[0], await ecrecovery.addrRecovered()); - }); - - it('recover should fail when a wrong hash is sent', async function () { - // Create the signature using account[0] - let signature = web3.eth.sign(accounts[0], web3.sha3(TEST_MESSAGE)); - - // Recover the signer address from the generated message and wrong signature. - await ecrecovery.recover(web3.sha3(TEST_MESSAGE).substring(2), signature); - assert.equal('0x0000000000000000000000000000000000000000', await ecrecovery.addrRecovered()); - }); -}); From c3361e5c946d69f28557c5a54b227d4ef6032b4b Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 9 Oct 2018 12:59:10 +0530 Subject: [PATCH 9/9] fixes #1206 --- test/access/Roles.test.js | 4 +--- test/access/roles/PublicRole.behavior.js | 2 +- test/crowdsale/AllowanceCrowdsale.test.js | 4 ++-- test/crowdsale/Crowdsale.test.js | 6 +++--- test/crowdsale/MintedCrowdsale.behavior.js | 2 +- test/drafts/ERC20Migrator.test.js | 4 +--- test/examples/SimpleToken.test.js | 3 +-- test/helpers/constants.js | 6 ++++++ test/math/SafeMath.test.js | 7 +++---- test/ownership/Ownable.behavior.js | 3 +-- test/ownership/Secondary.test.js | 4 +--- test/payment/ConditionalEscrow.test.js | 3 ++- test/payment/Escrow.behavior.js | 7 ++++--- test/payment/PullPayment.test.js | 3 ++- test/payment/RefundEscrow.test.js | 5 +++-- test/payment/SplitPayment.test.js | 5 +++-- test/token/ERC20/ERC20.test.js | 17 ++++++++--------- test/token/ERC20/TokenVesting.test.js | 2 +- .../ERC20/behaviors/ERC20Burnable.behavior.js | 6 +++--- .../ERC20/behaviors/ERC20Mintable.behavior.js | 5 ++--- test/token/ERC721/ERC721.behavior.js | 16 ++++++++-------- test/token/ERC721/ERC721MintBurn.behavior.js | 6 +++--- test/token/ERC721/ERC721PausedToken.behavior.js | 2 +- 23 files changed, 61 insertions(+), 61 deletions(-) create mode 100644 test/helpers/constants.js diff --git a/test/access/Roles.test.js b/test/access/Roles.test.js index 7d5573cec0a..76517492c11 100644 --- a/test/access/Roles.test.js +++ b/test/access/Roles.test.js @@ -1,13 +1,11 @@ const { assertRevert } = require('../helpers/assertRevert'); - +const { ZERO_ADDRESS } = require('../helpers/constants'); const RolesMock = artifacts.require('RolesMock'); require('chai') .should(); contract('Roles', function ([_, authorized, otherAuthorized, anyone]) { - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - beforeEach(async function () { this.roles = await RolesMock.new(); }); diff --git a/test/access/roles/PublicRole.behavior.js b/test/access/roles/PublicRole.behavior.js index f1c723b7821..a3067f88e2e 100644 --- a/test/access/roles/PublicRole.behavior.js +++ b/test/access/roles/PublicRole.behavior.js @@ -1,4 +1,5 @@ const { assertRevert } = require('../../helpers/assertRevert'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const expectEvent = require('../../helpers/expectEvent'); require('chai') @@ -10,7 +11,6 @@ function capitalize (str) { function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], rolename) { rolename = capitalize(rolename); - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; describe('should behave like public role', function () { beforeEach('check preconditions', async function () { diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index 8e57a841b24..c6f825126dd 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -2,6 +2,7 @@ const expectEvent = require('../helpers/expectEvent'); const { ether } = require('../helpers/ether'); const { assertRevert } = require('../helpers/assertRevert'); const { ethGetBalance } = require('../helpers/web3'); +const { ZERO_ADDRESS } = require('../helpers/constants'); const BigNumber = web3.BigNumber; @@ -17,7 +18,6 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW const value = ether(0.42); const expectedTokenAmount = rate.mul(value); const tokenAllowance = new BigNumber('1e22'); - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; beforeEach(async function () { this.token = await SimpleToken.new({ from: tokenWallet }); @@ -46,7 +46,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW purchaser: investor, beneficiary: investor, value: value, - amount: expectedTokenAmount + amount: expectedTokenAmount, }); }); diff --git a/test/crowdsale/Crowdsale.test.js b/test/crowdsale/Crowdsale.test.js index f691c951576..b1f3b381f6e 100644 --- a/test/crowdsale/Crowdsale.test.js +++ b/test/crowdsale/Crowdsale.test.js @@ -2,6 +2,7 @@ const expectEvent = require('../helpers/expectEvent'); const { assertRevert } = require('../helpers/assertRevert'); const { ether } = require('../helpers/ether'); const { ethGetBalance } = require('../helpers/web3'); +const { ZERO_ADDRESS } = require('../helpers/constants'); const BigNumber = web3.BigNumber; @@ -17,7 +18,6 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { const value = ether(42); const tokenSupply = new BigNumber('1e22'); const expectedTokenAmount = rate.mul(value); - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; it('requires a non-null token', async function () { await assertRevert( @@ -87,7 +87,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { purchaser: investor, beneficiary: investor, value: value, - amount: expectedTokenAmount + amount: expectedTokenAmount, }); }); @@ -111,7 +111,7 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { purchaser: purchaser, beneficiary: investor, value: value, - amount: expectedTokenAmount + amount: expectedTokenAmount, }); }); diff --git a/test/crowdsale/MintedCrowdsale.behavior.js b/test/crowdsale/MintedCrowdsale.behavior.js index c55850cd9a4..ab8dc8259cc 100644 --- a/test/crowdsale/MintedCrowdsale.behavior.js +++ b/test/crowdsale/MintedCrowdsale.behavior.js @@ -25,7 +25,7 @@ function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate purchaser: investor, beneficiary: investor, value: value, - amount: expectedTokenAmount + amount: expectedTokenAmount, }); }); diff --git a/test/drafts/ERC20Migrator.test.js b/test/drafts/ERC20Migrator.test.js index 315a7ea7886..608dce86099 100644 --- a/test/drafts/ERC20Migrator.test.js +++ b/test/drafts/ERC20Migrator.test.js @@ -1,5 +1,5 @@ const { assertRevert } = require('../helpers/assertRevert'); - +const { ZERO_ADDRESS } = require('../helpers/constants'); const ERC20Mock = artifacts.require('ERC20Mock'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20Migrator = artifacts.require('ERC20Migrator'); @@ -11,8 +11,6 @@ require('chai') .should(); contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - const totalSupply = 200; it('reverts with a null legacy token address', async function () { diff --git a/test/examples/SimpleToken.test.js b/test/examples/SimpleToken.test.js index f59a8200017..e7f8fa5c104 100644 --- a/test/examples/SimpleToken.test.js +++ b/test/examples/SimpleToken.test.js @@ -1,4 +1,5 @@ const { decodeLogs } = require('../helpers/decodeLogs'); +const { ZERO_ADDRESS } = require('../helpers/constants'); const SimpleToken = artifacts.require('SimpleToken'); const BigNumber = web3.BigNumber; @@ -8,8 +9,6 @@ require('chai') .should(); contract('SimpleToken', function ([_, creator]) { - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - beforeEach(async function () { this.token = await SimpleToken.new({ from: creator }); }); diff --git a/test/helpers/constants.js b/test/helpers/constants.js new file mode 100644 index 00000000000..70d2242a3f7 --- /dev/null +++ b/test/helpers/constants.js @@ -0,0 +1,6 @@ +const BigNumber = web3.BigNumber; + +module.exports = { + ZERO_ADDRESS: '0x0000000000000000000000000000000000000000', + MAX_UINT256: new BigNumber(2).pow(256).minus(1), +}; diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index 0174bd0acff..56cedeb84de 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -1,4 +1,5 @@ const { assertRevert } = require('../helpers/assertRevert'); +const { MAX_UINT256 } = require('../helpers/constants'); const BigNumber = web3.BigNumber; const SafeMathMock = artifacts.require('SafeMathMock'); @@ -8,8 +9,6 @@ require('chai') .should(); contract('SafeMath', function () { - const MAX_UINT = new BigNumber(2).pow(256).minus(1); - beforeEach(async function () { this.safeMath = await SafeMathMock.new(); }); @@ -23,7 +22,7 @@ contract('SafeMath', function () { }); it('throws a revert error on addition overflow', async function () { - const a = MAX_UINT; + const a = MAX_UINT256; const b = new BigNumber(1); await assertRevert(this.safeMath.add(a, b)); @@ -62,7 +61,7 @@ contract('SafeMath', function () { }); it('throws a revert error on multiplication overflow', async function () { - const a = MAX_UINT; + const a = MAX_UINT256; const b = new BigNumber(2); await assertRevert(this.safeMath.mul(a, b)); diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index eac3c10ce81..551351dd07a 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -1,7 +1,6 @@ const { expectThrow } = require('../helpers/expectThrow'); const { EVMRevert } = require('../helpers/EVMRevert'); - -const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; +const { ZERO_ADDRESS } = require('../helpers/constants'); require('chai') .should(); diff --git a/test/ownership/Secondary.test.js b/test/ownership/Secondary.test.js index 000d0af11ba..31676be79d0 100644 --- a/test/ownership/Secondary.test.js +++ b/test/ownership/Secondary.test.js @@ -1,13 +1,11 @@ const { assertRevert } = require('../helpers/assertRevert'); - +const { ZERO_ADDRESS } = require('../helpers/constants'); const SecondaryMock = artifacts.require('SecondaryMock'); require('chai') .should(); contract('Secondary', function ([_, primary, newPrimary, anyone]) { - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - beforeEach(async function () { this.secondary = await SecondaryMock.new({ from: primary }); }); diff --git a/test/payment/ConditionalEscrow.test.js b/test/payment/ConditionalEscrow.test.js index 5115fee4872..03eed68f7f4 100644 --- a/test/payment/ConditionalEscrow.test.js +++ b/test/payment/ConditionalEscrow.test.js @@ -1,6 +1,7 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); const { expectThrow } = require('../helpers/expectThrow'); const { EVMRevert } = require('../helpers/EVMRevert'); +const { ether } = require('../helpers/ether'); const BigNumber = web3.BigNumber; @@ -24,7 +25,7 @@ contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) { }); context('when withdrawal is disallowed', function () { - const amount = web3.toWei(23.0, 'ether'); + const amount = ether(23.0); beforeEach(async function () { await this.escrow.setAllowed(payee, false); diff --git a/test/payment/Escrow.behavior.js b/test/payment/Escrow.behavior.js index fce4bd69217..9769291e15e 100644 --- a/test/payment/Escrow.behavior.js +++ b/test/payment/Escrow.behavior.js @@ -2,6 +2,7 @@ const expectEvent = require('../helpers/expectEvent'); const { expectThrow } = require('../helpers/expectThrow'); const { EVMRevert } = require('../helpers/EVMRevert'); const { ethGetBalance } = require('../helpers/web3'); +const { ether } = require('../helpers/ether'); const BigNumber = web3.BigNumber; @@ -10,7 +11,7 @@ require('chai') .should(); function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { - const amount = web3.toWei(42.0, 'ether'); + const amount = ether(42.0); describe('as an escrow', function () { describe('deposits', function () { @@ -34,7 +35,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { const { logs } = await this.escrow.deposit(payee1, { from: primary, value: amount }); expectEvent.inLogs(logs, 'Deposited', { payee: payee1, - weiAmount: amount + weiAmount: amount, }); }); @@ -87,7 +88,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { const { logs } = await this.escrow.withdraw(payee1, { from: primary }); expectEvent.inLogs(logs, 'Withdrawn', { payee: payee1, - weiAmount: amount + weiAmount: amount, }); }); }); diff --git a/test/payment/PullPayment.test.js b/test/payment/PullPayment.test.js index 1eab3911f5d..1f4bcc52528 100644 --- a/test/payment/PullPayment.test.js +++ b/test/payment/PullPayment.test.js @@ -1,4 +1,5 @@ const { ethGetBalance } = require('../helpers/web3'); +const { ether } = require('../helpers/ether'); const BigNumber = web3.BigNumber; @@ -9,7 +10,7 @@ require('chai') const PullPaymentMock = artifacts.require('PullPaymentMock'); contract('PullPayment', function ([_, payer, payee1, payee2]) { - const amount = web3.toWei(17.0, 'ether'); + const amount = ether(17.0); beforeEach(async function () { this.contract = await PullPaymentMock.new({ value: amount }); diff --git a/test/payment/RefundEscrow.test.js b/test/payment/RefundEscrow.test.js index c499f4009dd..a3d669d6961 100644 --- a/test/payment/RefundEscrow.test.js +++ b/test/payment/RefundEscrow.test.js @@ -2,6 +2,8 @@ const { expectThrow } = require('../helpers/expectThrow'); const { EVMRevert } = require('../helpers/EVMRevert'); const expectEvent = require('../helpers/expectEvent'); const { ethGetBalance } = require('../helpers/web3'); +const { ether } = require('../helpers/ether'); +const { ZERO_ADDRESS } = require('../helpers/constants'); const BigNumber = web3.BigNumber; @@ -12,9 +14,8 @@ require('chai') const RefundEscrow = artifacts.require('RefundEscrow'); contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) { - const amount = web3.toWei(54.0, 'ether'); + const amount = ether(54.0); const refundees = [refundee1, refundee2]; - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; it('requires a non-null beneficiary', async function () { await expectThrow( diff --git a/test/payment/SplitPayment.test.js b/test/payment/SplitPayment.test.js index cf9ef0e0184..c4a720fb945 100644 --- a/test/payment/SplitPayment.test.js +++ b/test/payment/SplitPayment.test.js @@ -1,5 +1,7 @@ const { ethGetBalance } = require('../helpers/web3'); const { sendEther } = require('./../helpers/sendTransaction'); +const { ether } = require('../helpers/ether'); +const { ZERO_ADDRESS } = require('./../helpers/constants'); const BigNumber = web3.BigNumber; @@ -12,8 +14,7 @@ const { EVMRevert } = require('../helpers/EVMRevert.js'); const SplitPayment = artifacts.require('SplitPayment'); contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { - const amount = web3.toWei(1.0, 'ether'); - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; + const amount = ether(1.0); it('rejects an empty set of payees', async function () { await expectThrow(SplitPayment.new([], []), EVMRevert); diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 283e8752a09..e224de94256 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -1,5 +1,6 @@ const { assertRevert } = require('../../helpers/assertRevert'); const expectEvent = require('../../helpers/expectEvent'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const ERC20Mock = artifacts.require('ERC20Mock'); @@ -10,8 +11,6 @@ require('chai') .should(); contract('ERC20', function ([_, owner, recipient, anotherAccount]) { - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - beforeEach(async function () { this.token = await ERC20Mock.new(owner, 100); }); @@ -65,7 +64,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Transfer', { from: owner, to: to, - value: amount + value: amount, }); }); }); @@ -93,7 +92,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount + value: amount, }); }); @@ -127,7 +126,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount + value: amount, }); }); @@ -197,7 +196,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Transfer', { from: owner, to: to, - value: amount + value: amount, }); }); }); @@ -272,7 +271,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: 0 + value: 0, }); }); @@ -329,7 +328,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount + value: amount, }); }); @@ -363,7 +362,7 @@ contract('ERC20', function ([_, owner, recipient, anotherAccount]) { expectEvent.inLogs(logs, 'Approval', { owner: owner, spender: spender, - value: amount + value: amount, }); }); diff --git a/test/token/ERC20/TokenVesting.test.js b/test/token/ERC20/TokenVesting.test.js index 7c4fbcc8e36..acfdb9adc58 100644 --- a/test/token/ERC20/TokenVesting.test.js +++ b/test/token/ERC20/TokenVesting.test.js @@ -2,6 +2,7 @@ const { expectThrow } = require('../../helpers/expectThrow'); const { EVMRevert } = require('../../helpers/EVMRevert'); const time = require('../../helpers/time'); const { ethGetBlock } = require('../../helpers/web3'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const BigNumber = web3.BigNumber; @@ -14,7 +15,6 @@ const TokenVesting = artifacts.require('TokenVesting'); contract('TokenVesting', function ([_, owner, beneficiary]) { const amount = new BigNumber(1000); - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; beforeEach(async function () { // +1 minute so it starts after contract instantiation diff --git a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js index 9c7bada7acc..25af3254c01 100644 --- a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js @@ -1,8 +1,8 @@ const { assertRevert } = require('../../../helpers/assertRevert'); const expectEvent = require('../../../helpers/expectEvent'); +const { ZERO_ADDRESS } = require('../../../helpers/constants'); const BigNumber = web3.BigNumber; -const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; require('chai') .use(require('chai-bignumber')(BigNumber)) @@ -32,7 +32,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, - value: amount + value: amount, }); }); } @@ -78,7 +78,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { expectEvent.inLogs(this.logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, - value: amount + value: amount, }); }); } diff --git a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js index 07b3837b086..f34504afc32 100644 --- a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js @@ -1,5 +1,6 @@ const { assertRevert } = require('../../../helpers/assertRevert'); const expectEvent = require('../../../helpers/expectEvent'); +const { ZERO_ADDRESS } = require('../../../helpers/constants'); const BigNumber = web3.BigNumber; @@ -8,8 +9,6 @@ require('chai') .should(); function shouldBehaveLikeERC20Mintable (minter, [anyone]) { - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; - describe('as a mintable token', function () { describe('mint', function () { const amount = 100; @@ -38,7 +37,7 @@ function shouldBehaveLikeERC20Mintable (minter, [anyone]) { expectEvent.inLogs(this.logs, 'Transfer', { from: ZERO_ADDRESS, to: anyone, - value: amount + value: amount, }); }); } diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index d2cefe743c7..a18b6b4375c 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -1,6 +1,7 @@ const expectEvent = require('../../helpers/expectEvent'); const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior'); const { assertRevert } = require('../../helpers/assertRevert'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const { decodeLogs } = require('../../helpers/decodeLogs'); const { sendTransaction } = require('../../helpers/sendTransaction'); @@ -19,7 +20,6 @@ function shouldBehaveLikeERC721 ( const firstTokenId = 1; const secondTokenId = 2; const unknownTokenId = 3; - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; const RECEIVER_MAGIC_VALUE = '0x150b7a02'; describe('like an ERC721', function () { @@ -92,7 +92,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: this.toWhom, - tokenId: tokenId + tokenId: tokenId, }); }); } else { @@ -100,7 +100,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: this.toWhom, - tokenId: tokenId + tokenId: tokenId, }); }); } @@ -165,7 +165,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: owner, - tokenId: tokenId + tokenId: tokenId, }); }); @@ -341,7 +341,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'Approval', { owner: owner, approved: address, - tokenId: tokenId + tokenId: tokenId, }); }); }; @@ -451,7 +451,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'ApprovalForAll', { owner: owner, operator: operator, - approved: true + approved: true, }); }); }); @@ -473,7 +473,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'ApprovalForAll', { owner: owner, operator: operator, - approved: true + approved: true, }); }); @@ -501,7 +501,7 @@ function shouldBehaveLikeERC721 ( expectEvent.inLogs(logs, 'ApprovalForAll', { owner: owner, operator: operator, - approved: true + approved: true, }); }); }); diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index 294bd433b57..a5141abcab7 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -1,5 +1,6 @@ const { assertRevert } = require('../../helpers/assertRevert'); const expectEvent = require('../../helpers/expectEvent'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const BigNumber = web3.BigNumber; require('chai') @@ -15,7 +16,6 @@ function shouldBehaveLikeMintAndBurnERC721 ( const secondTokenId = 2; const thirdTokenId = 3; const unknownTokenId = 4; - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; const MOCK_URI = 'https://example.com'; describe('like a mintable and burnable ERC721', function () { @@ -45,7 +45,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: ZERO_ADDRESS, to: newOwner, - tokenId: thirdTokenId + tokenId: thirdTokenId, }); }); }); @@ -90,7 +90,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( expectEvent.inLogs(logs, 'Transfer', { from: owner, to: ZERO_ADDRESS, - tokenId: tokenId + tokenId: tokenId, }); }); }); diff --git a/test/token/ERC721/ERC721PausedToken.behavior.js b/test/token/ERC721/ERC721PausedToken.behavior.js index d14e6a39533..a7196d8370d 100644 --- a/test/token/ERC721/ERC721PausedToken.behavior.js +++ b/test/token/ERC721/ERC721PausedToken.behavior.js @@ -1,5 +1,6 @@ const { assertRevert } = require('../../helpers/assertRevert'); const { sendTransaction } = require('../../helpers/sendTransaction'); +const { ZERO_ADDRESS } = require('../../helpers/constants'); const BigNumber = web3.BigNumber; @@ -11,7 +12,6 @@ function shouldBehaveLikeERC721PausedToken (owner, [recipient, operator]) { const firstTokenId = 1; const mintedTokens = 1; const mockData = '0x42'; - const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; describe('like a paused ERC721', function () { beforeEach(async function () {