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 @@
"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": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/babel-preset-env/-/babel-preset-env-1.7.0.tgz",
......
......@@ -37,11 +37,6 @@
},
"homepage": "https://github.com/OpenZeppelin/zeppelin-solidity",
"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-as-promised": "^7.0.0",
"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({
from, to, value,
});
var SecureTargetBounty = artifacts.require('SecureTargetBounty');
var InsecureTargetBounty = artifacts.require('InsecureTargetBounty');
function awaitEvent (event, handler) {
return new Promise((resolve, reject) => {
......
import increaseTime from './helpers/increaseTime';
import expectThrow from './helpers/expectThrow';
import assertRevert from './helpers/assertRevert';
const { increaseTime } = require('./helpers/increaseTime');
const { expectThrow } = require('./helpers/expectThrow');
const { assertRevert } = require('./helpers/assertRevert');
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
......
import assertRevert from './helpers/assertRevert';
import { ethGetBalance } from './helpers/web3';
const { assertRevert } = require('./helpers/assertRevert');
const { ethGetBalance } = require('./helpers/web3');
var LimitBalanceMock = artifacts.require('LimitBalanceMock');
......
import expectThrow from './helpers/expectThrow';
const { expectThrow } = require('./helpers/expectThrow');
const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
......
import expectThrow from './helpers/expectThrow';
import { ethGetBalance, ethSendTransaction } from './helpers/web3';
const { expectThrow } = require('./helpers/expectThrow');
const { ethGetBalance, ethSendTransaction } = require('./helpers/web3');
const SimpleSavingsWallet = artifacts.require('SimpleSavingsWallet');
......
import assertRevert from '../helpers/assertRevert';
import { signHex } from '../helpers/sign';
const { assertRevert } = require('../helpers/assertRevert');
const { signHex } = require('../helpers/sign');
const Bouncer = artifacts.require('SignatureBouncerMock');
......@@ -8,19 +7,19 @@ require('chai')
.use(require('chai-as-promised'))
.should();
export const getSigner = (contract, signer, data = '') => (addr) => {
const getSigner = (contract, signer, data = '') => (addr) => {
// via: https://github.com/OpenZeppelin/zeppelin-solidity/pull/812/files
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`
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,...)'
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
const strippedHexVal = hexVal.substr(2);
return start ? strippedHexVal.padStart(sizeInBytes * 2, 0) : strippedHexVal.padEnd(sizeInBytes * 2, 0);
......
import ether from '../helpers/ether';
import assertRevert from '../helpers/assertRevert';
import { ethGetBalance } from '../helpers/web3';
const { ether } = require('../helpers/ether');
const { assertRevert } = require('../helpers/assertRevert');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import EVMRevert from '../helpers/EVMRevert';
const { ether } = require('../helpers/ether');
const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import { ethGetBalance } from '../helpers/web3';
const { ether } = require('../helpers/ether');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';
const { advanceBlock } = require('../helpers/advanceToBlock');
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
const { latestTime } = require('../helpers/latestTime');
const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
const { ether } = require('../helpers/ether');
const { advanceBlock } = require('../helpers/advanceToBlock');
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
const { latestTime } = require('../helpers/latestTime');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import EVMRevert from '../helpers/EVMRevert';
const { ether } = require('../helpers/ether');
const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber;
......
import { ethGetBalance } from '../helpers/web3';
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......@@ -7,7 +7,7 @@ const should = require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
export default function ([_, investor, wallet, purchaser], rate, value) {
function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate, value) {
const expectedTokenAmount = rate.mul(value);
describe('as a minted crowdsale', function () {
......@@ -44,3 +44,7 @@ export default function ([_, investor, wallet, purchaser], rate, value) {
});
});
}
module.exports = {
shouldBehaveLikeMintedCrowdsale,
};
import shouldBehaveLikeMintedCrowdsale from './MintedCrowdsale.behaviour';
import ether from '../helpers/ether';
const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behaviour');
const { ether } = require('../helpers/ether');
const BigNumber = web3.BigNumber;
......
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';
import ether from '../helpers/ether';
const { advanceBlock } = require('../helpers/advanceToBlock');
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
const { latestTime } = require('../helpers/latestTime');
const { EVMRevert } = require('../helpers/EVMRevert');
const { ether } = require('../helpers/ether');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';
import { ethGetBalance } from '../helpers/web3';
const { ether } = require('../helpers/ether');
const { advanceBlock } = require('../helpers/advanceToBlock');
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
const { latestTime } = require('../helpers/latestTime');
const { EVMRevert } = require('../helpers/EVMRevert');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';
const { ether } = require('../helpers/ether');
const { advanceBlock } = require('../helpers/advanceToBlock');
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
const { latestTime } = require('../helpers/latestTime');
const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
const { ether } = require('../helpers/ether');
const BigNumber = web3.BigNumber;
......
import ether from '../helpers/ether';
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';
import assertRevert from '../helpers/assertRevert';
import { ethGetBalance } from '../helpers/web3';
const { ether } = require('../helpers/ether');
const { advanceBlock } = require('../helpers/advanceToBlock');
const { increaseTimeTo, duration } = require('../helpers/increaseTime');
const { latestTime } = require('../helpers/latestTime');
const { EVMRevert } = require('../helpers/EVMRevert');
const { assertRevert } = require('../helpers/assertRevert');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import decodeLogs from '../helpers/decodeLogs';
const { decodeLogs } = require('../helpers/decodeLogs');
const SimpleToken = artifacts.require('SimpleToken');
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) => {
web3.currentProvider.sendAsync({
jsonrpc: '2.0',
......@@ -11,7 +11,7 @@ export function advanceBlock () {
}
// 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) {
throw Error(`block number ${number} is in the past (current is ${web3.eth.blockNumber})`);
}
......@@ -20,3 +20,8 @@ export default async function advanceToBlock (number) {
await advanceBlock();
}
}
module.exports = {
advanceBlock,
advanceToBlock,
};
export default async promise => {
async function assertJump (promise) {
try {
await promise;
assert.fail('Expected invalid opcode not received');
......@@ -6,4 +6,8 @@ export default async promise => {
const invalidOpcodeReceived = error.message.search('invalid opcode') >= 0;
assert(invalidOpcodeReceived, `Expected "invalid opcode", got ${error} instead`);
}
}
module.exports = {
assertJump,
};
export default async promise => {
async function assertRevert (promise) {
try {
await promise;
assert.fail('Expected revert not received');
......@@ -6,4 +6,8 @@ export default async promise => {
const revertFound = error.message.search('revert') >= 0;
assert(revertFound, `Expected "revert", got ${error} instead`);
}
}
module.exports = {
assertRevert,
};
const SolidityEvent = require('web3/lib/web3/event.js');
export default function decodeLogs (logs, contract, address) {
function decodeLogs (logs, contract, address) {
return logs.map(log => {
const event = new SolidityEvent(null, contract.events[log.topics[0]], address);
return event.decode(log);
});
}
module.exports = {
decodeLogs,
};
export default function ether (n) {
function ether (n) {
return new web3.BigNumber(web3.toWei(n, 'ether'));
}
module.exports = {
ether,
};
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);
should.exist(event);
for (const [k, v] of Object.entries(eventArgs)) {
......@@ -8,12 +8,12 @@ const inLogs = async (logs, eventName, eventArgs = {}) => {
event.args[k].should.eq(v);
}
return event;
};
}
const inTransaction = async (tx, eventName, eventArgs = {}) => {
async function inTransaction (tx, eventName, eventArgs = {}) {
const { logs } = await tx;
return inLogs(logs, eventName, eventArgs);
};
}
module.exports = {
inLogs,
......
export default async promise => {
async function expectThrow (promise) {
try {
await promise;
} catch (error) {
......@@ -18,4 +18,8 @@ export default async promise => {
return;
}
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
export default function increaseTime (duration) {
function increaseTime (duration) {
const id = Date.now();
return new Promise((resolve, reject) => {
......@@ -31,14 +31,15 @@ export default function increaseTime (duration) {
*
* @param target time in seconds
*/
export async function increaseTimeTo (target) {
async function increaseTimeTo (target) {
let now = (await latestTime());
if (target < now) throw Error(`Cannot increase current time(${now}) to a moment in the past(${target})`);
let diff = target - now;
return increaseTime(diff);
}
export const duration = {
const duration = {
seconds: function (val) { return val; },
minutes: function (val) { return val * this.seconds(60); },
hours: function (val) { return val * this.minutes(60); },
......@@ -46,3 +47,9 @@ export const duration = {
weeks: function (val) { return val * this.days(7); },
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
export default async function latestTime () {
async function latestTime () {
const block = await ethGetBlock('latest');
return block.timestamp;
}
module.exports = {
latestTime,
};
import { soliditySha3 } from 'web3-utils';
const { soliditySha3 } = require('web3-utils');
const INTERFACE_ID_LENGTH = 4;
export default (interfaces = []) => {
function makeInterfaceId (interfaces = []) {
const interfaceIdBuffer = interfaces
.map(methodSignature => soliditySha3(methodSignature)) // keccak256
.map(h =>
......@@ -18,4 +18,8 @@ export default (interfaces = []) => {
}, Buffer.alloc(INTERFACE_ID_LENGTH));
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) {
// Filter empty strings and hash elements
this.elements = elements.filter(el => el).map(el => sha3(el));
......@@ -129,3 +129,7 @@ export default class MerkleTree {
return Buffer.concat([...args].sort(Buffer.compare));
}
}
module.exports = {
MerkleTree,
};
const _ = require('lodash');
const ethjsABI = require('ethjs-abi');
export function findMethod (abi, name, args) {
function findMethod (abi, name, args) {
for (var i = 0; i < abi.length; i++) {
const methodArgs = _.map(abi[i].inputs, 'type').join(',');
if ((abi[i].name === name) && (methodArgs === 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 encodedData = ethjsABI.encodeMethod(abiMethod, argsValues);
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.
* @param {string} message the plaintext/ascii/original message
* @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 prefix = utils.toBuffer('\u0019Ethereum Signed Message:\n' + messageHex.length.toString());
return utils.bufferToHex(utils.sha3(Buffer.concat([prefix, messageHex])));
};
}
// 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));
};
}
// signs hex string using web3 (auto-applies prefix)
export const signHex = (signer, message = '') => {
function signHex (signer, message = '') {
return signMessage(signer, message, { encoding: 'hex' });
}
module.exports = {
hashMessage,
signMessage,
signHex,
};
// from https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6
module.export = web3.eth.transactionMined = function (txnHash, interval) {
// From https://gist.github.com/xavierlepretre/88682e871f4ad07be4534ae560692ee6
function transactionMined (txnHash, interval) {
var transactionReceiptAsync;
interval = interval || 500;
transactionReceiptAsync = function (txnHash, resolve, reject) {
......@@ -30,4 +29,10 @@ module.export = web3.eth.transactionMined = function (txnHash, interval) {
transactionReceiptAsync(txnHash, resolve, reject);
});
}
}
web3.eth.transactionMined = transactionMined;
module.exports = {
transactionMined,
};
......@@ -2,6 +2,8 @@ const pify = require('pify');
const ethAsync = pify(web3.eth);
export const ethGetBalance = ethAsync.getBalance;
export const ethSendTransaction = ethAsync.sendTransaction;
export const ethGetBlock = ethAsync.getBlock;
module.exports = {
ethGetBalance: ethAsync.getBalance,
ethSendTransaction: ethAsync.sendTransaction,
ethGetBlock: ethAsync.getBlock,
};
import makeInterfaceId from '../helpers/makeInterfaceId';
const { makeInterfaceId } = require('../helpers/makeInterfaceId');
const INTERFACE_IDS = {
ERC165: makeInterfaceId([
......@@ -30,7 +30,7 @@ const INTERFACE_IDS = {
]),
};
export default function (interfaces = []) {
function shouldSupportInterfaces (interfaces = []) {
describe('ERC165\'s supportsInterface(bytes4)', function () {
beforeEach(function () {
this.thing = this.mock || this.token;
......@@ -52,3 +52,7 @@ export default function (interfaces = []) {
}
});
}
module.exports = {
shouldSupportInterfaces,
};
import shouldSupportInterfaces from './SupportsInterface.behavior';
import assertRevert from '../helpers/assertRevert';
const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
const { assertRevert } = require('../helpers/assertRevert');
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');
require('chai')
......
import MerkleTree from '../helpers/merkleTree.js';
import { sha3, bufferToHex } from 'ethereumjs-util';
const { MerkleTree } = require('../helpers/merkleTree.js');
const { sha3, bufferToHex } = require('ethereumjs-util');
var MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
......
import { ethGetBalance } from '../helpers/web3';
const Destructible = artifacts.require('Destructible');
require('../helpers/transactionMined.js');
var Destructible = artifacts.require('Destructible');
const { ethGetBalance } = require('../helpers/web3');
contract('Destructible', function (accounts) {
it('should send balance to owner after destruction', async function () {
......
import assertRevert from '../helpers/assertRevert';
const { assertRevert } = require('../helpers/assertRevert');
const PausableMock = artifacts.require('PausableMock');
contract('Pausable', function (accounts) {
......
import { ethGetBalance } from '../helpers/web3';
const { ethGetBalance } = require('../helpers/web3');
var TokenDestructible = artifacts.require('TokenDestructible');
var StandardTokenMock = artifacts.require('StandardTokenMock');
require('../helpers/transactionMined.js');
contract('TokenDestructible', function (accounts) {
let destructible;
......
import assertJump from '../helpers/assertJump';
const { assertJump } = require('../helpers/assertJump');
const BigNumber = web3.BigNumber;
const SafeMathMock = artifacts.require('SafeMathMock');
......
import expectThrow from '../helpers/expectThrow';
const { expectThrow } = require('../helpers/expectThrow');
const CanReclaimToken = artifacts.require('CanReclaimToken');
const BasicTokenMock = artifacts.require('BasicTokenMock');
......
import assertRevert from '../helpers/assertRevert';
const { assertRevert } = require('../helpers/assertRevert');
var Claimable = artifacts.require('Claimable');
......
var Contactable = artifacts.require('Contactable');
contract('Contactable', function (accounts) {
......
import assertRevert from '../helpers/assertRevert';
const { assertRevert } = require('../helpers/assertRevert');
var DelayedClaimable = artifacts.require('DelayedClaimable');
......
import expectThrow from '../helpers/expectThrow';
const { expectThrow } = require('../helpers/expectThrow');
const Ownable = artifacts.require('Ownable');
const HasNoContracts = artifacts.require('HasNoContracts');
......
import { ethSendTransaction, ethGetBalance } from '../helpers/web3';
import expectThrow from '../helpers/expectThrow';
const { expectThrow } = require('../helpers/expectThrow');
const { ethSendTransaction, ethGetBalance } = require('../helpers/web3');
const HasNoEtherTest = artifacts.require('HasNoEtherTest');
const ForceEther = artifacts.require('ForceEther');
......
import expectThrow from '../helpers/expectThrow';
const { expectThrow } = require('../helpers/expectThrow');
const HasNoTokens = artifacts.require('HasNoTokens');
const ERC223TokenMock = artifacts.require('ERC223TokenMock');
......
import EVMRevert from '../helpers/EVMRevert';
const { EVMRevert } = require('../helpers/EVMRevert');
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
......@@ -6,7 +6,7 @@ require('chai')
.use(require('chai-as-promised'))
.should();
export default function (accounts) {
function shouldBehaveLikeOwnable (accounts) {
describe('as an ownable', function () {
it('should have an owner', async function () {
let owner = await this.ownable.owner();
......@@ -47,4 +47,8 @@ export default function (accounts) {
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');
......
import expectThrow from '../helpers/expectThrow';
import expectEvent from '../helpers/expectEvent';
const { expectThrow } = require('../helpers/expectThrow');
const expectEvent = require('../helpers/expectEvent');
const Superuser = artifacts.require('Superuser');
......@@ -27,7 +27,7 @@ contract('Superuser', function (accounts) {
it('should change superuser after transferring', async function () {
await this.superuser.transferSuperuser(newSuperuser, { from: firstOwner });
const ownerIsSuperuser = await this.superuser.isSuperuser(firstOwner);
ownerIsSuperuser.should.be.equal(false);
......
import expectThrow from '../helpers/expectThrow';
import expectEvent from '../helpers/expectEvent';
const { expectThrow } = require('../helpers/expectThrow');
const expectEvent = require('../helpers/expectEvent');
const WhitelistMock = artifacts.require('WhitelistMock');
......
import expectThrow from '../../helpers/expectThrow';
import expectEvent from '../../helpers/expectEvent';
const { expectThrow } = require('../../helpers/expectThrow');
const expectEvent = require('../../helpers/expectEvent');
const RBACMock = artifacts.require('RBACMock');
......
import shouldBehaveLikeEscrow from './Escrow.behaviour';
import EVMRevert from '../helpers/EVMRevert';
const { shouldBehaveLikeEscrow } = require('./Escrow.behaviour');
const { EVMRevert } = require('../helpers/EVMRevert');
const BigNumber = web3.BigNumber;
......
import expectEvent from '../helpers/expectEvent';
import EVMRevert from '../helpers/EVMRevert';
import { ethGetBalance } from '../helpers/web3';
const expectEvent = require('../helpers/expectEvent');
const { EVMRevert } = require('../helpers/EVMRevert');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......@@ -8,7 +8,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
export default function (owner, [payee1, payee2]) {
function shouldBehaveLikeEscrow (owner, [payee1, payee2]) {
const amount = web3.toWei(42.0, 'ether');
describe('as an escrow', function () {
......@@ -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');
......
import { ethGetBalance } from '../helpers/web3';
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import EVMRevert from '../helpers/EVMRevert';
import expectEvent from '../helpers/expectEvent';
import { ethGetBalance } from '../helpers/web3';
const { EVMRevert } = require('../helpers/EVMRevert');
const expectEvent = require('../helpers/expectEvent');
const { ethGetBalance } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import { ethGetBalance, ethSendTransaction } from '../helpers/web3';
const { ethGetBalance, ethSendTransaction } = require('../helpers/web3');
const BigNumber = web3.BigNumber;
......
import assertRevert from '../../helpers/assertRevert';
const { assertRevert } = require('../../helpers/assertRevert');
const BasicToken = artifacts.require('BasicTokenMock');
contract('StandardToken', function ([_, owner, recipient, anotherAccount]) {
......
import assertRevert from '../../helpers/assertRevert';
import { inLogs } from '../../helpers/expectEvent';
const { assertRevert } = require('../../helpers/assertRevert');
const { inLogs } = require('../../helpers/expectEvent');
const BigNumber = web3.BigNumber;
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
......@@ -9,7 +9,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
export default function ([owner], initialBalance) {
function shouldBehaveLikeBurnableToken ([owner], initialBalance) {
describe('as a basic burnable token', function () {
const from = owner;
......@@ -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');
contract('BurnableToken', function ([owner]) {
......
import expectThrow from '../../helpers/expectThrow';
const { expectThrow } = require('../../helpers/expectThrow');
export default function ([owner, anotherAccount, minter, cap]) {
describe('capped token', function () {
function shouldBehaveLikeCappedToken ([owner, anotherAccount, minter, cap]) {
describe('capped token', function () {
const from = minter;
it('should start with the correct cap', async function () {
......@@ -25,4 +25,8 @@ export default function ([owner, anotherAccount, minter, cap]) {
await expectThrow(this.token.mint(owner, 1, { from }));
});
});
}
}
module.exports = {
shouldBehaveLikeCappedToken,
};
import ether from '../../helpers/ether';
import shouldBehaveLikeMintableToken from './MintableToken.behaviour';
import shouldBehaveLikeCappedToken from './CappedToken.behaviour';
const { ether } = require('../../helpers/ether');
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour');
var CappedToken = artifacts.require('CappedToken');
contract('Capped', function ([owner, anotherAccount]) {
const _cap = ether(1000);
beforeEach(async function () {
this.token = await CappedToken.new(_cap, { from: owner });
});
......
import assertRevert from '../../helpers/assertRevert';
const { assertRevert } = require('../../helpers/assertRevert');
const BigNumber = web3.BigNumber;
......@@ -7,7 +7,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
export default function ([owner, anotherAccount, minter]) {
function shouldBehaveLikeMintableToken ([owner, anotherAccount, minter]) {
describe('as a basic mintable token', function () {
describe('after token creation', function () {
it('sender should be token owner', async function () {
......@@ -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');
contract('MintableToken', function ([owner, anotherAccount]) {
......
import assertRevert from '../../helpers/assertRevert';
const { assertRevert } = require('../../helpers/assertRevert');
const PausableToken = artifacts.require('PausableTokenMock');
contract('PausableToken', function ([_, owner, recipient, anotherAccount]) {
......
import ether from '../../helpers/ether';
import shouldBehaveLikeRBACMintableToken from './RBACMintableToken.behaviour';
import shouldBehaveLikeMintableToken from './MintableToken.behaviour';
import shouldBehaveLikeCappedToken from './CappedToken.behaviour';
const { ether } = require('../../helpers/ether');
const { shouldBehaveLikeRBACMintableToken } = require('./RBACMintableToken.behaviour');
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour');
const RBACCappedTokenMock = artifacts.require('RBACCappedTokenMock');
......
import expectThrow from '../../helpers/expectThrow';
const { expectThrow } = require('../../helpers/expectThrow');
const ROLE_MINTER = 'minter';
export default function ([owner, anotherAccount]) {
function shouldBehaveLikeRBACMintableToken ([owner, anotherAccount]) {
describe('handle roles', function () {
it('owner can add and remove a minter role', async function () {
await this.token.addMinter(anotherAccount, { from: owner });
......@@ -24,5 +24,9 @@ export default function ([owner, anotherAccount]) {
this.token.removeMinter(anotherAccount, { from: anotherAccount })
);
});
});
});
}
module.exports = {
shouldBehaveLikeRBACMintableToken,
};
import shouldBehaveLikeRBACMintableToken from './RBACMintableToken.behaviour';
import shouldBehaveLikeMintableToken from './MintableToken.behaviour';
const { shouldBehaveLikeRBACMintableToken } = require('./RBACMintableToken.behaviour');
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const RBACMintableToken = artifacts.require('RBACMintableToken');
......
import EVMRevert from '../../helpers/EVMRevert';
const { EVMRevert } = require('../../helpers/EVMRevert');
require('chai')
.use(require('chai-as-promised'))
......
import assertRevert from '../../helpers/assertRevert';
import { inLogs } from '../../helpers/expectEvent';
import shouldBehaveLikeBurnableToken from './BurnableToken.behaviour';
const { assertRevert } = require('../../helpers/assertRevert');
const { inLogs } = require('../../helpers/expectEvent');
const { shouldBehaveLikeBurnableToken } = require('./BurnableToken.behaviour');
const StandardBurnableTokenMock = artifacts.require('StandardBurnableTokenMock');
const BigNumber = web3.BigNumber;
......@@ -13,7 +13,7 @@ require('chai')
contract('StandardBurnableToken', function ([owner, burner]) {
const initialBalance = 1000;
beforeEach(async function () {
this.token = await StandardBurnableTokenMock.new(owner, initialBalance);
});
......
import assertRevert from '../../helpers/assertRevert';
const { assertRevert } = require('../../helpers/assertRevert');
const StandardTokenMock = artifacts.require('StandardTokenMock');
contract('StandardToken', function ([_, owner, recipient, anotherAccount]) {
......
import latestTime from '../../helpers/latestTime';
import { increaseTimeTo, duration } from '../../helpers/increaseTime';
const { latestTime } = require('../../helpers/latestTime');
const { increaseTimeTo, duration } = require('../../helpers/increaseTime');
const BigNumber = web3.BigNumber;
......
import EVMRevert from '../../helpers/EVMRevert';
import latestTime from '../../helpers/latestTime';
import { increaseTimeTo, duration } from '../../helpers/increaseTime';
import { ethGetBlock } from '../../helpers/web3';
const { EVMRevert } = require('../../helpers/EVMRevert');
const { latestTime } = require('../../helpers/latestTime');
const { increaseTimeTo, duration } = require('../../helpers/increaseTime');
const { ethGetBlock } = require('../../helpers/web3');
const BigNumber = web3.BigNumber;
......
import shouldSupportInterfaces from '../../introspection/SupportsInterface.behavior';
import assertRevert from '../../helpers/assertRevert';
import decodeLogs from '../../helpers/decodeLogs';
import sendTransaction from '../../helpers/sendTransaction';
import _ from 'lodash';
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const { assertRevert } = require('../../helpers/assertRevert');
const { decodeLogs } = require('../../helpers/decodeLogs');
const { sendTransaction } = require('../../helpers/sendTransaction');
const _ = require('lodash');
const ERC721Receiver = artifacts.require('ERC721ReceiverMock.sol');
const BigNumber = web3.BigNumber;
......@@ -12,7 +12,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
export default function shouldBehaveLikeERC721BasicToken (accounts) {
function shouldBehaveLikeERC721BasicToken (accounts) {
const firstTokenId = 1;
const secondTokenId = 2;
const unknownTokenId = 3;
......@@ -558,4 +558,8 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) {
'ERC721Exists',
]);
});
}
module.exports = {
shouldBehaveLikeERC721BasicToken,
};
import shouldBehaveLikeERC721BasicToken from './ERC721BasicToken.behaviour';
import shouldMintAndBurnERC721Token from './ERC721MintBurn.behaviour';
const { shouldBehaveLikeERC721BasicToken } = require('./ERC721BasicToken.behaviour');
const { shouldBehaveLikeMintAndBurnERC721Token } = require('./ERC721MintBurn.behaviour');
const BigNumber = web3.BigNumber;
const ERC721BasicToken = artifacts.require('ERC721BasicTokenMock.sol');
......@@ -15,5 +15,5 @@ contract('ERC721BasicToken', function (accounts) {
});
shouldBehaveLikeERC721BasicToken(accounts);
shouldMintAndBurnERC721Token(accounts);
shouldBehaveLikeMintAndBurnERC721Token(accounts);
});
import assertRevert from '../../helpers/assertRevert';
const { assertRevert } = require('../../helpers/assertRevert');
const BigNumber = web3.BigNumber;
require('chai')
......@@ -6,7 +6,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
export default function shouldMintAndBurnERC721Token (accounts) {
function shouldBehaveLikeMintAndBurnERC721Token (accounts) {
const firstTokenId = 1;
const secondTokenId = 2;
const unknownTokenId = 3;
......@@ -23,7 +23,7 @@ export default function shouldMintAndBurnERC721Token (accounts) {
const to = accounts[1];
const tokenId = unknownTokenId;
let logs = null;
describe('when successful', function () {
beforeEach(async function () {
const result = await this.token.mint(to, tokenId);
......@@ -108,4 +108,8 @@ export default function shouldMintAndBurnERC721Token (accounts) {
});
});
});
}
module.exports = {
shouldBehaveLikeMintAndBurnERC721Token,
};
import assertRevert from '../../helpers/assertRevert';
import shouldBehaveLikeERC721BasicToken from './ERC721BasicToken.behaviour';
import shouldMintAndBurnERC721Token from './ERC721MintBurn.behaviour';
import shouldSupportInterfaces from '../../introspection/SupportsInterface.behavior';
import _ from 'lodash';
const { assertRevert } = require('../../helpers/assertRevert');
const { shouldBehaveLikeERC721BasicToken } = require('./ERC721BasicToken.behaviour');
const { shouldBehaveLikeMintAndBurnERC721Token } = require('./ERC721MintBurn.behaviour');
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const _ = require('lodash');
const BigNumber = web3.BigNumber;
const ERC721Token = artifacts.require('ERC721TokenMock.sol');
......@@ -24,7 +24,7 @@ contract('ERC721Token', function (accounts) {
});
shouldBehaveLikeERC721BasicToken(accounts);
shouldMintAndBurnERC721Token(accounts);
shouldBehaveLikeMintAndBurnERC721Token(accounts);
describe('like a full ERC721', function () {
beforeEach(async function () {
......
require('dotenv').config();
require('babel-register');
require('babel-polyfill');
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