Merge remote-tracking branch 'upstream/master' into add-smart-token

This commit is contained in:
AugustoL
2018-01-17 11:01:05 -03:00
103 changed files with 1714 additions and 516 deletions

View File

@ -74,7 +74,7 @@ contract('Bounty', function (accounts) {
web3.eth.getBalance(bounty.address).toNumber());
}
};
bounty.createTarget({ from: researcher });
await bounty.createTarget({ from: researcher });
await awaitEvent(event, watcher);
});
});
@ -104,7 +104,7 @@ contract('Bounty', function (accounts) {
assert.equal(0, web3.eth.getBalance(bounty.address).toNumber());
};
bounty.createTarget({ from: researcher });
await bounty.createTarget({ from: researcher });
await awaitEvent(event, watcher);
});
});

25
test/Math.test.js Normal file
View File

@ -0,0 +1,25 @@
var MathMock = artifacts.require('./mocks/MathMock.sol');
contract('Math', function (accounts) {
let math;
before(async function () {
math = await MathMock.new();
});
it('returns max correctly', async function () {
let a = 5678;
let b = 1234;
await math.max64(a, b);
let result = await math.result();
assert.equal(result, a);
});
it('returns min correctly', async function () {
let a = 5678;
let b = 1234;
await math.min64(a, b);
let result = await math.result();
assert.equal(result, b);
});
});

View File

@ -1,8 +1,8 @@
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 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 BigNumber = web3.BigNumber;

View File

@ -1,8 +1,8 @@
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 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 BigNumber = web3.BigNumber;

View File

@ -1,7 +1,7 @@
import { advanceBlock } from './helpers/advanceToBlock';
import { increaseTimeTo, duration } from './helpers/increaseTime';
import latestTime from './helpers/latestTime';
import EVMRevert from './helpers/EVMRevert';
import { advanceBlock } from '../helpers/advanceToBlock';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import EVMRevert from '../helpers/EVMRevert';
const BigNumber = web3.BigNumber;

View File

@ -1,5 +1,5 @@
import ether from './helpers/ether';
import EVMRevert from './helpers/EVMRevert';
import ether from '../helpers/ether';
import EVMRevert from '../helpers/EVMRevert';
const BigNumber = web3.BigNumber;

View File

@ -1,8 +1,8 @@
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 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 BigNumber = web3.BigNumber;

View File

@ -1,8 +1,8 @@
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 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 BigNumber = web3.BigNumber;

View File

