Unverified Commit cea2a85a by Nicolás Venturo Committed by GitHub

Remove Babel (#1074)

* Test helpers no longer rely on Babel.

* Behaviours are no longer imported.

* Removed Babel dependency.

* Fixed linter errors.
parent 99e4b081
...@@ -1246,37 +1246,6 @@ ...@@ -1246,37 +1246,6 @@
"babel-types": "^6.24.1" "babel-types": "^6.24.1"
} }
}, },
"babel-polyfill": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz",
"integrity": "sha1-N5k3q8Z9eJWXCtxiHyhM2WbPIVM=",
"dev": true,
"requires": {
"babel-runtime": "^6.26.0",
"core-js": "^2.5.0",
"regenerator-runtime": "^0.10.5"
},
"dependencies": {
"babel-runtime": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz",
"integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=",
"dev": true,
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
},
"dependencies": {
"regenerator-runtime": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz",
"integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==",
"dev": true
}
}
}
}
},
"babel-preset-env": { "babel-preset-env": {
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz", "resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz",
......
...@@ -37,11 +37,6 @@ ...@@ -37,11 +37,6 @@
}, },
"homepage": "https://github.com/OpenZeppelin/zeppelin-solidity", "homepage": "https://github.com/OpenZeppelin/zeppelin-solidity",
"devDependencies": { "devDependencies": {
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-stage-2": "^6.18.0",
"babel-preset-stage-3": "^6.17.0",
"babel-register": "^6.26.0",
"chai": "^4.1.2", "chai": "^4.1.2",
"chai-as-promised": "^7.0.0", "chai-as-promised": "^7.0.0",
"chai-bignumber": "^2.0.2", "chai-bignumber": "^2.0.2",
......
import { ethGetBalance, ethSendTransaction } from './helpers/web3'; const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
var SecureTargetBounty = artifacts.require('SecureTargetBounty');
var InsecureTargetBounty = artifacts.require('InsecureTargetBounty');
const sendReward = async (from, to, value) => ethSendTransaction({ const sendReward = async (from, to, value) => ethSendTransaction({
from, to, value, from, to, value,
}); });
var SecureTargetBounty = artifacts.require('SecureTargetBounty');
var InsecureTargetBounty = artifacts.require('InsecureTargetBounty');
function awaitEvent (event, handler) { function awaitEvent (event, handler) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
......
import increaseTime from './helpers/increaseTime'; const { increaseTime } = require('./helpers/increaseTime');
import expectThrow from './helpers/expectThrow'; const { expectThrow } = require('./helpers/expectThrow');
import assertRevert from './helpers/assertRevert'; const { assertRevert } = require('./helpers/assertRevert');
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000'; const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
......
import assertRevert from './helpers/assertRevert'; const { assertRevert } = require('./helpers/assertRevert');
import { ethGetBalance } from './helpers/web3'; const { ethGetBalance } = require('./helpers/web3');
var LimitBalanceMock = artifacts.require('LimitBalanceMock'); var LimitBalanceMock = artifacts.require('LimitBalanceMock');
......
const { expectThrow } = require('./helpers/expectThrow');
import expectThrow from './helpers/expectThrow';
const ReentrancyMock = artifacts.require('ReentrancyMock'); const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack'); const ReentrancyAttack = artifacts.require('ReentrancyAttack');
......
const { expectThrow } = require('./helpers/expectThrow');
import expectThrow from './helpers/expectThrow'; const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
import { ethGetBalance, ethSendTransaction } from './helpers/web3';
const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet'); const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet');
......
const { assertRevert } = require('../helpers/assertRevert');
import assertRevert from '../helpers/assertRevert'; const { signHex } = require('../helpers/sign');
import { signHex } from '../helpers/sign';
const Bouncer = artifacts.require('SignatureBouncerMock'); const Bouncer = artifacts.require('SignatureBouncerMock');
...@@ -8,19 +7,19 @@ require('chai') ...@@ -8,19 +7,19 @@ require('chai')
.use(require('chai-as-promised')) .use(require('chai-as-promised'))
.should(); .should();
export const getSigner = (contract, signer, data = '') => (addr) => { const getSigner = (contract, signer, data = '') => (addr) => {
// via: https://github.com/OpenZeppelin/zeppelin-solidity/pull/812/files // via: https://github.com/OpenZeppelin/zeppelin-solidity/pull/812/files
const message = contract.address.substr(2) + addr.substr(2) + data; const message = contract.address.substr(2) + addr.substr(2) + data;
// ^ substr to remove `0x` because in solidity the address is a set of byes, not a string `0xabcd` // ^ substr to remove `0x` because in solidity the address is a set of byes, not a string `0xabcd`
return signHex(signer, message); return signHex(signer, message);
}; };
export const getMethodId = (methodName, ...paramTypes) => { const getMethodId = (methodName, ...paramTypes) => {
// methodId is a sha3 of the first 4 bytes after 0x of 'method(paramType1,...)' // methodId is a sha3 of the first 4 bytes after 0x of 'method(paramType1,...)'
return web3.sha3(`${methodName}(${paramTypes.join(',')})`).substr(2, 8); return web3.sha3(`${methodName}(${paramTypes.join(',')})`).substr(2, 8);
}; };
export const stripAndPadHexValue = (hexVal, sizeInBytes, start = true) => { const stripAndPadHexValue = (hexVal, sizeInBytes, start = true) => {
// strip 0x from the font and pad with 0's for // strip 0x from the font and pad with 0's for
const strippedHexVal = hexVal.substr(2); const strippedHexVal = hexVal.substr(2);
return start ? strippedHexVal.padStart(sizeInBytes * 2, 0) : strippedHexVal.padEnd(sizeInBytes * 2, 0); return start ? strippedHexVal.padStart(sizeInBytes * 2, 0) : strippedHexVal.padEnd(sizeInBytes * 2, 0);
......
const { ether } = require('../helpers/ether');
import ether from '../helpers/ether'; const { assertRevert } = require('../helpers/assertRevert');
import assertRevert from '../helpers/assertRevert'; const { ethGetBalance } = require('../helpers/web3');
import { ethGetBalance } from '../helpers/web3';
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import { advanceBlock } from '../helpers/advanceToBlock'; const { advanceBlock } = require('../helpers/advanceToBlock');
import { increaseTimeTo, duration } from '../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../helpers/increaseTime');
import latestTime from '../helpers/latestTime'; const { latestTime } = require('../helpers/latestTime');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import { advanceBlock } from '../helpers/advanceToBlock'; const { advanceBlock } = require('../helpers/advanceToBlock');
import { increaseTimeTo, duration } from '../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../helpers/increaseTime');
import latestTime from '../helpers/latestTime'; const { latestTime } = require('../helpers/latestTime');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
...@@ -7,7 +7,7 @@ const should = require('chai') ...@@ -7,7 +7,7 @@ const should = require('chai')
.use(require('chai-bignumber')(BigNumber)) .use(require('chai-bignumber')(BigNumber))
.should(); .should();
export default function ([_, investor, wallet, purchaser], rate, value) { function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate, value) {
const expectedTokenAmount = rate.mul(value); const expectedTokenAmount = rate.mul(value);
describe('as a minted crowdsale', function () { describe('as a minted crowdsale', function () {
...@@ -44,3 +44,7 @@ export default function ([_, investor, wallet, purchaser], rate, value) { ...@@ -44,3 +44,7 @@ export default function ([_, investor, wallet, purchaser], rate, value) {
}); });
}); });
} }
module.exports = {
shouldBehaveLikeMintedCrowdsale,
};
import shouldBehaveLikeMintedCrowdsale from './MintedCrowdsale.behaviour'; const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behaviour');
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import { advanceBlock } from '../helpers/advanceToBlock'; const { advanceBlock } = require('../helpers/advanceToBlock');
import { increaseTimeTo, duration } from '../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../helpers/increaseTime');
import latestTime from '../helpers/latestTime'; const { latestTime } = require('../helpers/latestTime');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import { advanceBlock } from '../helpers/advanceToBlock'; const { advanceBlock } = require('../helpers/advanceToBlock');
import { increaseTimeTo, duration } from '../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../helpers/increaseTime');
import latestTime from '../helpers/latestTime'; const { latestTime } = require('../helpers/latestTime');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import { advanceBlock } from '../helpers/advanceToBlock'; const { advanceBlock } = require('../helpers/advanceToBlock');
import { increaseTimeTo, duration } from '../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../helpers/increaseTime');
import latestTime from '../helpers/latestTime'; const { latestTime } = require('../helpers/latestTime');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether'; const { ether } = require('../helpers/ether');
import { advanceBlock } from '../helpers/advanceToBlock'; const { advanceBlock } = require('../helpers/advanceToBlock');
import { increaseTimeTo, duration } from '../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../helpers/increaseTime');
import latestTime from '../helpers/latestTime'; const { latestTime } = require('../helpers/latestTime');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
import assertRevert from '../helpers/assertRevert'; const { assertRevert } = require('../helpers/assertRevert');
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import decodeLogs from '../helpers/decodeLogs'; const { decodeLogs } = require('../helpers/decodeLogs');
const SimpleToken = artifacts.require('SimpleToken'); const SimpleToken = artifacts.require('SimpleToken');
contract('SimpleToken', accounts => { contract('SimpleToken', accounts => {
......
export default 'revert'; const EVMRevert = 'revert';
module.exports = {
EVMRevert,
};
export default 'invalid opcode'; const EVMThrow = 'invalid opcode';
module.exports = {
EVMThrow,
};
export function advanceBlock () { function advanceBlock () {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
web3.currentProvider.sendAsync({ web3.currentProvider.sendAsync({
jsonrpc: '2.0', jsonrpc: '2.0',
...@@ -11,7 +11,7 @@ export function advanceBlock () { ...@@ -11,7 +11,7 @@ export function advanceBlock () {
} }
// Advances the block number so that the last mined block is `number`. // Advances the block number so that the last mined block is `number`.
export default async function advanceToBlock (number) { async function advanceToBlock (number) {
if (web3.eth.blockNumber > number) { if (web3.eth.blockNumber > number) {
throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`); throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`);
} }
...@@ -20,3 +20,8 @@ export default async function advanceToBlock (number) { ...@@ -20,3 +20,8 @@ export default async function advanceToBlock (number) {
await advanceBlock(); await advanceBlock();
} }
} }
module.exports = {
advanceBlock,
advanceToBlock,
};
export default async promise => { async function assertJump (promise) {
try { try {
await promise; await promise;
assert.fail('Expected invalid opcode not received'); assert.fail('Expected invalid opcode not received');
...@@ -6,4 +6,8 @@ export default async promise => { ...@@ -6,4 +6,8 @@ export default async promise => {
const invalidOpcodeReceived = error.message.search('invalid opcode') >= 0; const invalidOpcodeReceived = error.message.search('invalid opcode') >= 0;
assert(invalidOpcodeReceived, `Expected "invalid opcode", got ${error} instead`); assert(invalidOpcodeReceived, `Expected "invalid opcode", got ${error} instead`);
} }
}
module.exports = {
assertJump,
}; };
export default async promise => { async function assertRevert (promise) {
try { try {
await promise; await promise;
assert.fail('Expected revert not received'); assert.fail('Expected revert not received');
...@@ -6,4 +6,8 @@ export default async promise => { ...@@ -6,4 +6,8 @@ export default async promise => {
const revertFound = error.message.search('revert') >= 0; const revertFound = error.message.search('revert') >= 0;
assert(revertFound, `Expected "revert", got ${error} instead`); assert(revertFound, `Expected "revert", got ${error} instead`);
} }
}
module.exports = {
assertRevert,
}; };
const SolidityEvent = require('web3/lib/web3/event.js'); const SolidityEvent = require('web3/lib/web3/event.js');
export default function decodeLogs (logs, contract, address) { function decodeLogs (logs, contract, address) {
return logs.map(log => { return logs.map(log => {
const event = new SolidityEvent(null, contract.events[log.topics[0]], address); const event = new SolidityEvent(null, contract.events[log.topics[0]], address);
return event.decode(log); return event.decode(log);
}); });
} }
module.exports = {
decodeLogs,
};
export default function ether (n) { function ether (n) {
return new web3.BigNumber(web3.toWei(n, 'ether')); return new web3.BigNumber(web3.toWei(n, 'ether'));
} }
module.exports = {
ether,
};
const should = require('chai').should(); const should = require('chai').should();
const inLogs = async (logs, eventName, eventArgs = {}) => { async function inLogs (logs, eventName, eventArgs = {}) {
const event = logs.find(e => e.event === eventName); const event = logs.find(e => e.event === eventName);
should.exist(event); should.exist(event);
for (const [k, v] of Object.entries(eventArgs)) { for (const [k, v] of Object.entries(eventArgs)) {
...@@ -8,12 +8,12 @@ const inLogs = async (logs, eventName, eventArgs = {}) => { ...@@ -8,12 +8,12 @@ const inLogs = async (logs, eventName, eventArgs = {}) => {
event.args[k].should.eq(v); event.args[k].should.eq(v);
} }
return event; return event;
}; }
const inTransaction = async (tx, eventName, eventArgs = {}) => { async function inTransaction (tx, eventName, eventArgs = {}) {
const { logs } = await tx; const { logs } = await tx;
return inLogs(logs, eventName, eventArgs); return inLogs(logs, eventName, eventArgs);
}; }
module.exports = { module.exports = {
inLogs, inLogs,
......
export default async promise => { async function expectThrow (promise) {
try { try {
await promise; await promise;
} catch (error) { } catch (error) {
...@@ -18,4 +18,8 @@ export default async promise => { ...@@ -18,4 +18,8 @@ export default async promise => {
return; return;
} }
assert.fail('Expected throw not received'); assert.fail('Expected throw not received');
}
module.exports = {
expectThrow,
}; };
import latestTime from './latestTime'; const { latestTime } = require('./latestTime');
// Increases ganache time by the passed duration in seconds // Increases ganache time by the passed duration in seconds
export default function increaseTime (duration) { function increaseTime (duration) {
const id = Date.now(); const id = Date.now();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
...@@ -31,14 +31,15 @@ export default function increaseTime (duration) { ...@@ -31,14 +31,15 @@ export default function increaseTime (duration) {
* *
* @param target time in seconds * @param target time in seconds
*/ */
export async function increaseTimeTo (target) { async function increaseTimeTo (target) {
let now = (await latestTime()); let now = (await latestTime());
if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`); if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`);
let diff = target - now; let diff = target - now;
return increaseTime(diff); return increaseTime(diff);
} }
export const duration = { const duration = {
seconds: function (val) { return val; }, seconds: function (val) { return val; },
minutes: function (val) { return val * this.seconds(60); }, minutes: function (val) { return val * this.seconds(60); },
hours: function (val) { return val * this.minutes(60); }, hours: function (val) { return val * this.minutes(60); },
...@@ -46,3 +47,9 @@ export const duration = { ...@@ -46,3 +47,9 @@ export const duration = {
weeks: function (val) { return val * this.days(7); }, weeks: function (val) { return val * this.days(7); },
years: function (val) { return val * this.days(365); }, years: function (val) { return val * this.days(365); },
}; };
module.exports = {
increaseTime,
increaseTimeTo,
duration,
};
import { ethGetBlock } from './web3'; const { ethGetBlock } = require('./web3');
// Returns the time of the last mined block in seconds // Returns the time of the last mined block in seconds
export default async function latestTime () { async function latestTime () {
const block = await ethGetBlock('latest'); const block = await ethGetBlock('latest');
return block.timestamp; return block.timestamp;
} }
module.exports = {
latestTime,
};
import { soliditySha3 } from 'web3-utils'; const { soliditySha3 } = require('web3-utils');
const INTERFACE_ID_LENGTH = 4; const INTERFACE_ID_LENGTH = 4;
export default (interfaces = []) => { function makeInterfaceId (interfaces = []) {
const interfaceIdBuffer = interfaces const interfaceIdBuffer = interfaces
.map(methodSignature => soliditySha3(methodSignature)) // keccak256 .map(methodSignature => soliditySha3(methodSignature)) // keccak256
.map(h => .map(h =>
...@@ -18,4 +18,8 @@ export default (interfaces = []) => { ...@@ -18,4 +18,8 @@ export default (interfaces = []) => {
}, Buffer.alloc(INTERFACE_ID_LENGTH)); }, Buffer.alloc(INTERFACE_ID_LENGTH));
return `0x${interfaceIdBuffer.toString('hex')}`; return `0x${interfaceIdBuffer.toString('hex')}`;
}
module.exports = {
makeInterfaceId,
}; };
import { sha3, bufferToHex } from 'ethereumjs-util'; const { sha3, bufferToHex } = require('ethereumjs-util');
export default class MerkleTree { class MerkleTree {
constructor (elements) { constructor (elements) {
// Filter empty strings and hash elements // Filter empty strings and hash elements
this.elements = elements.filter(el => el).map(el => sha3(el)); this.elements = elements.filter(el => el).map(el => sha3(el));
...@@ -129,3 +129,7 @@ export default class MerkleTree { ...@@ -129,3 +129,7 @@ export default class MerkleTree {
return Buffer.concat([...args].sort(Buffer.compare)); return Buffer.concat([...args].sort(Buffer.compare));
} }
} }
module.exports = {
MerkleTree,
};
const _ = require('lodash'); const _ = require('lodash');
const ethjsABI = require('ethjs-abi'); const ethjsABI = require('ethjs-abi');
export function findMethod (abi, name, args) { function findMethod (abi, name, args) {
for (var i = 0; i < abi.length; i++) { for (var i = 0; i < abi.length; i++) {
const methodArgs = _.map(abi[i].inputs, 'type').join(','); const methodArgs = _.map(abi[i].inputs, 'type').join(',');
if ((abi[i].name === name) && (methodArgs === args)) { if ((abi[i].name === name) && (methodArgs === args)) {
...@@ -10,8 +10,13 @@ export function findMethod (abi, name, args) { ...@@ -10,8 +10,13 @@ export function findMethod (abi, name, args) {
} }
} }
export default function sendTransaction (target, name, argsTypes, argsValues, opts) { function sendTransaction (target, name, argsTypes, argsValues, opts) {
const abiMethod = findMethod(target.abi, name, argsTypes); const abiMethod = findMethod(target.abi, name, argsTypes);
const encodedData = ethjsABI.encodeMethod(abiMethod, argsValues); const encodedData = ethjsABI.encodeMethod(abiMethod, argsValues);
return target.sendTransaction(Object.assign({ data: encodedData }, opts)); return target.sendTransaction(Object.assign({ data: encodedData }, opts));
} }
module.exports = {
findMethod,
sendTransaction,
};
import utils from 'ethereumjs-util'; const utils = require('ethereumjs-util');
/** /**
* Hash and add same prefix to the hash that ganache use. * Hash and add same prefix to the hash that ganache use.
* @param {string} message the plaintext/ascii/original message * @param {string} message the plaintext/ascii/original message
* @return {string} the hash of the message, prefixed, and then hashed again * @return {string} the hash of the message, prefixed, and then hashed again
*/ */
export const hashMessage = (message) => { function hashMessage (message) {
const messageHex = Buffer.from(utils.sha3(message).toString('hex'), 'hex'); 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('\u0019Ethereum Signed Message:\n' + messageHex.length.toString());
return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex]))); return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex])));
}; }
// signs message using web3 (auto-applies prefix) // signs message using web3 (auto-applies prefix)
export const signMessage = (signer, message = '', options = {}) => { function signMessage (signer, message = '', options = {}) {
return web3.eth.sign(signer, web3.sha3(message, options)); return web3.eth.sign(signer, web3.sha3(message, options));
}; }
// signs hex string using web3 (auto-applies prefix) // signs hex string using web3 (auto-applies prefix)
export const signHex = (signer, message = '') => { function signHex (signer, message = '') {
return signMessage(signer, message, { encoding: 'hex' }); return signMessage(signer, message, { encoding: 'hex' });
}
module.exports = {
hashMessage,
signMessage,
signHex,
}; };
// From https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6
// from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6 function transactionMined (txnHash, interval) {
module.export = web3.eth.transactionMined = function (txnHash, interval) {
var transactionReceiptAsync; var transactionReceiptAsync;
interval = interval || 500; interval = interval || 500;
transactionReceiptAsync = function (txnHash, resolve, reject) { transactionReceiptAsync = function (txnHash, resolve, reject) {
...@@ -30,4 +29,10 @@ module.export = web3.eth.transactionMined = function (txnHash, interval) { ...@@ -30,4 +29,10 @@ module.export = web3.eth.transactionMined = function (txnHash, interval) {
transactionReceiptAsync(txnHash, resolve, reject); transactionReceiptAsync(txnHash, resolve, reject);
}); });
} }
}
web3.eth.transactionMined = transactionMined;
module.exports = {
transactionMined,
}; };
...@@ -2,6 +2,8 @@ const pify = require('pify'); ...@@ -2,6 +2,8 @@ const pify = require('pify');
const ethAsync = pify(web3.eth); const ethAsync = pify(web3.eth);
export const ethGetBalance = ethAsync.getBalance; module.exports = {
export const ethSendTransaction = ethAsync.sendTransaction; ethGetBalance: ethAsync.getBalance,
export const ethGetBlock = ethAsync.getBlock; ethSendTransaction: ethAsync.sendTransaction,
ethGetBlock: ethAsync.getBlock,
};
import makeInterfaceId from '../helpers/makeInterfaceId'; const { makeInterfaceId } = require('../helpers/makeInterfaceId');
const INTERFACE_IDS = { const INTERFACE_IDS = {
ERC165: makeInterfaceId([ ERC165: makeInterfaceId([
...@@ -30,7 +30,7 @@ const INTERFACE_IDS = { ...@@ -30,7 +30,7 @@ const INTERFACE_IDS = {
]), ]),
}; };
export default function (interfaces = []) { function shouldSupportInterfaces (interfaces = []) {
describe('ERC165\'s supportsInterface(bytes4)', function () { describe('ERC165\'s supportsInterface(bytes4)', function () {
beforeEach(function () { beforeEach(function () {
this.thing = this.mock || this.token; this.thing = this.mock || this.token;
...@@ -52,3 +52,7 @@ export default function (interfaces = []) { ...@@ -52,3 +52,7 @@ export default function (interfaces = []) {
} }
}); });
} }
module.exports = {
shouldSupportInterfaces,
};
import shouldSupportInterfaces from './SupportsInterface.behavior'; const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
import assertRevert from '../helpers/assertRevert'; const { assertRevert } = require('../helpers/assertRevert');
const SupportsInterfaceWithLookup = artifacts.require('SupportsInterfaceWithLookupMock'); const SupportsInterfaceWithLookup = artifacts.require('SupportsInterfaceWithLookupMock');
......
const { hashMessage, signMessage } = require('../helpers/sign');
const { expectThrow } = require('../helpers/expectThrow');
import {
hashMessage,
signMessage,
} from '../helpers/sign';
import expectThrow from '../helpers/expectThrow';
const ECRecoveryMock = artifacts.require('ECRecoveryMock'); const ECRecoveryMock = artifacts.require('ECRecoveryMock');
require('chai') require('chai')
......
const { MerkleTree } = require('../helpers/merkleTree.js');
import MerkleTree from '../helpers/merkleTree.js'; const { sha3, bufferToHex } = require('ethereumjs-util');
import { sha3, bufferToHex } from 'ethereumjs-util';
var MerkleProofWrapper = artifacts.require('MerkleProofWrapper'); var MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
......
import { ethGetBalance } from '../helpers/web3'; var Destructible = artifacts.require('Destructible');
const { ethGetBalance } = require('../helpers/web3');
const Destructible = artifacts.require('Destructible');
require('../helpers/transactionMined.js');
contract('Destructible', function (accounts) { contract('Destructible', function (accounts) {
it('should send balance to owner after destruction', async function () { it('should send balance to owner after destruction', async function () {
......
const { assertRevert } = require('../helpers/assertRevert');
import assertRevert from '../helpers/assertRevert';
const PausableMock = artifacts.require('PausableMock'); const PausableMock = artifacts.require('PausableMock');
contract('Pausable', function (accounts) { contract('Pausable', function (accounts) {
......
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
var TokenDestructible = artifacts.require('TokenDestructible'); var TokenDestructible = artifacts.require('TokenDestructible');
var StandardTokenMock = artifacts.require('StandardTokenMock'); var StandardTokenMock = artifacts.require('StandardTokenMock');
require('../helpers/transactionMined.js');
contract('TokenDestructible', function (accounts) { contract('TokenDestructible', function (accounts) {
let destructible; let destructible;
......
import assertJump from '../helpers/assertJump'; const { assertJump } = require('../helpers/assertJump');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
const SafeMathMock = artifacts.require('SafeMathMock'); const SafeMathMock = artifacts.require('SafeMathMock');
......
const { expectThrow } = require('../helpers/expectThrow');
import expectThrow from '../helpers/expectThrow';
const CanReclaimToken = artifacts.require('CanReclaimToken'); const CanReclaimToken = artifacts.require('CanReclaimToken');
const BasicTokenMock = artifacts.require('BasicTokenMock'); const BasicTokenMock = artifacts.require('BasicTokenMock');
......
const { assertRevert } = require('../helpers/assertRevert');
import assertRevert from '../helpers/assertRevert';
var Claimable = artifacts.require('Claimable'); var Claimable = artifacts.require('Claimable');
......
var Contactable = artifacts.require('Contactable'); var Contactable = artifacts.require('Contactable');
contract('Contactable', function (accounts) { contract('Contactable', function (accounts) {
......
import assertRevert from '../helpers/assertRevert'; const { assertRevert } = require('../helpers/assertRevert');
var DelayedClaimable = artifacts.require('DelayedClaimable'); var DelayedClaimable = artifacts.require('DelayedClaimable');
......
const { expectThrow } = require('../helpers/expectThrow');
import expectThrow from '../helpers/expectThrow';
const Ownable = artifacts.require('Ownable'); const Ownable = artifacts.require('Ownable');
const HasNoContracts = artifacts.require('HasNoContracts'); const HasNoContracts = artifacts.require('HasNoContracts');
......
import { ethSendTransaction, ethGetBalance } from '../helpers/web3'; const { expectThrow } = require('../helpers/expectThrow');
import expectThrow from '../helpers/expectThrow'; const { ethSendTransaction, ethGetBalance } = require('../helpers/web3');
const HasNoEtherTest = artifacts.require('HasNoEtherTest'); const HasNoEtherTest = artifacts.require('HasNoEtherTest');
const ForceEther = artifacts.require('ForceEther'); const ForceEther = artifacts.require('ForceEther');
......
const { expectThrow } = require('../helpers/expectThrow');
import expectThrow from '../helpers/expectThrow';
const HasNoTokens = artifacts.require('HasNoTokens'); const HasNoTokens = artifacts.require('HasNoTokens');
const ERC223TokenMock = artifacts.require('ERC223TokenMock'); const ERC223TokenMock = artifacts.require('ERC223TokenMock');
......
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
...@@ -6,7 +6,7 @@ require('chai') ...@@ -6,7 +6,7 @@ require('chai')
.use(require('chai-as-promised')) .use(require('chai-as-promised'))
.should(); .should();
export default function (accounts) { function shouldBehaveLikeOwnable (accounts) {
describe('as an ownable', function () { describe('as an ownable', function () {
it('should have an owner', async function () { it('should have an owner', async function () {
let owner = await this.ownable.owner(); let owner = await this.ownable.owner();
...@@ -47,4 +47,8 @@ export default function (accounts) { ...@@ -47,4 +47,8 @@ export default function (accounts) {
await this.ownable.renounceOwnership({ from: other }).should.be.rejectedWith(EVMRevert); await this.ownable.renounceOwnership({ from: other }).should.be.rejectedWith(EVMRevert);
}); });
}); });
}
module.exports = {
shouldBehaveLikeOwnable,
}; };
import shouldBehaveLikeOwnable from './Ownable.behaviour'; const { shouldBehaveLikeOwnable } = require('./Ownable.behaviour');
const Ownable = artifacts.require('Ownable'); const Ownable = artifacts.require('Ownable');
......
import expectThrow from '../helpers/expectThrow'; const { expectThrow } = require('../helpers/expectThrow');
import expectEvent from '../helpers/expectEvent'; const expectEvent = require('../helpers/expectEvent');
const Superuser = artifacts.require('Superuser'); const Superuser = artifacts.require('Superuser');
......
import expectThrow from '../helpers/expectThrow'; const { expectThrow } = require('../helpers/expectThrow');
import expectEvent from '../helpers/expectEvent'; const expectEvent = require('../helpers/expectEvent');
const WhitelistMock = artifacts.require('WhitelistMock'); const WhitelistMock = artifacts.require('WhitelistMock');
......
import expectThrow from '../../helpers/expectThrow'; const { expectThrow } = require('../../helpers/expectThrow');
import expectEvent from '../../helpers/expectEvent'; const expectEvent = require('../../helpers/expectEvent');
const RBACMock = artifacts.require('RBACMock'); const RBACMock = artifacts.require('RBACMock');
......
import shouldBehaveLikeEscrow from './Escrow.behaviour'; const { shouldBehaveLikeEscrow } = require('./Escrow.behaviour');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import expectEvent from '../helpers/expectEvent'; const expectEvent = require('../helpers/expectEvent');
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
...@@ -8,7 +8,7 @@ require('chai') ...@@ -8,7 +8,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber)) .use(require('chai-bignumber')(BigNumber))
.should(); .should();
export default function (owner, [payee1, payee2]) { function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
const amount = web3.toWei(42.0, 'ether'); const amount = web3.toWei(42.0, 'ether');
describe('as an escrow', function () { describe('as an escrow', function () {
...@@ -96,4 +96,8 @@ export default function (owner, [payee1, payee2]) { ...@@ -96,4 +96,8 @@ export default function (owner, [payee1, payee2]) {
}); });
}); });
}); });
}
module.exports = {
shouldBehaveLikeEscrow,
}; };
import shouldBehaveLikeEscrow from './Escrow.behaviour'; const { shouldBehaveLikeEscrow } = require('./Escrow.behaviour');
const Escrow = artifacts.require('Escrow'); const Escrow = artifacts.require('Escrow');
......
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import EVMRevert from '../helpers/EVMRevert'; const { EVMRevert } = require('../helpers/EVMRevert');
import expectEvent from '../helpers/expectEvent'; const expectEvent = require('../helpers/expectEvent');
import { ethGetBalance } from '../helpers/web3'; const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import { ethGetBalance, ethSendTransaction } from '../helpers/web3'; const { ethGetBalance, ethSendTransaction } = require('../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
const BasicToken = artifacts.require('BasicTokenMock'); const BasicToken = artifacts.require('BasicTokenMock');
contract('StandardToken', function ([_, owner, recipient, anotherAccount]) { contract('StandardToken', function ([_, owner, recipient, anotherAccount]) {
......
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
import { inLogs } from '../../helpers/expectEvent'; const { inLogs } = require('../../helpers/expectEvent');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
...@@ -9,7 +9,7 @@ require('chai') ...@@ -9,7 +9,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber)) .use(require('chai-bignumber')(BigNumber))
.should(); .should();
export default function ([owner], initialBalance) { function shouldBehaveLikeBurnableToken ([owner], initialBalance) {
describe('as a basic burnable token', function () { describe('as a basic burnable token', function () {
const from = owner; const from = owner;
...@@ -47,4 +47,8 @@ export default function ([owner], initialBalance) { ...@@ -47,4 +47,8 @@ export default function ([owner], initialBalance) {
}); });
}); });
}); });
}
module.exports = {
shouldBehaveLikeBurnableToken,
}; };
import shouldBehaveLikeBurnableToken from './BurnableToken.behaviour'; const { shouldBehaveLikeBurnableToken } = require('./BurnableToken.behaviour');
const BurnableTokenMock = artifacts.require('BurnableTokenMock'); const BurnableTokenMock = artifacts.require('BurnableTokenMock');
contract('BurnableToken', function ([owner]) { contract('BurnableToken', function ([owner]) {
......
import expectThrow from '../../helpers/expectThrow'; const { expectThrow } = require('../../helpers/expectThrow');
export default function ([owner, anotherAccount, minter, cap]) { function shouldBehaveLikeCappedToken ([owner, anotherAccount, minter, cap]) {
describe('capped token', function () { describe('capped token', function () {
const from = minter; const from = minter;
...@@ -26,3 +26,7 @@ export default function ([owner, anotherAccount, minter, cap]) { ...@@ -26,3 +26,7 @@ export default function ([owner, anotherAccount, minter, cap]) {
}); });
}); });
} }
module.exports = {
shouldBehaveLikeCappedToken,
};
import ether from '../../helpers/ether'; const { ether } = require('../../helpers/ether');
import shouldBehaveLikeMintableToken from './MintableToken.behaviour'; const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
import shouldBehaveLikeCappedToken from './CappedToken.behaviour'; const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour');
var CappedToken = artifacts.require('CappedToken'); var CappedToken = artifacts.require('CappedToken');
......
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
...@@ -7,7 +7,7 @@ require('chai') ...@@ -7,7 +7,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber)) .use(require('chai-bignumber')(BigNumber))
.should(); .should();
export default function ([owner, anotherAccount, minter]) { function shouldBehaveLikeMintableToken ([owner, anotherAccount, minter]) {
describe('as a basic mintable token', function () { describe('as a basic mintable token', function () {
describe('after token creation', function () { describe('after token creation', function () {
it('sender should be token owner', async function () { it('sender should be token owner', async function () {
...@@ -145,4 +145,8 @@ export default function ([owner, anotherAccount, minter]) { ...@@ -145,4 +145,8 @@ export default function ([owner, anotherAccount, minter]) {
}); });
}); });
}); });
}
module.exports = {
shouldBehaveLikeMintableToken,
}; };
import shouldBehaveLikeMintableToken from './MintableToken.behaviour'; const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const MintableToken = artifacts.require('MintableToken'); const MintableToken = artifacts.require('MintableToken');
contract('MintableToken', function ([owner, anotherAccount]) { contract('MintableToken', function ([owner, anotherAccount]) {
......
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
const PausableToken = artifacts.require('PausableTokenMock'); const PausableToken = artifacts.require('PausableTokenMock');
contract('PausableToken', function ([_, owner, recipient, anotherAccount]) { contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
......
import ether from '../../helpers/ether'; const { ether } = require('../../helpers/ether');
import shouldBehaveLikeRBACMintableToken from './RBACMintableToken.behaviour'; const { shouldBehaveLikeRBACMintableToken } = require('./RBACMintableToken.behaviour');
import shouldBehaveLikeMintableToken from './MintableToken.behaviour'; const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
import shouldBehaveLikeCappedToken from './CappedToken.behaviour'; const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour');
const RBACCappedTokenMock = artifacts.require('RBACCappedTokenMock'); const RBACCappedTokenMock = artifacts.require('RBACCappedTokenMock');
......
import expectThrow from '../../helpers/expectThrow'; const { expectThrow } = require('../../helpers/expectThrow');
const ROLE_MINTER = 'minter'; const ROLE_MINTER = 'minter';
export default function ([owner, anotherAccount]) { function shouldBehaveLikeRBACMintableToken ([owner, anotherAccount]) {
describe('handle roles', function () { describe('handle roles', function () {
it('owner can add and remove a minter role', async function () { it('owner can add and remove a minter role', async function () {
await this.token.addMinter(anotherAccount, { from: owner }); await this.token.addMinter(anotherAccount, { from: owner });
...@@ -25,4 +25,8 @@ export default function ([owner, anotherAccount]) { ...@@ -25,4 +25,8 @@ export default function ([owner, anotherAccount]) {
); );
}); });
}); });
}
module.exports = {
shouldBehaveLikeRBACMintableToken,
}; };
import shouldBehaveLikeRBACMintableToken from './RBACMintableToken.behaviour'; const { shouldBehaveLikeRBACMintableToken } = require('./RBACMintableToken.behaviour');
import shouldBehaveLikeMintableToken from './MintableToken.behaviour'; const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const RBACMintableToken = artifacts.require('RBACMintableToken'); const RBACMintableToken = artifacts.require('RBACMintableToken');
......
import EVMRevert from '../../helpers/EVMRevert'; const { EVMRevert } = require('../../helpers/EVMRevert');
require('chai') require('chai')
.use(require('chai-as-promised')) .use(require('chai-as-promised'))
......
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
import { inLogs } from '../../helpers/expectEvent'; const { inLogs } = require('../../helpers/expectEvent');
import shouldBehaveLikeBurnableToken from './BurnableToken.behaviour'; const { shouldBehaveLikeBurnableToken } = require('./BurnableToken.behaviour');
const StandardBurnableTokenMock = artifacts.require('StandardBurnableTokenMock'); const StandardBurnableTokenMock = artifacts.require('StandardBurnableTokenMock');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
const StandardTokenMock = artifacts.require('StandardTokenMock'); const StandardTokenMock = artifacts.require('StandardTokenMock');
contract('StandardToken', function ([_, owner, recipient, anotherAccount]) { contract('StandardToken', function ([_, owner, recipient, anotherAccount]) {
......
import latestTime from '../../helpers/latestTime'; const { latestTime } = require('../../helpers/latestTime');
import { increaseTimeTo, duration } from '../../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../../helpers/increaseTime');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import EVMRevert from '../../helpers/EVMRevert'; const { EVMRevert } = require('../../helpers/EVMRevert');
import latestTime from '../../helpers/latestTime'; const { latestTime } = require('../../helpers/latestTime');
import { increaseTimeTo, duration } from '../../helpers/increaseTime'; const { increaseTimeTo, duration } = require('../../helpers/increaseTime');
import { ethGetBlock } from '../../helpers/web3'; const { ethGetBlock } = require('../../helpers/web3');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
......
import shouldSupportInterfaces from '../../introspection/SupportsInterface.behavior'; const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
import decodeLogs from '../../helpers/decodeLogs'; const { decodeLogs } = require('../../helpers/decodeLogs');
import sendTransaction from '../../helpers/sendTransaction'; const { sendTransaction } = require('../../helpers/sendTransaction');
import _ from 'lodash'; const _ = require('lodash');
const ERC721Receiver = artifacts.require('ERC721ReceiverMock.sol'); const ERC721Receiver = artifacts.require('ERC721ReceiverMock.sol');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
...@@ -12,7 +12,7 @@ require('chai') ...@@ -12,7 +12,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber)) .use(require('chai-bignumber')(BigNumber))
.should(); .should();
export default function shouldBehaveLikeERC721BasicToken (accounts) { function shouldBehaveLikeERC721BasicToken (accounts) {
const firstTokenId = 1; const firstTokenId = 1;
const secondTokenId = 2; const secondTokenId = 2;
const unknownTokenId = 3; const unknownTokenId = 3;
...@@ -558,4 +558,8 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) { ...@@ -558,4 +558,8 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) {
'ERC721Exists', 'ERC721Exists',
]); ]);
}); });
}
module.exports = {
shouldBehaveLikeERC721BasicToken,
}; };
import shouldBehaveLikeERC721BasicToken from './ERC721BasicToken.behaviour'; const { shouldBehaveLikeERC721BasicToken } = require('./ERC721BasicToken.behaviour');
import shouldMintAndBurnERC721Token from './ERC721MintBurn.behaviour'; const { shouldBehaveLikeMintAndBurnERC721Token } = require('./ERC721MintBurn.behaviour');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
const ERC721BasicToken = artifacts.require('ERC721BasicTokenMock.sol'); const ERC721BasicToken = artifacts.require('ERC721BasicTokenMock.sol');
...@@ -15,5 +15,5 @@ contract('ERC721BasicToken', function (accounts) { ...@@ -15,5 +15,5 @@ contract('ERC721BasicToken', function (accounts) {
}); });
shouldBehaveLikeERC721BasicToken(accounts); shouldBehaveLikeERC721BasicToken(accounts);
shouldMintAndBurnERC721Token(accounts); shouldBehaveLikeMintAndBurnERC721Token(accounts);
}); });
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
require('chai') require('chai')
...@@ -6,7 +6,7 @@ require('chai') ...@@ -6,7 +6,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber)) .use(require('chai-bignumber')(BigNumber))
.should(); .should();
export default function shouldMintAndBurnERC721Token (accounts) { function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
const firstTokenId = 1; const firstTokenId = 1;
const secondTokenId = 2; const secondTokenId = 2;
const unknownTokenId = 3; const unknownTokenId = 3;
...@@ -108,4 +108,8 @@ export default function shouldMintAndBurnERC721Token (accounts) { ...@@ -108,4 +108,8 @@ export default function shouldMintAndBurnERC721Token (accounts) {
}); });
}); });
}); });
}
module.exports = {
shouldBehaveLikeMintAndBurnERC721Token,
}; };
import assertRevert from '../../helpers/assertRevert'; const { assertRevert } = require('../../helpers/assertRevert');
import shouldBehaveLikeERC721BasicToken from './ERC721BasicToken.behaviour'; const { shouldBehaveLikeERC721BasicToken } = require('./ERC721BasicToken.behaviour');
import shouldMintAndBurnERC721Token from './ERC721MintBurn.behaviour'; const { shouldBehaveLikeMintAndBurnERC721Token } = require('./ERC721MintBurn.behaviour');
import shouldSupportInterfaces from '../../introspection/SupportsInterface.behavior'; const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
import _ from 'lodash'; const _ = require('lodash');
const BigNumber = web3.BigNumber; const BigNumber = web3.BigNumber;
const ERC721Token = artifacts.require('ERC721TokenMock.sol'); const ERC721Token = artifacts.require('ERC721TokenMock.sol');
...@@ -24,7 +24,7 @@ contract('ERC721Token', function (accounts) { ...@@ -24,7 +24,7 @@ contract('ERC721Token', function (accounts) {
}); });
shouldBehaveLikeERC721BasicToken(accounts); shouldBehaveLikeERC721BasicToken(accounts);
shouldMintAndBurnERC721Token(accounts); shouldBehaveLikeMintAndBurnERC721Token(accounts);
describe('like a full ERC721', function () { describe('like a full ERC721', function () {
beforeEach(async function () { beforeEach(async function () {
......
require('dotenv').config(); require('dotenv').config();
require('babel-register');
require('babel-polyfill');
const HDWalletProvider = require('truffle-hdwallet-provider'); const HDWalletProvider = require('truffle-hdwallet-provider');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment