Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Behaviours are no longer imported.
  • Loading branch information
nventuro committed Jul 13, 2018
commit 7e059825fb67052a077378a3fa999cabb4b6b1ae
1 change: 0 additions & 1 deletion test/Bounty.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

let sendReward = function (sender, receiver, value) {
web3.eth.sendTransaction({
from: sender,
Expand Down
1 change: 0 additions & 1 deletion test/ReentrancyGuard.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const { expectThrow } = require('./helpers/expectThrow');
const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
Expand Down
6 changes: 3 additions & 3 deletions test/access/SignatureBouncer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,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);
Expand Down
6 changes: 5 additions & 1 deletion test/crowdsale/MintedCrowdsale.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,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 () {
Expand Down Expand Up @@ -42,3 +42,7 @@ export default function ([_, investor, wallet, purchaser], rate, value) {
});
});
}

module.exports = {
shouldBehaveLikeMintedCrowdsale,
};
2 changes: 1 addition & 1 deletion test/crowdsale/MintedCrowdsale.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldBehaveLikeMintedCrowdsale from './MintedCrowdsale.behaviour';
const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behaviour');
const { ether } = require('../helpers/ether');

const BigNumber = web3.BigNumber;
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/expectEvent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const should = require('chai').should();

async function inLogs (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)) {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/makeInterfaceId.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { soliditySha3 } from 'web3-utils';
const { soliditySha3 } = require('web3-utils');

const INTERFACE_ID_LENGTH = 4;

Expand Down
8 changes: 6 additions & 2 deletions test/helpers/merkleTree.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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));
Expand Down Expand Up @@ -129,3 +129,7 @@ export default class MerkleTree {
return Buffer.concat([...args].sort(Buffer.compare));
}
}

module.exports = {
MerkleTree,
};
2 changes: 1 addition & 1 deletion test/helpers/sign.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import utils from 'ethereumjs-util';
const utils = require('ethereumjs-util');

