Skip to content

Commit bdfe054

Browse files
authored
Merge branch 'master' into less-helpers
2 parents 1d419b3 + 58a4244 commit bdfe054

24 files changed

+50
-38
lines changed

contracts/bounties/BreakInvariantBounty.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ import "../ownership/Ownable.sol";
88
* @dev This bounty will pay out to a researcher if they break invariant logic of the contract.
99
*/
1010
contract BreakInvariantBounty is PullPayment, Ownable {
11-
bool private _claimable = true;
11+
bool private _claimable;
1212
mapping(address => address) private _researchers;
1313

1414
event TargetCreated(address createdAddress);
1515
event BountyCanceled();
1616

17+
constructor() public {
18+
_claimable = true;
19+
}
20+
1721
/**
1822
* @dev Fallback function allowing the contract to receive funds, if they haven't already been claimed.
1923
*/

contracts/ownership/Ownable.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ pragma solidity ^0.4.24;
88
contract Ownable {
99
address private _owner;
1010

11-
event OwnershipRenounced(address indexed previousOwner);
1211
event OwnershipTransferred(
1312
address indexed previousOwner,
1413
address indexed newOwner
@@ -20,6 +19,7 @@ contract Ownable {
2019
*/
2120
constructor() public {
2221
_owner = msg.sender;
22+
emit OwnershipTransferred(address(0), _owner);
2323
}
2424

2525
/**
@@ -51,7 +51,7 @@ contract Ownable {
5151
* modifier anymore.
5252
*/
5353
function renounceOwnership() public onlyOwner {
54-
emit OwnershipRenounced(_owner);
54+
emit OwnershipTransferred(_owner, address(0));
5555
_owner = address(0);
5656
}
5757

test/access/Roles.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
const shouldFail = require('../helpers/shouldFail');
2+
const { ZERO_ADDRESS } = require('../helpers/constants');
23

34
const RolesMock = artifacts.require('RolesMock');
45

56
require('chai')
67
.should();
78

89
contract('Roles', function ([_, authorized, otherAuthorized, anyone]) {
9-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
10-
1110
beforeEach(async function () {
1211
this.roles = await RolesMock.new();
1312
});

test/access/roles/PublicRole.behavior.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const shouldFail = require('../../helpers/shouldFail');
2+
const { ZERO_ADDRESS } = require('../../helpers/constants');
23
const expectEvent = require('../../helpers/expectEvent');
34

45
require('chai')
@@ -10,7 +11,6 @@ function capitalize (str) {
1011

1112
function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], rolename) {
1213
rolename = capitalize(rolename);
13-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1414

1515
describe('should behave like public role', function () {
1616
beforeEach('check preconditions', async function () {

test/crowdsale/AllowanceCrowdsale.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const expectEvent = require('../helpers/expectEvent');
22
const { ether } = require('../helpers/ether');
33
const shouldFail = require('../helpers/shouldFail');
44
const { ethGetBalance } = require('../helpers/web3');
5+
const { ZERO_ADDRESS } = require('../helpers/constants');
56

67
const BigNumber = web3.BigNumber;
78

@@ -17,7 +18,6 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW
1718
const value = ether(0.42);
1819
const expectedTokenAmount = rate.mul(value);
1920
const tokenAllowance = new BigNumber('1e22');
20-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
2121

2222
beforeEach(async function () {
2323
this.token = await SimpleToken.new({ from: tokenWallet });

test/crowdsale/Crowdsale.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const expectEvent = require('../helpers/expectEvent');
22
const shouldFail = require('../helpers/shouldFail');
33
const { ether } = require('../helpers/ether');
44
const { ethGetBalance } = require('../helpers/web3');
5+
const { ZERO_ADDRESS } = require('../helpers/constants');
56

67
const BigNumber = web3.BigNumber;
78

@@ -17,7 +18,6 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
1718
const value = ether(42);
1819
const tokenSupply = new BigNumber('1e22');
1920
const expectedTokenAmount = rate.mul(value);
20-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
2121

2222
it('requires a non-null token', async function () {
2323
await shouldFail.reverting(

test/drafts/ERC20Migrator.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const shouldFail = require('../helpers/shouldFail');
2+
const { ZERO_ADDRESS } = require('../helpers/constants');
23

34
const ERC20Mock = artifacts.require('ERC20Mock');
45
const ERC20Mintable = artifacts.require('ERC20Mintable');
@@ -11,8 +12,6 @@ require('chai')
1112
.should();
1213

1314
contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
14-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
15-
1615
const totalSupply = 200;
1716

1817
it('reverts with a null legacy token address', async function () {

test/examples/SimpleToken.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { decodeLogs } = require('../helpers/decodeLogs');
2+
const { ZERO_ADDRESS } = require('../helpers/constants');
23
const SimpleToken = artifacts.require('SimpleToken');
34

45
const BigNumber = web3.BigNumber;
@@ -8,8 +9,6 @@ require('chai')
89
.should();
910

1011
contract('SimpleToken', function ([_, creator]) {
11-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
12-
1312
beforeEach(async function () {
1413
this.token = await SimpleToken.new({ from: creator });
1514
});

test/helpers/constants.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const BigNumber = web3.BigNumber;
2+
3+
module.exports = {
4+
ZERO_ADDRESS: '0x0000000000000000000000000000000000000000',
5+
MAX_UINT256: new BigNumber(2).pow(256).minus(1),
6+
};

test/math/SafeMath.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const shouldFail = require('../helpers/shouldFail');
2+
const { MAX_UINT256 } = require('../helpers/constants');
23

34
const BigNumber = web3.BigNumber;
45
const SafeMathMock = artifacts.require('SafeMathMock');
@@ -8,8 +9,6 @@ require('chai')
89
.should();
910

1011
contract('SafeMath', function () {
11-
const MAX_UINT = new BigNumber(2).pow(256).minus(1);
12-
1312
beforeEach(async function () {
1413
this.safeMath = await SafeMathMock.new();
1514
});
@@ -23,7 +22,7 @@ contract('SafeMath', function () {
2322
});
2423

2524
it('throws a revert error on addition overflow', async function () {
26-
const a = MAX_UINT;
25+
const a = MAX_UINT256;
2726
const b = new BigNumber(1);
2827

2928
await shouldFail.reverting(this.safeMath.add(a, b));
@@ -62,7 +61,7 @@ contract('SafeMath', function () {
6261
});
6362

6463
it('throws a revert error on multiplication overflow', async function () {
65-
const a = MAX_UINT;
64+
const a = MAX_UINT256;
6665
const b = new BigNumber(2);
6766

6867
await shouldFail.reverting(this.safeMath.mul(a, b));

test/ownership/Ownable.behavior.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const shouldFail = require('../helpers/shouldFail');
2-
3-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
2+
const expectEvent = require('../helpers/expectEvent');
3+
const { ZERO_ADDRESS } = require('../helpers/constants');
44

55
require('chai')
66
.should();
@@ -13,7 +13,8 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {
1313

1414
it('changes owner after transfer', async function () {
1515
(await this.ownable.isOwner({ from: anyone })).should.be.equal(false);
16-
await this.ownable.transferOwnership(anyone, { from: owner });
16+
const { logs } = await this.ownable.transferOwnership(anyone, { from: owner });
17+
expectEvent.inLogs(logs, 'OwnershipTransferred');
1718

1819
(await this.ownable.owner()).should.equal(anyone);
1920
(await this.ownable.isOwner({ from: anyone })).should.be.equal(true);
@@ -28,7 +29,9 @@ function shouldBehaveLikeOwnable (owner, [anyone]) {
2829
});
2930

3031
it('loses owner after renouncement', async function () {
31-
await this.ownable.renounceOwnership({ from: owner });
32+
const { logs } = await this.ownable.renounceOwnership({ from: owner });
33+
expectEvent.inLogs(logs, 'OwnershipTransferred');
34+
3235
(await this.ownable.owner()).should.equal(ZERO_ADDRESS);
3336
});
3437

test/ownership/Secondary.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
const shouldFail = require('../helpers/shouldFail');
2+
const { ZERO_ADDRESS } = require('../helpers/constants');
23

34
const SecondaryMock = artifacts.require('SecondaryMock');
45

56
require('chai')
67
.should();
78

89
contract('Secondary', function ([_, primary, newPrimary, anyone]) {
9-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
10-
1110
beforeEach(async function () {
1211
this.secondary = await SecondaryMock.new({ from: primary });
1312
});

test/payment/ConditionalEscrow.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
2+
23
const shouldFail = require('../helpers/shouldFail');
4+
const { ether } = require('../helpers/ether');
35

46
const BigNumber = web3.BigNumber;
57

@@ -23,7 +25,7 @@ contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) {
2325
});
2426

2527
context('when withdrawal is disallowed', function () {
26-
const amount = web3.toWei(23.0, 'ether');
28+
const amount = ether(23.0);
2729

2830
beforeEach(async function () {
2931
await this.escrow.setAllowed(payee, false);

test/payment/Escrow.behavior.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const expectEvent = require('../helpers/expectEvent');
22
const shouldFail = require('../helpers/shouldFail');
33
const { ethGetBalance } = require('../helpers/web3');
4+
const { ether } = require('../helpers/ether');
45

56
const BigNumber = web3.BigNumber;
67

@@ -9,7 +10,7 @@ require('chai')
910
.should();
1011

1112
function shouldBehaveLikeEscrow (primary, [payee1, payee2]) {
12-
const amount = web3.toWei(42.0, 'ether');
13+
const amount = ether(42.0);
1314

1415
describe('as an escrow', function () {
1516
describe('deposits', function () {

test/payment/PullPayment.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const { ethGetBalance } = require('../helpers/web3');
2+
const { ether } = require('../helpers/ether');
23

34
const BigNumber = web3.BigNumber;
45

@@ -9,7 +10,7 @@ require('chai')
910
const PullPaymentMock = artifacts.require('PullPaymentMock');
1011

1112
contract('PullPayment', function ([_, payer, payee1, payee2]) {
12-
const amount = web3.toWei(17.0, 'ether');
13+
const amount = ether(17.0);
1314

1415
beforeEach(async function () {
1516
this.contract = await PullPaymentMock.new({ value: amount });

test/payment/RefundEscrow.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const shouldFail = require('../helpers/shouldFail');
22
const expectEvent = require('../helpers/expectEvent');
33
const { ethGetBalance } = require('../helpers/web3');
4+
const { ether } = require('../helpers/ether');
5+
const { ZERO_ADDRESS } = require('../helpers/constants');
46

57
const BigNumber = web3.BigNumber;
68

@@ -11,9 +13,8 @@ require('chai')
1113
const RefundEscrow = artifacts.require('RefundEscrow');
1214

1315
contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) {
14-
const amount = web3.toWei(54.0, 'ether');
16+
const amount = ether(54.0);
1517
const refundees = [refundee1, refundee2];
16-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1718

1819
it('requires a non-null beneficiary', async function () {
1920
await shouldFail.reverting(

test/payment/SplitPayment.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const { ethGetBalance } = require('../helpers/web3');
22
const { sendEther } = require('./../helpers/sendTransaction');
3+
const { ether } = require('../helpers/ether');
4+
const { ZERO_ADDRESS } = require('./../helpers/constants');
35

46
const BigNumber = web3.BigNumber;
57

@@ -11,8 +13,7 @@ const shouldFail = require('../helpers/shouldFail');
1113
const SplitPayment = artifacts.require('SplitPayment');
1214

1315
contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) {
14-
const amount = web3.toWei(1.0, 'ether');
15-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
16+
const amount = ether(1.0);
1617

1718
it('rejects an empty set of payees', async function () {
1819
await shouldFail.reverting(SplitPayment.new([], []));

test/token/ERC20/ERC20.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const shouldFail = require('../../helpers/shouldFail');
22
const expectEvent = require('../../helpers/expectEvent');
3+
const { ZERO_ADDRESS } = require('../../helpers/constants');
34

45
const ERC20Mock = artifacts.require('ERC20Mock');
56

@@ -10,8 +11,6 @@ require('chai')
1011
.should();
1112

1213
contract('ERC20', function ([_, owner, recipient, anotherAccount]) {
13-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
14-
1514
beforeEach(async function () {
1615
this.token = await ERC20Mock.new(owner, 100);
1716
});

test/token/ERC20/TokenVesting.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const shouldFail = require('../../helpers/shouldFail');
22
const time = require('../../helpers/time');
33
const { ethGetBlock } = require('../../helpers/web3');
4+
const { ZERO_ADDRESS } = require('../../helpers/constants');
45

56
const BigNumber = web3.BigNumber;
67

@@ -13,7 +14,6 @@ const TokenVesting = artifacts.require('TokenVesting');
1314

1415
contract('TokenVesting', function ([_, owner, beneficiary]) {
1516
const amount = new BigNumber(1000);
16-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1717

1818
beforeEach(async function () {
1919
// +1 minute so it starts after contract instantiation

test/token/ERC20/behaviors/ERC20Burnable.behavior.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const shouldFail = require('../../../helpers/shouldFail');
22
const expectEvent = require('../../../helpers/expectEvent');
3+
const { ZERO_ADDRESS } = require('../../../helpers/constants');
34

45
const BigNumber = web3.BigNumber;
5-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
66

77
require('chai')
88
.use(require('chai-bignumber')(BigNumber))

test/token/ERC20/behaviors/ERC20Mintable.behavior.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const shouldFail = require('../../../helpers/shouldFail');
22
const expectEvent = require('../../../helpers/expectEvent');
3+
const { ZERO_ADDRESS } = require('../../../helpers/constants');
34

45
const BigNumber = web3.BigNumber;
56

@@ -8,8 +9,6 @@ require('chai')
89
.should();
910

1011
function shouldBehaveLikeERC20Mintable (minter, [anyone]) {
11-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
12-
1312
describe('as a mintable token', function () {
1413
describe('mint', function () {
1514
const amount = 100;

test/token/ERC721/ERC721.behavior.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const expectEvent = require('../../helpers/expectEvent');
22
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
33
const shouldFail = require('../../helpers/shouldFail');
4+
const { ZERO_ADDRESS } = require('../../helpers/constants');
45
const { decodeLogs } = require('../../helpers/decodeLogs');
56
const { sendTransaction } = require('../../helpers/sendTransaction');
67

@@ -19,7 +20,6 @@ function shouldBehaveLikeERC721 (
1920
const firstTokenId = 1;
2021
const secondTokenId = 2;
2122
const unknownTokenId = 3;
22-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
2323
const RECEIVER_MAGIC_VALUE = '0x150b7a02';
2424

2525
describe('like an ERC721', function () {

test/token/ERC721/ERC721MintBurn.behavior.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const shouldFail = require('../../helpers/shouldFail');
22
const expectEvent = require('../../helpers/expectEvent');
3+
const { ZERO_ADDRESS } = require('../../helpers/constants');
34
const BigNumber = web3.BigNumber;
45

56
require('chai')
@@ -15,7 +16,6 @@ function shouldBehaveLikeMintAndBurnERC721 (
1516
const secondTokenId = 2;
1617
const thirdTokenId = 3;
1718
const unknownTokenId = 4;
18-
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
1919
const MOCK_URI = 'https://example.com';
2020

2121
describe('like a mintable and burnable ERC721', function () {

0 commit comments

Comments
 (0)