@ -1,6 +1,6 @@
var Destructible = artifacts.require('../contracts/lifecycle/Destructible.sol');
require('./helpers/transactionMined.js');
require('../helpers/transactionMined.js');
contract('Destructible', function (accounts) {
it('should send balance to owner after destruction', async function () {

View File

@ -1,5 +1,5 @@
import assertRevert from './helpers/assertRevert';
import assertRevert from '../helpers/assertRevert';
const PausableMock = artifacts.require('mocks/PausableMock.sol');
contract('Pausable', function (accounts) {

View File

@ -1,7 +1,7 @@
var TokenDestructible = artifacts.require('../contracts/lifecycle/TokenDestructible.sol');
var StandardTokenMock = artifacts.require('mocks/StandardTokenMock.sol');
require('./helpers/transactionMined.js');
require('../helpers/transactionMined.js');
contract('TokenDestructible', function (accounts) {
let destructible;

View File

@ -1,5 +1,5 @@
import assertRevert from './helpers/assertRevert';
const assertJump = require('./helpers/assertJump');
import assertRevert from '../helpers/assertRevert';
const assertJump = require('../helpers/assertJump');
var SafeMathMock = artifacts.require('mocks/SafeMathMock.sol');
contract('SafeMath', function (accounts) {

17
test/mocks/MathMock.sol Normal file
View File

@ -0,0 +1,17 @@
pragma solidity ^0.4.18;
import "../../contracts/math/Math.sol";
contract MathMock {
uint64 public result;
function max64(uint64 a, uint64 b) public {
result = Math.max64(a, b);
}
function min64(uint64 a, uint64 b) public {
result = Math.min64(a, b);
}
}

View File

@ -1,5 +1,5 @@
import expectThrow from './helpers/expectThrow';
import expectThrow from '../helpers/expectThrow';
const CanReclaimToken = artifacts.require('../contracts/ownership/CanReclaimToken.sol');
const BasicTokenMock = artifacts.require('mocks/BasicTokenMock.sol');

View File

@ -1,5 +1,5 @@
import assertRevert from './helpers/assertRevert';
import assertRevert from '../helpers/assertRevert';
var Claimable = artifacts.require('../contracts/ownership/Claimable.sol');

View File

@ -1,3 +1,4 @@
import assertRevert from '../helpers/assertRevert';
var DelayedClaimable = artifacts.require('../contracts/ownership/DelayedClaimable.sol');
@ -42,25 +43,13 @@ contract('DelayedClaimable', function (accounts) {
assert.equal(start, 100);
let pendingOwner = await delayedClaimable.pendingOwner();
assert.equal(pendingOwner, accounts[1]);
var err = null;
try {
await delayedClaimable.claimOwnership({ from: accounts[1] });
} catch (error) {
err = error;
}
assert.isFalse(err.message.search('revert') === -1);
await assertRevert(delayedClaimable.claimOwnership({ from: accounts[1] }));
let owner = await delayedClaimable.owner();
assert.isTrue(owner !== accounts[1]);
});
it('set end and start invalid values fail', async function () {
await delayedClaimable.transferOwnership(accounts[1]);
var err = null;
try {
await delayedClaimable.setLimits(1001, 1000);
} catch (error) {
err = error;
}
assert.isFalse(err.message.search('revert') === -1);
await assertRevert(delayedClaimable.setLimits(1001, 1000));
});
});

View File

@ -1,5 +1,5 @@
import expectThrow from './helpers/expectThrow';
import expectThrow from '../helpers/expectThrow';
const Ownable = artifacts.require('../contracts/ownership/Ownable.sol');
const HasNoContracts = artifacts.require(

View File

@ -1,6 +1,6 @@
import expectThrow from './helpers/expectThrow';
import toPromise from './helpers/toPromise';
import expectThrow from '../helpers/expectThrow';
import toPromise from '../helpers/toPromise';
const HasNoEtherTest = artifacts.require('../mocks/HasNoEtherTest.sol');
const ForceEther = artifacts.require('../mocks/ForceEther.sol');

View File

@ -1,5 +1,5 @@
import expectThrow from './helpers/expectThrow';
import expectThrow from '../helpers/expectThrow';
const HasNoTokens = artifacts.require('../contracts/lifecycle/HasNoTokens.sol');
const ERC23TokenMock = artifacts.require('mocks/ERC23TokenMock.sol');

View File

@ -1,5 +1,5 @@
import assertRevert from './helpers/assertRevert';
import assertRevert from '../helpers/assertRevert';
var Ownable = artifacts.require('../contracts/ownership/Ownable.sol');

View File

@ -1,5 +1,5 @@
import expectThrow from './helpers/expectThrow';
import expectEvent from './helpers/expectEvent';
import expectThrow from '../../helpers/expectThrow';
import expectEvent from '../../helpers/expectEvent';
const RBACMock = artifacts.require('mocks/RBACMock.sol');
@ -45,17 +45,17 @@ contract('RBAC', function (accounts) {
.should.be.fulfilled;
});
it('does not allow admins to call #nobodyCanDoThis', async () => {
expectThrow(
await expectThrow(
mock.nobodyCanDoThis({ from: admin })
);
});
it('does not allow advisors to call #nobodyCanDoThis', async () => {
expectThrow(
await expectThrow(
mock.nobodyCanDoThis({ from: advisors[0] })
);
});
it('does not allow anyone to call #nobodyCanDoThis', async () => {
expectThrow(
await expectThrow(
mock.nobodyCanDoThis({ from: anyone })
);
});
@ -69,14 +69,14 @@ contract('RBAC', function (accounts) {
});
it('announces a RoleAdded event on addRole', async () => {
expectEvent.inTransaction(
await expectEvent.inTransaction(
mock.adminAddRole(futureAdvisor, ROLE_ADVISOR, { from: admin }),
'RoleAdded'
);
});
it('announces a RoleRemoved event on removeRole', async () => {
expectEvent.inTransaction(
await expectEvent.inTransaction(
mock.adminRemoveRole(futureAdvisor, ROLE_ADVISOR, { from: admin }),
'RoleRemoved'
);
@ -85,12 +85,12 @@ contract('RBAC', function (accounts) {
context('in adversarial conditions', () => {
it('does not allow an advisor to remove another advisor', async () => {
expectThrow(
await expectThrow(
mock.removeAdvisor(advisors[1], { from: advisors[0] })
);
});
it('does not allow "anyone" to remove an advisor', async () => {
expectThrow(
await expectThrow(
mock.removeAdvisor(advisors[0], { from: anyone })
);
});

View File

@ -5,7 +5,7 @@ require('chai')
.use(require('chai-bignumber')(BigNumber))
.should();
const EVMThrow = require('./helpers/EVMThrow.js');
const EVMThrow = require('../helpers/EVMThrow.js');
const SplitPayment = artifacts.require('../contracts/payment/SplitPayment.sol');
contract('SplitPayment', function ([owner, payee1, payee2, payee3, nonpayee1, payer1]) {

View File

@ -1,4 +1,4 @@
import assertRevert from './helpers/assertRevert';
import assertRevert from '../helpers/assertRevert';
var BasicTokenMock = artifacts.require('mocks/BasicTokenMock.sol');

View File

@ -1,5 +1,5 @@
const EVMRevert = require('./helpers/EVMRevert.js');
const EVMRevert = require('../helpers/EVMRevert.js');
const BurnableTokenMock = artifacts.require('mocks/BurnableTokenMock.sol');
const BigNumber = web3.BigNumber;

View File

@ -1,6 +1,6 @@
import expectThrow from './helpers/expectThrow';
import ether from './helpers/ether';
import expectThrow from '../helpers/expectThrow';
import ether from '../helpers/ether';
var CappedToken = artifacts.require('../contracts/Tokens/CappedToken.sol');

View File

@ -1,5 +1,5 @@
import expectThrow from './helpers/expectThrow';
import expectThrow from '../helpers/expectThrow';
var MintableToken = artifacts.require('../contracts/Tokens/MintableToken.sol');
contract('Mintable', function (accounts) {

View File

@ -1,6 +1,6 @@
'user strict';
import assertRevert from './helpers/assertRevert';
import assertRevert from '../helpers/assertRevert';
var PausableTokenMock = artifacts.require('./mocks/PausableTokenMock.sol');
contract('PausableToken', function (accounts) {

View File

@ -1,4 +1,4 @@
import EVMThrow from './helpers/EVMThrow';
import EVMThrow from '../helpers/EVMThrow';
require('chai')
.use(require('chai-as-promised'))

View File

@ -1,5 +1,5 @@
import assertRevert from './helpers/assertRevert';
import assertRevert from '../helpers/assertRevert';
var StandardTokenMock = artifacts.require('mocks/StandardTokenMock.sol');

View File

@ -1,5 +1,5 @@
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
import latestTime from '../helpers/latestTime';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
const BigNumber = web3.BigNumber;

View File

@ -1,6 +1,6 @@
import EVMRevert from './helpers/EVMRevert';
import latestTime from './helpers/latestTime';
import { increaseTimeTo, duration } from './helpers/increaseTime';
import EVMRevert from '../helpers/EVMRevert';
import latestTime from '../helpers/latestTime';
import { increaseTimeTo, duration } from '../helpers/increaseTime';
const BigNumber = web3.BigNumber;