/**
* Hash and add same prefix to the hash that ganache use.
Expand Down
6 changes: 5 additions & 1 deletion test/introspection/SupportsInterface.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -52,3 +52,7 @@ export default function (interfaces = []) {
}
});
}

module.exports = {
shouldSupportInterfaces,
};
2 changes: 1 addition & 1 deletion test/introspection/SupportsInterfaceWithLookup.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldSupportInterfaces from './SupportsInterface.behavior';
const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
const { assertRevert } = require('../helpers/assertRevert');

const SupportsInterfaceWithLookup = artifacts.require('SupportsInterfaceWithLookupMock');
Expand Down
6 changes: 1 addition & 5 deletions test/library/ECRecovery.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@

import {
hashMessage,
signMessage,
} from '../helpers/sign';
const { hashMessage, signMessage } = require('../helpers/sign');
const ECRecoveryMock = artifacts.require('ECRecoveryMock');

require('chai')
Expand Down
5 changes: 2 additions & 3 deletions test/library/MerkleProof.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

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');

Expand Down
2 changes: 0 additions & 2 deletions test/lifecycle/Destructible.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

var Destructible = artifacts.require('Destructible');
require('../helpers/transactionMined.js');

contract('Destructible', function (accounts) {
it('should send balance to owner after destruction', async function () {
Expand Down
2 changes: 0 additions & 2 deletions test/lifecycle/TokenDestructible.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

var TokenDestructible = artifacts.require('TokenDestructible');
var StandardTokenMock = artifacts.require('StandardTokenMock');
require('../helpers/transactionMined.js');

contract('TokenDestructible', function (accounts) {
let destructible;
Expand Down
1 change: 0 additions & 1 deletion test/ownership/Contactable.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

var Contactable = artifacts.require('Contactable');

contract('Contactable', function (accounts) {
Expand Down
6 changes: 5 additions & 1 deletion test/ownership/Ownable.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -47,4 +47,8 @@ export default function (accounts) {
await this.ownable.renounceOwnership({ from: other }).should.be.rejectedWith(EVMRevert);
});
});
}

module.exports = {
shouldBehaveLikeOwnable,
};
2 changes: 1 addition & 1 deletion test/ownership/Ownable.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldBehaveLikeOwnable from './Ownable.behaviour';
const { shouldBehaveLikeOwnable } = require('./Ownable.behaviour');

const Ownable = artifacts.require('Ownable');

Expand Down
2 changes: 1 addition & 1 deletion test/payment/ConditionalEscrow.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldBehaveLikeEscrow from './Escrow.behaviour';
const { shouldBehaveLikeEscrow } = require('./Escrow.behaviour');
const { EVMRevert } = require('../helpers/EVMRevert');

const BigNumber = web3.BigNumber;
Expand Down
6 changes: 5 additions & 1 deletion test/payment/Escrow.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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 () {
Expand Down Expand Up @@ -95,4 +95,8 @@ export default function (owner, [payee1, payee2]) {
});
});
});
}

module.exports = {
shouldBehaveLikeEscrow,
};
2 changes: 1 addition & 1 deletion test/payment/Escrow.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldBehaveLikeEscrow from './Escrow.behaviour';
const { shouldBehaveLikeEscrow } = require('./Escrow.behaviour');

const Escrow = artifacts.require('Escrow');

Expand Down
6 changes: 5 additions & 1 deletion test/token/ERC20/BurnableToken.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -47,4 +47,8 @@ export default function ([owner], initialBalance) {
});
});
});
}

module.exports = {
shouldBehaveLikeBurnableToken,
};
2 changes: 1 addition & 1 deletion test/token/ERC20/BurnableToken.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldBehaveLikeBurnableToken from './BurnableToken.behaviour';
const { shouldBehaveLikeBurnableToken } = require('./BurnableToken.behaviour');
const BurnableTokenMock = artifacts.require('BurnableTokenMock');

contract('BurnableToken', function ([owner]) {
Expand Down
6 changes: 5 additions & 1 deletion test/token/ERC20/CappedToken.behaviour.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { expectThrow } = require('../../helpers/expectThrow');

export default function ([owner, anotherAccount, minter, cap]) {
function shouldBehaveLikeCappedToken ([owner, anotherAccount, minter, cap]) {
describe('capped token', function () {
const from = minter;

Expand All @@ -26,3 +26,7 @@ export default function ([owner, anotherAccount, minter, cap]) {
});
});
}

module.exports = {
shouldBehaveLikeCappedToken,
};
4 changes: 2 additions & 2 deletions test/token/ERC20/CappedToken.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ether } = require('../../helpers/ether')
import shouldBehaveLikeMintableToken from './MintableToken.behaviour';
import shouldBehaveLikeCappedToken from './CappedToken.behaviour';
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour')
const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour')

var CappedToken = artifacts.require('CappedToken');

Expand Down
6 changes: 5 additions & 1 deletion test/token/ERC20/MintableToken.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -145,4 +145,8 @@ export default function ([owner, anotherAccount, minter]) {
});
});
});
}

module.exports = {
shouldBehaveLikeMintableToken,
};
2 changes: 1 addition & 1 deletion test/token/ERC20/MintableToken.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shouldBehaveLikeMintableToken from './MintableToken.behaviour';
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const MintableToken = artifacts.require('MintableToken');

contract('MintableToken', function ([owner, anotherAccount]) {
Expand Down
6 changes: 3 additions & 3 deletions test/token/ERC20/RBACCappedToken.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { ether } = require('../../helpers/ether');
import shouldBehaveLikeRBACMintableToken from './RBACMintableToken.behaviour';
import shouldBehaveLikeMintableToken from './MintableToken.behaviour';
import shouldBehaveLikeCappedToken from './CappedToken.behaviour';
const { shouldBehaveLikeRBACMintableToken } = require('./RBACMintableToken.behaviour');
const { shouldBehaveLikeMintableToken } = require('./MintableToken.behaviour');
const { shouldBehaveLikeCappedToken } = require('./CappedToken.behaviour');

const RBACCappedTokenMock = artifacts.require('RBACCappedTokenMock');

Expand Down
6 changes: 5 additions & 1 deletion test/token/ERC20/RBACMintableToken.behaviour.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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 });
Expand All @@ -25,4 +25,8 @@ export default function ([owner, anotherAccount]) {
);
});
});
}

module.exports = {
shouldBehaveLikeRBACMintableToken,
};
4 changes: 2 additions & 2 deletions test/token/ERC20/RBACMintableToken.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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');

Expand Down
2 changes: 1 addition & 1 deletion test/token/ERC20/SafeERC20.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EVMRevert from '../../helpers/EVMRevert';
const { EVMRevert } = require('../../helpers/EVMRevert');

require('chai')
.use(require('chai-as-promised'))
Expand Down
2 changes: 1 addition & 1 deletion test/token/ERC20/StandardBurnableToken.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { assertRevert } = require('../../helpers/assertRevert');
const { inLogs } = require('../../helpers/expectEvent');
import shouldBehaveLikeBurnableToken from './BurnableToken.behaviour';
const { shouldBehaveLikeBurnableToken } = require('./BurnableToken.behaviour');

const StandardBurnableTokenMock = artifacts.require('StandardBurnableTokenMock');
const BigNumber = web3.BigNumber;
Expand Down
2 changes: 1 addition & 1 deletion test/token/ERC20/TokenVesting.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EVMRevert from '../../helpers/EVMRevert';
const { EVMRevert } = require('../../helpers/EVMRevert');
const { latestTime } = require('../../helpers/latestTime');
const { increaseTimeTo, duration } = require('../../helpers/increaseTime');

Expand Down
10 changes: 7 additions & 3 deletions test/token/ERC721/ERC721BasicToken.behaviour.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import shouldSupportInterfaces from '../../introspection/SupportsInterface.behavior';
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const { assertRevert } = require('../../helpers/assertRevert');
const { decodeLogs } = require('../../helpers/decodeLogs');
const { sendTransaction } = require('../../helpers/sendTransaction');
import _ from 'lodash';
const _ = require('lodash');

const ERC721Receiver = artifacts.require('ERC721ReceiverMock.sol');
const BigNumber = web3.BigNumber;
Expand All @@ -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;
Expand Down Expand Up @@ -558,4 +558,8 @@ export default function shouldBehaveLikeERC721BasicToken (accounts) {
'ERC721Exists',
]);
});
}

module.exports = {
shouldBehaveLikeERC721BasicToken,
};
6 changes: 3 additions & 3 deletions test/token/ERC721/ERC721BasicToken.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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');
Expand All @@ -15,5 +15,5 @@ contract('ERC721BasicToken', function (accounts) {
});

shouldBehaveLikeERC721BasicToken(accounts);
shouldMintAndBurnERC721Token(accounts);
shouldBehaveLikeMintAndBurnERC721Token(accounts);
});
Loading