From 97be1da46ccf7d9b83ee1010f5a930a6610d60ea Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 3 Sep 2018 03:11:24 +0000 Subject: [PATCH 01/13] Improve encapsulation on Pausable --- contracts/lifecycle/Pausable.sol | 9 ++++++++- test/token/ERC20/ERC20Pausable.test.js | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index 0a2767aa61f..03dff6692ee 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -12,9 +12,16 @@ contract Pausable is Ownable { event Paused(); event Unpaused(); - bool public paused = false; + bool private paused = false; + /** + * @return true if the contract is paused, false otherwise. + */ + function isPaused() public view returns(bool) { + return paused; + } + /** * @dev Modifier to make a function callable only when the contract is not paused. */ diff --git a/test/token/ERC20/ERC20Pausable.test.js b/test/token/ERC20/ERC20Pausable.test.js index 8fbe4f70876..b11ecb3e7b6 100644 --- a/test/token/ERC20/ERC20Pausable.test.js +++ b/test/token/ERC20/ERC20Pausable.test.js @@ -13,7 +13,7 @@ contract('ERC20Pausable', function ([_, owner, recipient, anotherAccount]) { describe('when the token is unpaused', function () { it('pauses the token', async function () { await this.token.pause({ from }); - (await this.token.paused()).should.equal(true); + (await this.token.isPaused()).should.equal(true); }); it('emits a Pause event', async function () { @@ -55,7 +55,7 @@ contract('ERC20Pausable', function ([_, owner, recipient, anotherAccount]) { it('unpauses the token', async function () { await this.token.unpause({ from }); - (await this.token.paused()).should.equal(false); + (await this.token.isPaused()).should.equal(false); }); it('emits an Unpause event', async function () { @@ -87,18 +87,18 @@ contract('ERC20Pausable', function ([_, owner, recipient, anotherAccount]) { describe('paused', function () { it('is not paused by default', async function () { - (await this.token.paused({ from })).should.equal(false); + (await this.token.isPaused({ from })).should.equal(false); }); it('is paused after being paused', async function () { await this.token.pause({ from }); - (await this.token.paused({ from })).should.equal(true); + (await this.token.isPaused({ from })).should.equal(true); }); it('is not paused after being paused and then unpaused', async function () { await this.token.pause({ from }); await this.token.unpause({ from }); - (await this.token.paused()).should.equal(false); + (await this.token.isPaused()).should.equal(false); }); }); From 3a2c242b150589f36aeae0b9dde619ffa39dee50 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 3 Sep 2018 03:13:48 +0000 Subject: [PATCH 02/13] add the underscore --- contracts/lifecycle/Pausable.sol | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index 03dff6692ee..3e5676f7f87 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -12,21 +12,21 @@ contract Pausable is Ownable { event Paused(); event Unpaused(); - bool private paused = false; + bool private paused_ = false; /** * @return true if the contract is paused, false otherwise. */ function isPaused() public view returns(bool) { - return paused; + return paused_; } /** * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { - require(!paused); + require(!paused_); _; } @@ -34,7 +34,7 @@ contract Pausable is Ownable { * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { - require(paused); + require(paused_); _; } @@ -42,7 +42,7 @@ contract Pausable is Ownable { * @dev called by the owner to pause, triggers stopped state */ function pause() public onlyOwner whenNotPaused { - paused = true; + paused_ = true; emit Paused(); } @@ -50,7 +50,7 @@ contract Pausable is Ownable { * @dev called by the owner to unpause, returns to normal state */ function unpause() public onlyOwner whenPaused { - paused = false; + paused_ = false; emit Unpaused(); } } From 641699116ce84be2de9bb72905db58b0126c6de9 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 3 Sep 2018 03:44:22 +0000 Subject: [PATCH 03/13] Improve encapsulation on ownership --- contracts/ownership/Claimable.sol | 19 +++++++++---- contracts/ownership/DelayedClaimable.sol | 32 +++++++++++++++------- contracts/ownership/Heritable.sol | 13 ++++----- contracts/ownership/Ownable.sol | 19 +++++++++---- contracts/ownership/Superuser.sol | 2 +- contracts/token/ERC20/ERC20Mintable.sol | 2 +- contracts/token/ERC20/TokenVesting.sol | 2 +- test/access/SignatureBouncer.test.js | 2 +- test/crowdsale/MintedCrowdsale.test.js | 2 +- test/ownership/Claimable.test.js | 6 ++-- test/ownership/DelayedClaimable.test.js | 20 +++++++------- test/ownership/Ownable.behavior.js | 6 ++-- test/ownership/Superuser.test.js | 4 +-- test/token/ERC20/ERC20Mintable.behavior.js | 2 +- 14 files changed, 78 insertions(+), 53 deletions(-) diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index 9027c11f52d..6576632af12 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -10,30 +10,37 @@ import "./Ownable.sol"; * This allows the new owner to accept the transfer. */ contract Claimable is Ownable { - address public pendingOwner; + address private pendingOwner_; /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { - require(msg.sender == pendingOwner); + require(msg.sender == pendingOwner_); _; } + /** + * @return the address of the pending owner. + */ + function getPendingOwner() public view returns(address) { + return pendingOwner_; + } + /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { - pendingOwner = newOwner; + pendingOwner_ = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { - emit OwnershipTransferred(owner, pendingOwner); - owner = pendingOwner; - pendingOwner = address(0); + emit OwnershipTransferred(getOwner(), pendingOwner_); + owner = pendingOwner_; + pendingOwner_ = address(0); } } diff --git a/contracts/ownership/DelayedClaimable.sol b/contracts/ownership/DelayedClaimable.sol index a9c0857f8e9..b965856490a 100644 --- a/contracts/ownership/DelayedClaimable.sol +++ b/contracts/ownership/DelayedClaimable.sol @@ -10,8 +10,22 @@ import "./Claimable.sol"; */ contract DelayedClaimable is Claimable { - uint256 public end; - uint256 public start; + uint256 private start_; + uint256 private end_; + + /** + * @return the start of the claimable period. + */ + function getStart() public view returns(uint256) { + return start_; + } + + /** + * @return the end of the claimable period. + */ + function getEnd() public view returns(uint256) { + return end_; + } /** * @dev Used to specify the time period during which a pending @@ -21,20 +35,18 @@ contract DelayedClaimable is Claimable { */ function setLimits(uint256 _start, uint256 _end) public onlyOwner { require(_start <= _end); - end = _end; - start = _start; + end_ = _end; + start_ = _start; } /** - * @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within + * @dev Allows the pending owner address to finalize the transfer, as long as it is called within * the specified start and end time. */ function claimOwnership() public onlyPendingOwner { - require((block.number <= end) && (block.number >= start)); - emit OwnershipTransferred(owner, pendingOwner); - owner = pendingOwner; - pendingOwner = address(0); - end = 0; + require((block.number <= end_) && (block.number >= start_)); + super.claimOwnership(); + end_ = 0; } } diff --git a/contracts/ownership/Heritable.sol b/contracts/ownership/Heritable.sol index 88e6fee62f4..9e3214c071f 100644 --- a/contracts/ownership/Heritable.sol +++ b/contracts/ownership/Heritable.sol @@ -51,9 +51,9 @@ contract Heritable is Ownable { } function setHeir(address _newHeir) public onlyOwner { - require(_newHeir != owner); + require(_newHeir != getOwner()); heartbeat(); - emit HeirChanged(owner, _newHeir); + emit HeirChanged(getOwner(), _newHeir); heir_ = _newHeir; } @@ -87,7 +87,7 @@ contract Heritable is Ownable { */ function proclaimDeath() public onlyHeir { require(_ownerLives()); - emit OwnerProclaimedDead(owner, heir_, timeOfDeath_); + emit OwnerProclaimedDead(getOwner(), heir_, timeOfDeath_); // solium-disable-next-line security/no-block-members timeOfDeath_ = block.timestamp; } @@ -96,7 +96,7 @@ contract Heritable is Ownable { * @dev Owner can send a heartbeat if they were mistakenly pronounced dead. */ function heartbeat() public onlyOwner { - emit OwnerHeartbeated(owner); + emit OwnerHeartbeated(getOwner()); timeOfDeath_ = 0; } @@ -107,9 +107,8 @@ contract Heritable is Ownable { require(!_ownerLives()); // solium-disable-next-line security/no-block-members require(block.timestamp >= timeOfDeath_ + heartbeatTimeout_); - emit OwnershipTransferred(owner, heir_); - emit HeirOwnershipClaimed(owner, heir_); - owner = heir_; + emit HeirOwnershipClaimed(getOwner(), heir_); + transferOwnership(heir_); timeOfDeath_ = 0; } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 1fbf571bf7c..a4d42ab0501 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -7,7 +7,7 @@ pragma solidity ^0.4.24; * functions, this simplifies the implementation of "user permissions". */ contract Ownable { - address public owner; + address private owner_; event OwnershipRenounced(address indexed previousOwner); @@ -22,14 +22,21 @@ contract Ownable { * account. */ constructor() public { - owner = msg.sender; + owner_ = msg.sender; + } + + /** + * @return the address of the owner. + */ + function getOwner() public view returns(address) { + return owner_; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { - require(msg.sender == owner); + require(msg.sender == owner_); _; } @@ -40,7 +47,7 @@ contract Ownable { * modifier anymore. */ function renounceOwnership() public onlyOwner { - emit OwnershipRenounced(owner); + emit OwnershipRenounced(owner_); owner = address(0); } @@ -58,7 +65,7 @@ contract Ownable { */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); - emit OwnershipTransferred(owner, _newOwner); - owner = _newOwner; + emit OwnershipTransferred(owner_, _newOwner); + owner_ = _newOwner; } } diff --git a/contracts/ownership/Superuser.sol b/contracts/ownership/Superuser.sol index afacc193455..98bc24721b5 100644 --- a/contracts/ownership/Superuser.sol +++ b/contracts/ownership/Superuser.sol @@ -27,7 +27,7 @@ contract Superuser is Ownable, RBAC { } modifier onlyOwnerOrSuperuser() { - require(msg.sender == owner || isSuperuser(msg.sender)); + require(msg.sender == getOwner() || isSuperuser(msg.sender)); _; } diff --git a/contracts/token/ERC20/ERC20Mintable.sol b/contracts/token/ERC20/ERC20Mintable.sol index 0ba200cdfac..de847f542ee 100644 --- a/contracts/token/ERC20/ERC20Mintable.sol +++ b/contracts/token/ERC20/ERC20Mintable.sol @@ -22,7 +22,7 @@ contract ERC20Mintable is ERC20, Ownable { } modifier hasMintPermission() { - require(msg.sender == owner); + require(msg.sender == getOwner()); _; } diff --git a/contracts/token/ERC20/TokenVesting.sol b/contracts/token/ERC20/TokenVesting.sol index 31fac8882ce..5b52c2b3074 100644 --- a/contracts/token/ERC20/TokenVesting.sol +++ b/contracts/token/ERC20/TokenVesting.sol @@ -93,7 +93,7 @@ contract TokenVesting is Ownable { revoked[_token] = true; - _token.safeTransfer(owner, refund); + _token.safeTransfer(getOwner(), refund); emit Revoked(); } diff --git a/test/access/SignatureBouncer.test.js b/test/access/SignatureBouncer.test.js index 20bc8542722..817f2f4776e 100644 --- a/test/access/SignatureBouncer.test.js +++ b/test/access/SignatureBouncer.test.js @@ -21,7 +21,7 @@ contract('Bouncer', function ([_, owner, anyone, bouncerAddress, authorizedUser] context('management', function () { it('has a default owner of self', async function () { - (await this.bouncer.owner()).should.equal(owner); + (await this.bouncer.getOwner()).should.equal(owner); }); it('allows the owner to add a bouncer', async function () { diff --git a/test/crowdsale/MintedCrowdsale.test.js b/test/crowdsale/MintedCrowdsale.test.js index 27f64e6edd2..8e4de50d86c 100644 --- a/test/crowdsale/MintedCrowdsale.test.js +++ b/test/crowdsale/MintedCrowdsale.test.js @@ -21,7 +21,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) { }); it('should be token owner', async function () { - (await this.token.owner()).should.equal(this.crowdsale.address); + (await this.token.getOwner()).should.equal(this.crowdsale.address); }); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); diff --git a/test/ownership/Claimable.test.js b/test/ownership/Claimable.test.js index bfc1355d5f7..40659532676 100644 --- a/test/ownership/Claimable.test.js +++ b/test/ownership/Claimable.test.js @@ -16,12 +16,12 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { }); it('should have an owner', async function () { - (await claimable.owner()).should.not.equal(0); + (await claimable.getOwner()).should.not.equal(0); }); it('changes pendingOwner after transfer', async function () { await claimable.transferOwnership(newOwner, { from: owner }); - (await claimable.pendingOwner()).should.equal(newOwner); + (await claimable.getPendingOwner()).should.equal(newOwner); }); it('should prevent to claimOwnership from anyone', async function () { @@ -40,7 +40,7 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { it('changes allow pending owner to claim ownership', async function () { await claimable.claimOwnership({ from: newOwner }); - (await claimable.owner()).should.equal(newOwner); + (await claimable.getOwner()).should.equal(newOwner); }); }); }); diff --git a/test/ownership/DelayedClaimable.test.js b/test/ownership/DelayedClaimable.test.js index e65ac86c41d..039f1ae672c 100644 --- a/test/ownership/DelayedClaimable.test.js +++ b/test/ownership/DelayedClaimable.test.js @@ -17,35 +17,35 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) { await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.setLimits(0, 1000, { from: owner }); - (await this.delayedClaimable.end()).should.be.bignumber.equal(1000); + (await this.delayedClaimable.getEnd()).should.be.bignumber.equal(1000); - (await this.delayedClaimable.start()).should.be.bignumber.equal(0); + (await this.delayedClaimable.getStart()).should.be.bignumber.equal(0); }); it('changes pendingOwner after transfer successful', async function () { await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.setLimits(0, 1000, { from: owner }); - (await this.delayedClaimable.end()).should.be.bignumber.equal(1000); + (await this.delayedClaimable.getEnd()).should.be.bignumber.equal(1000); - (await this.delayedClaimable.start()).should.be.bignumber.equal(0); + (await this.delayedClaimable.getStart()).should.be.bignumber.equal(0); - (await this.delayedClaimable.pendingOwner()).should.equal(newOwner); + (await this.delayedClaimable.getPendingOwner()).should.equal(newOwner); await this.delayedClaimable.claimOwnership({ from: newOwner }); - (await this.delayedClaimable.owner()).should.equal(newOwner); + (await this.delayedClaimable.getOwner()).should.equal(newOwner); }); it('changes pendingOwner after transfer fails', async function () { await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.setLimits(100, 110, { from: owner }); - (await this.delayedClaimable.end()).should.be.bignumber.equal(110); + (await this.delayedClaimable.getEnd()).should.be.bignumber.equal(110); - (await this.delayedClaimable.start()).should.be.bignumber.equal(100); + (await this.delayedClaimable.getStart()).should.be.bignumber.equal(100); - (await this.delayedClaimable.pendingOwner()).should.equal(newOwner); + (await this.delayedClaimable.getPendingOwner()).should.equal(newOwner); await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner })); - (await this.delayedClaimable.owner()).should.not.equal(newOwner); + (await this.delayedClaimable.getOwner()).should.not.equal(newOwner); }); it('set end and start invalid values fail', async function () { diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index 6257c01df5a..ebb550b0f25 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -9,12 +9,12 @@ require('chai') function shouldBehaveLikeOwnable (owner, [anyone]) { describe('as an ownable', function () { it('should have an owner', async function () { - (await this.ownable.owner()).should.equal(owner); + (await this.ownable.getOwner()).should.equal(owner); }); it('changes owner after transfer', async function () { await this.ownable.transferOwnership(anyone, { from: owner }); - (await this.ownable.owner()).should.equal(anyone); + (await this.ownable.getOwner()).should.equal(anyone); }); it('should prevent non-owners from transfering', async function () { @@ -27,7 +27,7 @@ function shouldBehaveLikeOwnable (owner, [anyone]) { it('loses owner after renouncement', async function () { await this.ownable.renounceOwnership({ from: owner }); - (await this.ownable.owner()).should.equal(ZERO_ADDRESS); + (await this.ownable.getOwner()).should.equal(ZERO_ADDRESS); }); it('should prevent non-owners from renouncement', async function () { diff --git a/test/ownership/Superuser.test.js b/test/ownership/Superuser.test.js index 5e4d2c32456..3b4e6ede62d 100644 --- a/test/ownership/Superuser.test.js +++ b/test/ownership/Superuser.test.js @@ -40,7 +40,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) 'OwnershipTransferred' ); - (await this.superuser.owner()).should.equal(newOwner); + (await this.superuser.getOwner()).should.equal(newOwner); }); it('should change owner after the owner transfers the ownership', async function () { @@ -49,7 +49,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) 'OwnershipTransferred' ); - (await this.superuser.owner()).should.equal(newOwner); + (await this.superuser.getOwner()).should.equal(newOwner); }); }); diff --git a/test/token/ERC20/ERC20Mintable.behavior.js b/test/token/ERC20/ERC20Mintable.behavior.js index 63fb861b551..cb982ed26f1 100644 --- a/test/token/ERC20/ERC20Mintable.behavior.js +++ b/test/token/ERC20/ERC20Mintable.behavior.js @@ -13,7 +13,7 @@ function shouldBehaveLikeERC20Mintable (owner, minter, [anyone]) { describe('as a basic mintable token', function () { describe('after token creation', function () { it('sender should be token owner', async function () { - (await this.token.owner({ from: owner })).should.equal(owner); + (await this.token.getOwner({ from: owner })).should.equal(owner); }); }); From 82f23f025e2346cc76b3d26e4550684d5c278c56 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 3 Sep 2018 03:50:07 +0000 Subject: [PATCH 04/13] fix rebase --- contracts/bounties/BreakInvariantBounty.sol | 2 +- contracts/ownership/Ownable.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/bounties/BreakInvariantBounty.sol b/contracts/bounties/BreakInvariantBounty.sol index c889fbe606f..1f330ffd378 100644 --- a/contracts/bounties/BreakInvariantBounty.sol +++ b/contracts/bounties/BreakInvariantBounty.sol @@ -50,7 +50,7 @@ contract BreakInvariantBounty is PullPayment, Ownable { * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() public onlyOwner { - selfdestruct(owner); + selfdestruct(getOwner()); } /** diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index a4d42ab0501..9a7d60d8978 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -48,7 +48,7 @@ contract Ownable { */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner_); - owner = address(0); + owner_ = address(0); } /** From 28422840f1b8d820a2bc45a4f41cfb84ad0c2265 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 3 Sep 2018 03:55:20 +0000 Subject: [PATCH 05/13] fix ownership --- contracts/ownership/CanReclaimToken.sol | 2 +- contracts/ownership/Claimable.sol | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/contracts/ownership/CanReclaimToken.sol b/contracts/ownership/CanReclaimToken.sol index 858a1db84e8..11452cdeb9b 100644 --- a/contracts/ownership/CanReclaimToken.sol +++ b/contracts/ownership/CanReclaimToken.sol @@ -20,7 +20,7 @@ contract CanReclaimToken is Ownable { */ function reclaimToken(IERC20 _token) external onlyOwner { uint256 balance = _token.balanceOf(this); - _token.safeTransfer(owner, balance); + _token.safeTransfer(getOwner(), balance); } } diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index 6576632af12..fd7c2ffbb39 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -39,8 +39,6 @@ contract Claimable is Ownable { * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { - emit OwnershipTransferred(getOwner(), pendingOwner_); - owner = pendingOwner_; - pendingOwner_ = address(0); + _transferOwnership(pendingOwner_); } } From fe431bfe8e8599229dd153f81bbab0ac51c10486 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Mon, 3 Sep 2018 04:23:33 +0000 Subject: [PATCH 06/13] Improve encapsulation on payments --- contracts/ownership/Heritable.sol | 2 +- contracts/payment/RefundEscrow.sol | 38 +++++++++++------ contracts/payment/SplitPayment.sol | 67 +++++++++++++++++++++++------- test/payment/RefundEscrow.test.js | 4 ++ test/payment/SplitPayment.test.js | 6 +-- 5 files changed, 85 insertions(+), 32 deletions(-) diff --git a/contracts/ownership/Heritable.sol b/contracts/ownership/Heritable.sol index 9e3214c071f..fc3d561fcad 100644 --- a/contracts/ownership/Heritable.sol +++ b/contracts/ownership/Heritable.sol @@ -108,7 +108,7 @@ contract Heritable is Ownable { // solium-disable-next-line security/no-block-members require(block.timestamp >= timeOfDeath_ + heartbeatTimeout_); emit HeirOwnershipClaimed(getOwner(), heir_); - transferOwnership(heir_); + _transferOwnership(heir_); timeOfDeath_ = 0; } diff --git a/contracts/payment/RefundEscrow.sol b/contracts/payment/RefundEscrow.sol index 9ba5fc60032..d9c11db5395 100644 --- a/contracts/payment/RefundEscrow.sol +++ b/contracts/payment/RefundEscrow.sol @@ -16,8 +16,8 @@ contract RefundEscrow is Ownable, ConditionalEscrow { event Closed(); event RefundsEnabled(); - State public state; - address public beneficiary; + State private state_; + address private beneficiary_; /** * @dev Constructor. @@ -25,8 +25,22 @@ contract RefundEscrow is Ownable, ConditionalEscrow { */ constructor(address _beneficiary) public { require(_beneficiary != address(0)); - beneficiary = _beneficiary; - state = State.Active; + beneficiary_ = _beneficiary; + state_ = State.Active; + } + + /** + * @return the current state of the escrow. + */ + function getState() public view returns(State) { + return state_; + } + + /** + * @return the beneficiary of the escrow. + */ + function getBeneficiary() public view returns(address) { + return beneficiary_; } /** @@ -34,7 +48,7 @@ contract RefundEscrow is Ownable, ConditionalEscrow { * @param _refundee The address funds will be sent to if a refund occurs. */ function deposit(address _refundee) public payable { - require(state == State.Active); + require(state_ == State.Active); super.deposit(_refundee); } @@ -43,8 +57,8 @@ contract RefundEscrow is Ownable, ConditionalEscrow { * further deposits. */ function close() public onlyOwner { - require(state == State.Active); - state = State.Closed; + require(state_ == State.Active); + state_ = State.Closed; emit Closed(); } @@ -52,8 +66,8 @@ contract RefundEscrow is Ownable, ConditionalEscrow { * @dev Allows for refunds to take place, rejecting further deposits. */ function enableRefunds() public onlyOwner { - require(state == State.Active); - state = State.Refunding; + require(state_ == State.Active); + state_ = State.Refunding; emit RefundsEnabled(); } @@ -61,14 +75,14 @@ contract RefundEscrow is Ownable, ConditionalEscrow { * @dev Withdraws the beneficiary's funds. */ function beneficiaryWithdraw() public { - require(state == State.Closed); - beneficiary.transfer(address(this).balance); + require(state_ == State.Closed); + beneficiary_.transfer(address(this).balance); } /** * @dev Returns whether refundees can withdraw their deposits (be refunded). */ function withdrawalAllowed(address _payee) public view returns (bool) { - return state == State.Refunding; + return state_ == State.Refunding; } } diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index 04b01425683..8b1c53017de 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -11,12 +11,12 @@ import "../math/SafeMath.sol"; contract SplitPayment { using SafeMath for uint256; - uint256 public totalShares = 0; - uint256 public totalReleased = 0; + uint256 private totalShares_ = 0; + uint256 private totalReleased_ = 0; - mapping(address => uint256) public shares; - mapping(address => uint256) public released; - address[] public payees; + mapping(address => uint256) private shares_; + mapping(address => uint256) private released_; + address[] private payees_; /** * @dev Constructor @@ -35,26 +35,61 @@ contract SplitPayment { */ function () external payable {} + /** + * @return the total shares of the contract. + */ + function getTotalShares() public view returns(uint256) { + return totalShares_; + } + + /** + * @return the total amount already released. + */ + function getTotalReleased() public view returns(uint256) { + return totalReleased_; + } + + /** + * @return the shares of an account. + */ + function getShares(address _account) public view returns(uint256) { + return shares_[_account]; + } + + /** + * @return the amount already released to an account. + */ + function getReleased(address _account) public view returns(uint256) { + return released_[_account]; + } + + /** + * @return the address of a payee. + */ + function getPayee(uint256 index) public view returns(address) { + return payees_[index]; + } + /** * @dev Claim your share of the balance. */ function claim() public { address payee = msg.sender; - require(shares[payee] > 0); + require(shares_[payee] > 0); - uint256 totalReceived = address(this).balance.add(totalReleased); + uint256 totalReceived = address(this).balance.add(totalReleased_); uint256 payment = totalReceived.mul( - shares[payee]).div( - totalShares).sub( - released[payee] + shares_[payee]).div( + totalShares_).sub( + released_[payee] ); require(payment != 0); assert(address(this).balance >= payment); - released[payee] = released[payee].add(payment); - totalReleased = totalReleased.add(payment); + released_[payee] = released_[payee].add(payment); + totalReleased_ = totalReleased_.add(payment); payee.transfer(payment); } @@ -67,10 +102,10 @@ contract SplitPayment { function _addPayee(address _payee, uint256 _shares) internal { require(_payee != address(0)); require(_shares > 0); - require(shares[_payee] == 0); + require(shares_[_payee] == 0); - payees.push(_payee); - shares[_payee] = _shares; - totalShares = totalShares.add(_shares); + payees_.push(_payee); + shares_[_payee] = _shares; + totalShares_ = totalShares_.add(_shares); } } diff --git a/test/payment/RefundEscrow.test.js b/test/payment/RefundEscrow.test.js index e74d68f674b..d96413e4148 100644 --- a/test/payment/RefundEscrow.test.js +++ b/test/payment/RefundEscrow.test.js @@ -28,6 +28,10 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2] }); context('active state', function () { + it('has beneficiary', async function () { + (await this.escrow.getBeneficiary()).should.be.equal(beneficiary); + }); + it('accepts deposits', async function () { await this.escrow.deposit(refundee1, { from: owner, value: amount }); diff --git a/test/payment/SplitPayment.test.js b/test/payment/SplitPayment.test.js index bb09ea73cac..c713ff48cc6 100644 --- a/test/payment/SplitPayment.test.js +++ b/test/payment/SplitPayment.test.js @@ -53,11 +53,11 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, }); it('should store shares if address is payee', async function () { - (await this.contract.shares.call(payee1)).should.be.bignumber.not.equal(0); + (await this.contract.getShares(payee1)).should.be.bignumber.not.equal(0); }); it('should not store shares if address is not payee', async function () { - (await this.contract.shares.call(nonpayee1)).should.be.bignumber.equal(0); + (await this.contract.getShares(nonpayee1)).should.be.bignumber.equal(0); }); it('should throw if no funds to claim', async function () { @@ -96,7 +96,7 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, (await ethGetBalance(this.contract.address)).should.be.bignumber.equal(0); // check correct funds released accounting - (await this.contract.totalReleased.call()).should.be.bignumber.equal(initBalance); + (await this.contract.getTotalReleased()).should.be.bignumber.equal(initBalance); }); }); }); From bb5a1a970be62932d89c041b9d860dc391a68db1 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Tue, 4 Sep 2018 04:55:07 +0000 Subject: [PATCH 07/13] Add missing tests --- test/payment/SplitPayment.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/payment/SplitPayment.test.js b/test/payment/SplitPayment.test.js index c713ff48cc6..fcbf6c58af1 100644 --- a/test/payment/SplitPayment.test.js +++ b/test/payment/SplitPayment.test.js @@ -46,6 +46,17 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, this.contract = await SplitPayment.new(this.payees, this.shares); }); + it('should have total shares', async function () { + (await this.contract.getTotalShares()).should.be.bignumber.equal(20 + 10 + 70); + }); + + it('should have payees', async function () { + this.payees.forEach(async (payee, index) => { + (await this.getPayee(index)).should.be.equal(payee); + (await this.contract.getReleased(payee)).should.be.bignumber.equal(0); + }); + }); + it('should accept payments', async function () { await ethSendTransaction({ from: owner, to: this.contract.address, value: amount }); From 63ee53f2e0bcf3a31d4c07617d7dd54eed515e75 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Tue, 4 Sep 2018 18:39:30 +0000 Subject: [PATCH 08/13] add missing test --- test/payment/RefundEscrow.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/payment/RefundEscrow.test.js b/test/payment/RefundEscrow.test.js index d96413e4148..392d07603cb 100644 --- a/test/payment/RefundEscrow.test.js +++ b/test/payment/RefundEscrow.test.js @@ -28,8 +28,9 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2] }); context('active state', function () { - it('has beneficiary', async function () { + it('has beneficiary and state', async function () { (await this.escrow.getBeneficiary()).should.be.equal(beneficiary); + (await this.escrow.getState()).should.be.bignumber.equal(0); }); it('accepts deposits', async function () { From bd25984a7546f5a9d8e6f7be4dc5326f7a0dcbeb Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 5 Sep 2018 02:23:44 +0000 Subject: [PATCH 09/13] Do not prefix getters --- contracts/bounties/BreakInvariantBounty.sol | 2 +- contracts/lifecycle/Pausable.sol | 2 +- contracts/ownership/CanReclaimToken.sol | 2 +- contracts/ownership/Claimable.sol | 2 +- contracts/ownership/DelayedClaimable.sol | 4 ++-- contracts/ownership/Heritable.sol | 10 +++++----- contracts/ownership/Ownable.sol | 2 +- contracts/ownership/Superuser.sol | 2 +- contracts/payment/RefundEscrow.sol | 4 ++-- contracts/payment/SplitPayment.sol | 10 +++++----- contracts/token/ERC20/ERC20Mintable.sol | 2 +- contracts/token/ERC20/TokenVesting.sol | 2 +- test/access/SignatureBouncer.test.js | 2 +- test/crowdsale/MintedCrowdsale.test.js | 2 +- test/ownership/Claimable.test.js | 6 +++--- test/ownership/DelayedClaimable.test.js | 20 ++++++++++---------- test/ownership/Ownable.behavior.js | 6 +++--- test/ownership/Superuser.test.js | 4 ++-- test/payment/RefundEscrow.test.js | 4 ++-- test/payment/SplitPayment.test.js | 10 +++++----- test/token/ERC20/ERC20Pausable.test.js | 10 +++++----- 21 files changed, 54 insertions(+), 54 deletions(-) diff --git a/contracts/bounties/BreakInvariantBounty.sol b/contracts/bounties/BreakInvariantBounty.sol index 1f330ffd378..5301a2d51a4 100644 --- a/contracts/bounties/BreakInvariantBounty.sol +++ b/contracts/bounties/BreakInvariantBounty.sol @@ -50,7 +50,7 @@ contract BreakInvariantBounty is PullPayment, Ownable { * @dev Transfers the current balance to the owner and terminates the contract. */ function destroy() public onlyOwner { - selfdestruct(getOwner()); + selfdestruct(owner()); } /** diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index 3e5676f7f87..37caf1e0a52 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -18,7 +18,7 @@ contract Pausable is Ownable { /** * @return true if the contract is paused, false otherwise. */ - function isPaused() public view returns(bool) { + function paused() public view returns(bool) { return paused_; } diff --git a/contracts/ownership/CanReclaimToken.sol b/contracts/ownership/CanReclaimToken.sol index 11452cdeb9b..e4f7e88a638 100644 --- a/contracts/ownership/CanReclaimToken.sol +++ b/contracts/ownership/CanReclaimToken.sol @@ -20,7 +20,7 @@ contract CanReclaimToken is Ownable { */ function reclaimToken(IERC20 _token) external onlyOwner { uint256 balance = _token.balanceOf(this); - _token.safeTransfer(getOwner(), balance); + _token.safeTransfer(owner(), balance); } } diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index fd7c2ffbb39..7c19d288076 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -23,7 +23,7 @@ contract Claimable is Ownable { /** * @return the address of the pending owner. */ - function getPendingOwner() public view returns(address) { + function pendingOwner() public view returns(address) { return pendingOwner_; } diff --git a/contracts/ownership/DelayedClaimable.sol b/contracts/ownership/DelayedClaimable.sol index b965856490a..b373e0067ea 100644 --- a/contracts/ownership/DelayedClaimable.sol +++ b/contracts/ownership/DelayedClaimable.sol @@ -16,14 +16,14 @@ contract DelayedClaimable is Claimable { /** * @return the start of the claimable period. */ - function getStart() public view returns(uint256) { + function start() public view returns(uint256) { return start_; } /** * @return the end of the claimable period. */ - function getEnd() public view returns(uint256) { + function end() public view returns(uint256) { return end_; } diff --git a/contracts/ownership/Heritable.sol b/contracts/ownership/Heritable.sol index fc3d561fcad..d015468f5ca 100644 --- a/contracts/ownership/Heritable.sol +++ b/contracts/ownership/Heritable.sol @@ -51,9 +51,9 @@ contract Heritable is Ownable { } function setHeir(address _newHeir) public onlyOwner { - require(_newHeir != getOwner()); + require(_newHeir != owner()); heartbeat(); - emit HeirChanged(getOwner(), _newHeir); + emit HeirChanged(owner(), _newHeir); heir_ = _newHeir; } @@ -87,7 +87,7 @@ contract Heritable is Ownable { */ function proclaimDeath() public onlyHeir { require(_ownerLives()); - emit OwnerProclaimedDead(getOwner(), heir_, timeOfDeath_); + emit OwnerProclaimedDead(owner(), heir_, timeOfDeath_); // solium-disable-next-line security/no-block-members timeOfDeath_ = block.timestamp; } @@ -96,7 +96,7 @@ contract Heritable is Ownable { * @dev Owner can send a heartbeat if they were mistakenly pronounced dead. */ function heartbeat() public onlyOwner { - emit OwnerHeartbeated(getOwner()); + emit OwnerHeartbeated(owner()); timeOfDeath_ = 0; } @@ -107,7 +107,7 @@ contract Heritable is Ownable { require(!_ownerLives()); // solium-disable-next-line security/no-block-members require(block.timestamp >= timeOfDeath_ + heartbeatTimeout_); - emit HeirOwnershipClaimed(getOwner(), heir_); + emit HeirOwnershipClaimed(owner(), heir_); _transferOwnership(heir_); timeOfDeath_ = 0; } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 9a7d60d8978..f89013a1a53 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -28,7 +28,7 @@ contract Ownable { /** * @return the address of the owner. */ - function getOwner() public view returns(address) { + function owner() public view returns(address) { return owner_; } diff --git a/contracts/ownership/Superuser.sol b/contracts/ownership/Superuser.sol index c0fddf3ab5c..b1f1fa4b52d 100644 --- a/contracts/ownership/Superuser.sol +++ b/contracts/ownership/Superuser.sol @@ -27,7 +27,7 @@ contract Superuser is Ownable, RBAC { } modifier onlyOwnerOrSuperuser() { - require(msg.sender == getOwner() || isSuperuser(msg.sender)); + require(msg.sender == owner() || isSuperuser(msg.sender)); _; } diff --git a/contracts/payment/RefundEscrow.sol b/contracts/payment/RefundEscrow.sol index d9c11db5395..802dd471128 100644 --- a/contracts/payment/RefundEscrow.sol +++ b/contracts/payment/RefundEscrow.sol @@ -32,14 +32,14 @@ contract RefundEscrow is Ownable, ConditionalEscrow { /** * @return the current state of the escrow. */ - function getState() public view returns(State) { + function state() public view returns(State) { return state_; } /** * @return the beneficiary of the escrow. */ - function getBeneficiary() public view returns(address) { + function beneficiary() public view returns(address) { return beneficiary_; } diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index 8b1c53017de..1655b738383 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -38,35 +38,35 @@ contract SplitPayment { /** * @return the total shares of the contract. */ - function getTotalShares() public view returns(uint256) { + function totalShares() public view returns(uint256) { return totalShares_; } /** * @return the total amount already released. */ - function getTotalReleased() public view returns(uint256) { + function totalReleased() public view returns(uint256) { return totalReleased_; } /** * @return the shares of an account. */ - function getShares(address _account) public view returns(uint256) { + function shares(address _account) public view returns(uint256) { return shares_[_account]; } /** * @return the amount already released to an account. */ - function getReleased(address _account) public view returns(uint256) { + function released(address _account) public view returns(uint256) { return released_[_account]; } /** * @return the address of a payee. */ - function getPayee(uint256 index) public view returns(address) { + function payee(uint256 index) public view returns(address) { return payees_[index]; } diff --git a/contracts/token/ERC20/ERC20Mintable.sol b/contracts/token/ERC20/ERC20Mintable.sol index de847f542ee..46d69813e6b 100644 --- a/contracts/token/ERC20/ERC20Mintable.sol +++ b/contracts/token/ERC20/ERC20Mintable.sol @@ -22,7 +22,7 @@ contract ERC20Mintable is ERC20, Ownable { } modifier hasMintPermission() { - require(msg.sender == getOwner()); + require(msg.sender == owner()); _; } diff --git a/contracts/token/ERC20/TokenVesting.sol b/contracts/token/ERC20/TokenVesting.sol index 5b52c2b3074..10d109b797c 100644 --- a/contracts/token/ERC20/TokenVesting.sol +++ b/contracts/token/ERC20/TokenVesting.sol @@ -93,7 +93,7 @@ contract TokenVesting is Ownable { revoked[_token] = true; - _token.safeTransfer(getOwner(), refund); + _token.safeTransfer(owner(), refund); emit Revoked(); } diff --git a/test/access/SignatureBouncer.test.js b/test/access/SignatureBouncer.test.js index 19143c850b0..798ab0ac9fa 100644 --- a/test/access/SignatureBouncer.test.js +++ b/test/access/SignatureBouncer.test.js @@ -20,7 +20,7 @@ contract('Bouncer', function ([_, owner, anyone, bouncerAddress, authorizedUser] context('management', function () { it('has a default owner of self', async function () { - (await this.bouncer.getOwner()).should.equal(owner); + (await this.bouncer.owner()).should.equal(owner); }); it('allows the owner to add a bouncer', async function () { diff --git a/test/crowdsale/MintedCrowdsale.test.js b/test/crowdsale/MintedCrowdsale.test.js index 9f3c8204229..50a37eaef72 100644 --- a/test/crowdsale/MintedCrowdsale.test.js +++ b/test/crowdsale/MintedCrowdsale.test.js @@ -21,7 +21,7 @@ contract('MintedCrowdsale', function ([_, investor, wallet, purchaser]) { }); it('should be token owner', async function () { - (await this.token.getOwner()).should.equal(this.crowdsale.address); + (await this.token.owner()).should.equal(this.crowdsale.address); }); shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value); diff --git a/test/ownership/Claimable.test.js b/test/ownership/Claimable.test.js index 40659532676..bfc1355d5f7 100644 --- a/test/ownership/Claimable.test.js +++ b/test/ownership/Claimable.test.js @@ -16,12 +16,12 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { }); it('should have an owner', async function () { - (await claimable.getOwner()).should.not.equal(0); + (await claimable.owner()).should.not.equal(0); }); it('changes pendingOwner after transfer', async function () { await claimable.transferOwnership(newOwner, { from: owner }); - (await claimable.getPendingOwner()).should.equal(newOwner); + (await claimable.pendingOwner()).should.equal(newOwner); }); it('should prevent to claimOwnership from anyone', async function () { @@ -40,7 +40,7 @@ contract('Claimable', function ([_, owner, newOwner, anyone]) { it('changes allow pending owner to claim ownership', async function () { await claimable.claimOwnership({ from: newOwner }); - (await claimable.getOwner()).should.equal(newOwner); + (await claimable.owner()).should.equal(newOwner); }); }); }); diff --git a/test/ownership/DelayedClaimable.test.js b/test/ownership/DelayedClaimable.test.js index 039f1ae672c..e65ac86c41d 100644 --- a/test/ownership/DelayedClaimable.test.js +++ b/test/ownership/DelayedClaimable.test.js @@ -17,35 +17,35 @@ contract('DelayedClaimable', function ([_, owner, newOwner]) { await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.setLimits(0, 1000, { from: owner }); - (await this.delayedClaimable.getEnd()).should.be.bignumber.equal(1000); + (await this.delayedClaimable.end()).should.be.bignumber.equal(1000); - (await this.delayedClaimable.getStart()).should.be.bignumber.equal(0); + (await this.delayedClaimable.start()).should.be.bignumber.equal(0); }); it('changes pendingOwner after transfer successful', async function () { await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.setLimits(0, 1000, { from: owner }); - (await this.delayedClaimable.getEnd()).should.be.bignumber.equal(1000); + (await this.delayedClaimable.end()).should.be.bignumber.equal(1000); - (await this.delayedClaimable.getStart()).should.be.bignumber.equal(0); + (await this.delayedClaimable.start()).should.be.bignumber.equal(0); - (await this.delayedClaimable.getPendingOwner()).should.equal(newOwner); + (await this.delayedClaimable.pendingOwner()).should.equal(newOwner); await this.delayedClaimable.claimOwnership({ from: newOwner }); - (await this.delayedClaimable.getOwner()).should.equal(newOwner); + (await this.delayedClaimable.owner()).should.equal(newOwner); }); it('changes pendingOwner after transfer fails', async function () { await this.delayedClaimable.transferOwnership(newOwner, { from: owner }); await this.delayedClaimable.setLimits(100, 110, { from: owner }); - (await this.delayedClaimable.getEnd()).should.be.bignumber.equal(110); + (await this.delayedClaimable.end()).should.be.bignumber.equal(110); - (await this.delayedClaimable.getStart()).should.be.bignumber.equal(100); + (await this.delayedClaimable.start()).should.be.bignumber.equal(100); - (await this.delayedClaimable.getPendingOwner()).should.equal(newOwner); + (await this.delayedClaimable.pendingOwner()).should.equal(newOwner); await assertRevert(this.delayedClaimable.claimOwnership({ from: newOwner })); - (await this.delayedClaimable.getOwner()).should.not.equal(newOwner); + (await this.delayedClaimable.owner()).should.not.equal(newOwner); }); it('set end and start invalid values fail', async function () { diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index ebb550b0f25..6257c01df5a 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -9,12 +9,12 @@ require('chai') function shouldBehaveLikeOwnable (owner, [anyone]) { describe('as an ownable', function () { it('should have an owner', async function () { - (await this.ownable.getOwner()).should.equal(owner); + (await this.ownable.owner()).should.equal(owner); }); it('changes owner after transfer', async function () { await this.ownable.transferOwnership(anyone, { from: owner }); - (await this.ownable.getOwner()).should.equal(anyone); + (await this.ownable.owner()).should.equal(anyone); }); it('should prevent non-owners from transfering', async function () { @@ -27,7 +27,7 @@ function shouldBehaveLikeOwnable (owner, [anyone]) { it('loses owner after renouncement', async function () { await this.ownable.renounceOwnership({ from: owner }); - (await this.ownable.getOwner()).should.equal(ZERO_ADDRESS); + (await this.ownable.owner()).should.equal(ZERO_ADDRESS); }); it('should prevent non-owners from renouncement', async function () { diff --git a/test/ownership/Superuser.test.js b/test/ownership/Superuser.test.js index 3b4e6ede62d..5e4d2c32456 100644 --- a/test/ownership/Superuser.test.js +++ b/test/ownership/Superuser.test.js @@ -40,7 +40,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) 'OwnershipTransferred' ); - (await this.superuser.getOwner()).should.equal(newOwner); + (await this.superuser.owner()).should.equal(newOwner); }); it('should change owner after the owner transfers the ownership', async function () { @@ -49,7 +49,7 @@ contract('Superuser', function ([_, firstOwner, newSuperuser, newOwner, anyone]) 'OwnershipTransferred' ); - (await this.superuser.getOwner()).should.equal(newOwner); + (await this.superuser.owner()).should.equal(newOwner); }); }); diff --git a/test/payment/RefundEscrow.test.js b/test/payment/RefundEscrow.test.js index 392d07603cb..7730d8242a0 100644 --- a/test/payment/RefundEscrow.test.js +++ b/test/payment/RefundEscrow.test.js @@ -29,8 +29,8 @@ contract('RefundEscrow', function ([_, owner, beneficiary, refundee1, refundee2] context('active state', function () { it('has beneficiary and state', async function () { - (await this.escrow.getBeneficiary()).should.be.equal(beneficiary); - (await this.escrow.getState()).should.be.bignumber.equal(0); + (await this.escrow.beneficiary()).should.be.equal(beneficiary); + (await this.escrow.state()).should.be.bignumber.equal(0); }); it('accepts deposits', async function () { diff --git a/test/payment/SplitPayment.test.js b/test/payment/SplitPayment.test.js index fcbf6c58af1..f1f08601e3d 100644 --- a/test/payment/SplitPayment.test.js +++ b/test/payment/SplitPayment.test.js @@ -47,13 +47,13 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, }); it('should have total shares', async function () { - (await this.contract.getTotalShares()).should.be.bignumber.equal(20 + 10 + 70); + (await this.contract.totalShares()).should.be.bignumber.equal(20 + 10 + 70); }); it('should have payees', async function () { this.payees.forEach(async (payee, index) => { - (await this.getPayee(index)).should.be.equal(payee); - (await this.contract.getReleased(payee)).should.be.bignumber.equal(0); + (await this.payee(index)).should.be.equal(payee); + (await this.contract.released(payee)).should.be.bignumber.equal(0); }); }); @@ -64,11 +64,11 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, }); it('should store shares if address is payee', async function () { - (await this.contract.getShares(payee1)).should.be.bignumber.not.equal(0); + (await this.contract.shares(payee1)).should.be.bignumber.not.equal(0); }); it('should not store shares if address is not payee', async function () { - (await this.contract.getShares(nonpayee1)).should.be.bignumber.equal(0); + (await this.contract.shares(nonpayee1)).should.be.bignumber.equal(0); }); it('should throw if no funds to claim', async function () { diff --git a/test/token/ERC20/ERC20Pausable.test.js b/test/token/ERC20/ERC20Pausable.test.js index b11ecb3e7b6..8fbe4f70876 100644 --- a/test/token/ERC20/ERC20Pausable.test.js +++ b/test/token/ERC20/ERC20Pausable.test.js @@ -13,7 +13,7 @@ contract('ERC20Pausable', function ([_, owner, recipient, anotherAccount]) { describe('when the token is unpaused', function () { it('pauses the token', async function () { await this.token.pause({ from }); - (await this.token.isPaused()).should.equal(true); + (await this.token.paused()).should.equal(true); }); it('emits a Pause event', async function () { @@ -55,7 +55,7 @@ contract('ERC20Pausable', function ([_, owner, recipient, anotherAccount]) { it('unpauses the token', async function () { await this.token.unpause({ from }); - (await this.token.isPaused()).should.equal(false); + (await this.token.paused()).should.equal(false); }); it('emits an Unpause event', async function () { @@ -87,18 +87,18 @@ contract('ERC20Pausable', function ([_, owner, recipient, anotherAccount]) { describe('paused', function () { it('is not paused by default', async function () { - (await this.token.isPaused({ from })).should.equal(false); + (await this.token.paused({ from })).should.equal(false); }); it('is paused after being paused', async function () { await this.token.pause({ from }); - (await this.token.isPaused({ from })).should.equal(true); + (await this.token.paused({ from })).should.equal(true); }); it('is not paused after being paused and then unpaused', async function () { await this.token.pause({ from }); await this.token.unpause({ from }); - (await this.token.isPaused()).should.equal(false); + (await this.token.paused()).should.equal(false); }); }); From b3b41951f3443fc451bde974de79cbce64fce36d Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 5 Sep 2018 03:02:17 +0000 Subject: [PATCH 10/13] Fix tests. --- test/payment/SplitPayment.test.js | 2 +- test/token/ERC20/ERC20Mintable.behavior.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/payment/SplitPayment.test.js b/test/payment/SplitPayment.test.js index f1f08601e3d..a284530996a 100644 --- a/test/payment/SplitPayment.test.js +++ b/test/payment/SplitPayment.test.js @@ -107,7 +107,7 @@ contract('SplitPayment', function ([_, owner, payee1, payee2, payee3, nonpayee1, (await ethGetBalance(this.contract.address)).should.be.bignumber.equal(0); // check correct funds released accounting - (await this.contract.getTotalReleased()).should.be.bignumber.equal(initBalance); + (await this.contract.totalReleased()).should.be.bignumber.equal(initBalance); }); }); }); diff --git a/test/token/ERC20/ERC20Mintable.behavior.js b/test/token/ERC20/ERC20Mintable.behavior.js index cb982ed26f1..63fb861b551 100644 --- a/test/token/ERC20/ERC20Mintable.behavior.js +++ b/test/token/ERC20/ERC20Mintable.behavior.js @@ -13,7 +13,7 @@ function shouldBehaveLikeERC20Mintable (owner, minter, [anyone]) { describe('as a basic mintable token', function () { describe('after token creation', function () { it('sender should be token owner', async function () { - (await this.token.getOwner({ from: owner })).should.equal(owner); + (await this.token.owner({ from: owner })).should.equal(owner); }); }); From fc473b440c371a0e5edcb2d3a262b1e0048d027c Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 5 Sep 2018 14:17:36 +0000 Subject: [PATCH 11/13] revert pending owner reset --- contracts/ownership/Claimable.sol | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index 7c19d288076..d11d141f809 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -40,5 +40,6 @@ contract Claimable is Ownable { */ function claimOwnership() public onlyPendingOwner { _transferOwnership(pendingOwner_); + pendingOwner = address(0); } } From 5d04b0a207a3fd8d0f23a55dabfafc5e3940fd23 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 5 Sep 2018 14:33:54 +0000 Subject: [PATCH 12/13] add missing underscore --- contracts/ownership/Claimable.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index d11d141f809..f92d6abfa59 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -40,6 +40,6 @@ contract Claimable is Ownable { */ function claimOwnership() public onlyPendingOwner { _transferOwnership(pendingOwner_); - pendingOwner = address(0); + pendingOwner_ = address(0); } } From 436ceeb701e547368a62b98b332f4df6fd8e35d8 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 5 Sep 2018 15:16:31 +0000 Subject: [PATCH 13/13] Add missing underscore --- contracts/payment/SplitPayment.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/payment/SplitPayment.sol b/contracts/payment/SplitPayment.sol index a603339425c..0d4a2e0956d 100644 --- a/contracts/payment/SplitPayment.sol +++ b/contracts/payment/SplitPayment.sol @@ -79,15 +79,15 @@ contract SplitPayment { uint256 totalReceived = address(this).balance.add(totalReleased_); uint256 payment = totalReceived.mul( - shares_[payee]).div( + shares_[_payee]).div( totalShares_).sub( - released_[payee] + released_[_payee] ); require(payment != 0); assert(address(this).balance >= payment); - released_[payee] = released_[payee].add(payment); + released_[_payee] = released_[_payee].add(payment); totalReleased_ = totalReleased_.add(payment); _payee.transfer(payment);