From 9f3096c2e4d5575095928eb7d9cba5c62f421037 Mon Sep 17 00:00:00 2001 From: Prince Sinha Date: Mon, 1 Apr 2019 13:58:03 +0530 Subject: [PATCH 01/20] Error handling in ERC20 and ERC721 --- contracts/token/ERC20/ERC20.sol | 10 ++++---- contracts/token/ERC721/ERC721.sol | 29 +++++++++++++---------- contracts/token/ERC721/ERC721Burnable.sol | 2 +- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 52a1786e559..f00bbe14f3b 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0)); + require(to != address(0), "Address (to) can't be null !!"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0)); + require(account != address(0), "Address (to) can't be null !!"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0)); + require(account != address(0), "Address (to) can't be null !!"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0)); - require(owner != address(0)); + require(spender != address(0), "Address (spender) can't be null !!"); + require(owner != address(0), "Address (owner) can't be null !!"); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index e2437cf5e83..1ba853d67fd 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0)); + require(owner != address(0), "Address (to) can't be null !!"); return _ownedTokensCount[owner].current(); } @@ -67,8 +67,9 @@ contract ERC721 is ERC165, IERC721 { * @return address currently marked as the owner of the given token ID */ function ownerOf(uint256 tokenId) public view returns (address) { + require(_exists(tokenId), "TokenId doesn't exist !!"); address owner = _tokenOwner[tokenId]; - require(owner != address(0)); + require(owner != address(0), "Address (to) can't be null !!"); return owner; } @@ -81,9 +82,10 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be approved */ function approve(address to, uint256 tokenId) public { + require(_exists(tokenId), "TokenId doesn't exist !!"); address owner = ownerOf(tokenId); - require(to != owner); - require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); + require(to != owner, "You can't approve yourself !!"); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "Only owner of the token can approve !!"); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); @@ -96,7 +98,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId)); + require(_exists(tokenId), "TokenId doesn't exists !!"); return _tokenApprovals[tokenId]; } @@ -107,7 +109,7 @@ contract ERC721 is ERC165, IERC721 { * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { - require(to != msg.sender); + require(to != msg.sender, "You can't approve yourself !!"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } @@ -131,7 +133,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId)); + require(_isApprovedOrOwner(msg.sender, tokenId), "You must be either Owner or Approved by Owner !!"); _transferFrom(from, to, tokenId); } @@ -186,6 +188,7 @@ contract ERC721 is ERC165, IERC721 { * is an operator of the owner, or is the owner of the token */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { + require(_exists(tokenId), "TokenId doesn't exist !!"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } @@ -197,8 +200,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0)); - require(!_exists(tokenId)); + require(to != address(0), "Address (to) can't be null !!"); + require(!_exists(tokenId), "TokenId already exist !!"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); @@ -214,7 +217,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner); + require(_exists(tokenId), "TokenId doesn't exist !!"); + require(ownerOf(tokenId) == owner, "You are not the owner of this token !!"); _clearApproval(tokenId); @@ -241,8 +245,9 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from); - require(to != address(0)); + require(_exists(tokenId), "TokenId doesn't exist !!"); + require(ownerOf(tokenId) == from, "You are not the owner of this token !!"); + require(to != address(0), "Address (to) can't be null !!"); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index e2dc6cf7724..5181d7bc5e4 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -12,7 +12,7 @@ contract ERC721Burnable is ERC721 { * @param tokenId uint256 id of the ERC721 token to be burned. */ function burn(uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId)); + require(_isApprovedOrOwner(msg.sender, tokenId), "You must be either Owner or Approved by Owner !!"); _burn(tokenId); } } From cd6274a466385ea72dc3f1126263d0f2c75c9f08 Mon Sep 17 00:00:00 2001 From: balajipachai Date: Tue, 2 Apr 2019 00:11:06 +0530 Subject: [PATCH 02/20] Added message string for require. --- contracts/access/Roles.sol | 10 +++---- contracts/access/roles/CapperRole.sol | 2 +- contracts/access/roles/MinterRole.sol | 2 +- contracts/access/roles/PauserRole.sol | 2 +- contracts/access/roles/SignerRole.sol | 2 +- contracts/access/roles/WhitelistAdminRole.sol | 2 +- contracts/access/roles/WhitelistedRole.sol | 2 +- contracts/crowdsale/Crowdsale.sol | 10 +++---- .../distribution/FinalizableCrowdsale.sol | 4 +-- .../distribution/PostDeliveryCrowdsale.sol | 4 +-- .../distribution/RefundableCrowdsale.sol | 6 ++--- .../RefundablePostDeliveryCrowdsale.sol | 4 +-- .../crowdsale/emission/AllowanceCrowdsale.sol | 2 +- .../crowdsale/emission/MintedCrowdsale.sol | 2 +- .../price/IncreasingPriceCrowdsale.sol | 4 +-- .../crowdsale/validation/CappedCrowdsale.sol | 4 +-- .../IndividuallyCappedCrowdsale.sol | 2 +- .../crowdsale/validation/TimedCrowdsale.sol | 10 +++---- .../validation/WhitelistCrowdsale.sol | 2 +- contracts/drafts/ERC20Migrator.sol | 10 +++---- contracts/drafts/ERC20Snapshot.sol | 4 +-- contracts/drafts/SignatureBouncer.sol | 8 +++--- contracts/drafts/SignedSafeMath.sol | 12 ++++----- contracts/drafts/TokenVesting.sol | 14 +++++----- contracts/examples/SampleCrowdsale.sol | 2 +- contracts/introspection/ERC165.sol | 2 +- contracts/lifecycle/Pausable.sol | 4 +-- contracts/math/SafeMath.sol | 10 +++---- .../ERC165/ERC165InterfacesSupported.sol | 2 +- contracts/mocks/ERC721ReceiverMock.sol | 2 +- contracts/mocks/ReentrancyAttack.sol | 2 +- contracts/mocks/ReentrancyMock.sol | 2 +- contracts/mocks/SafeERC20Helper.sol | 2 +- contracts/ownership/Ownable.sol | 4 +-- contracts/ownership/Secondary.sol | 4 +-- contracts/payment/PaymentSplitter.sol | 14 +++++----- .../payment/escrow/ConditionalEscrow.sol | 2 +- contracts/payment/escrow/RefundEscrow.sol | 10 +++---- contracts/token/ERC20/ERC20.sol | 10 +++---- contracts/token/ERC20/ERC20Capped.sol | 4 +-- contracts/token/ERC20/SafeERC20.sol | 8 +++--- contracts/token/ERC20/TokenTimelock.sol | 6 ++--- contracts/token/ERC721/ERC721.sol | 26 +++++++++---------- contracts/token/ERC721/ERC721Burnable.sol | 2 +- contracts/token/ERC721/ERC721Enumerable.sol | 4 +-- contracts/token/ERC721/ERC721Metadata.sol | 4 +-- contracts/utils/ReentrancyGuard.sol | 2 +- 47 files changed, 126 insertions(+), 126 deletions(-) diff --git a/contracts/access/Roles.sol b/contracts/access/Roles.sol index 1c97678c845..176f5dad8dc 100644 --- a/contracts/access/Roles.sol +++ b/contracts/access/Roles.sol @@ -13,8 +13,8 @@ library Roles { * @dev give an account access to this role */ function add(Role storage role, address account) internal { - require(account != address(0)); - require(!has(role, account)); + require(account != address(0), "from OpenZeppelin's:Roles.sol:add(). account cannot be address(0)"); + require(!has(role, account), "from OpenZeppelin's:Roles.sol:add() . account already has this role."); role.bearer[account] = true; } @@ -23,8 +23,8 @@ library Roles { * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { - require(account != address(0)); - require(has(role, account)); + require(account != address(0), "from OpenZeppelin's:Roles.sol:remove(). account cannot be address(0)"); + require(has(role, account), "from OpenZeppelin's:Roles.sol:remove(). account doesn't have this role."); role.bearer[account] = false; } @@ -34,7 +34,7 @@ library Roles { * @return bool */ function has(Role storage role, address account) internal view returns (bool) { - require(account != address(0)); + require(account != address(0), "from OpenZeppelin's:Roles.sol:has(). account cannot be address(0)"); return role.bearer[account]; } } diff --git a/contracts/access/roles/CapperRole.sol b/contracts/access/roles/CapperRole.sol index a6d9da06cb1..1343939722d 100644 --- a/contracts/access/roles/CapperRole.sol +++ b/contracts/access/roles/CapperRole.sol @@ -15,7 +15,7 @@ contract CapperRole { } modifier onlyCapper() { - require(isCapper(msg.sender)); + require(isCapper(msg.sender), "from OpenZeppelin's:CapperRole.sol:onlyCapper()."); _; } diff --git a/contracts/access/roles/MinterRole.sol b/contracts/access/roles/MinterRole.sol index 23d16c04290..327ccfa8a6b 100644 --- a/contracts/access/roles/MinterRole.sol +++ b/contracts/access/roles/MinterRole.sol @@ -15,7 +15,7 @@ contract MinterRole { } modifier onlyMinter() { - require(isMinter(msg.sender)); + require(isMinter(msg.sender), "from OpenZeppelin's:MinterRole.sol:onlyMinter()."); _; } diff --git a/contracts/access/roles/PauserRole.sol b/contracts/access/roles/PauserRole.sol index 073a08e414d..95488afcb50 100644 --- a/contracts/access/roles/PauserRole.sol +++ b/contracts/access/roles/PauserRole.sol @@ -15,7 +15,7 @@ contract PauserRole { } modifier onlyPauser() { - require(isPauser(msg.sender)); + require(isPauser(msg.sender), "from OpenZeppelin's:PauserRole.sol:onlyPauser()."); _; } diff --git a/contracts/access/roles/SignerRole.sol b/contracts/access/roles/SignerRole.sol index 91bb59c2e3b..9be6752197d 100644 --- a/contracts/access/roles/SignerRole.sol +++ b/contracts/access/roles/SignerRole.sol @@ -15,7 +15,7 @@ contract SignerRole { } modifier onlySigner() { - require(isSigner(msg.sender)); + require(isSigner(msg.sender), "from OpenZeppelin's:SignerRole.sol:onlySigner()."); _; } diff --git a/contracts/access/roles/WhitelistAdminRole.sol b/contracts/access/roles/WhitelistAdminRole.sol index e5f0883d9ae..223d904db14 100644 --- a/contracts/access/roles/WhitelistAdminRole.sol +++ b/contracts/access/roles/WhitelistAdminRole.sol @@ -19,7 +19,7 @@ contract WhitelistAdminRole { } modifier onlyWhitelistAdmin() { - require(isWhitelistAdmin(msg.sender)); + require(isWhitelistAdmin(msg.sender), "from OpenZeppelin's:WhitelistAdminRole.sol:onlyWhitelistAdmin()."); _; } diff --git a/contracts/access/roles/WhitelistedRole.sol b/contracts/access/roles/WhitelistedRole.sol index 89cf357f9ea..180289a9b3d 100644 --- a/contracts/access/roles/WhitelistedRole.sol +++ b/contracts/access/roles/WhitelistedRole.sol @@ -18,7 +18,7 @@ contract WhitelistedRole is WhitelistAdminRole { Roles.Role private _whitelisteds; modifier onlyWhitelisted() { - require(isWhitelisted(msg.sender)); + require(isWhitelisted(msg.sender), "from OpenZeppelin's:WhitelistedRole.sol:onlyWhitelisted()."); _; } diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 6b1c0a64206..5d1cfcba6f2 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -54,9 +54,9 @@ contract Crowdsale is ReentrancyGuard { * @param token Address of the token being sold */ constructor (uint256 rate, address payable wallet, IERC20 token) public { - require(rate > 0); - require(wallet != address(0)); - require(address(token) != address(0)); + require(rate > 0, "from OpenZeppelin's:Crowdsale.sol:constructor(). rate <= 0."); + require(wallet != address(0), "from OpenZeppelin's:Crowdsale.sol:constructor(). wallet cannot be address(0)."); + require(address(token) != address(0), "from OpenZeppelin's:Crowdsale.sol:constructor(). token address cannot be address(0)."); _rate = rate; _wallet = wallet; @@ -136,8 +136,8 @@ contract Crowdsale is ReentrancyGuard { * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - require(beneficiary != address(0)); - require(weiAmount != 0); + require(beneficiary != address(0), "from OpenZeppelin's:Crowdsale.sol:_preValidatePurchase(). beneficiary address cannot be address(0."); + require(weiAmount != 0, "from OpenZeppelin's:Crowdsale.sol:_preValidatePurchase(). weiAmount = 0."); } /** diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index 9058f70ad59..7d3fc4129fa 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -31,8 +31,8 @@ contract FinalizableCrowdsale is TimedCrowdsale { * work. Calls the contract's finalization function. */ function finalize() public { - require(!_finalized); - require(hasClosed()); + require(!_finalized, "from OpenZeppelin's:FinalizableCrowdsale.sol:finalize(). _finalized is true."); + require(hasClosed(), "from OpenZeppelin's:FinalizableCrowdsale.sol:finalize(). hasClosed() is false."); _finalized = true; diff --git a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol index 151b1a62498..59437d7f38f 100644 --- a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol @@ -17,9 +17,9 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { - require(hasClosed()); + require(hasClosed(), "from OpenZeppelin's:PostDeliveryCrowdsale.sol:withdrawTokens(). hasClosed() is false."); uint256 amount = _balances[beneficiary]; - require(amount > 0); + require(amount > 0, "from OpenZeppelin's:PostDeliveryCrowdsale.sol:withdrawTokens(). amount is <= 0."); _balances[beneficiary] = 0; _deliverTokens(beneficiary, amount); } diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index 21e736fde7f..9ee13be5123 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -28,7 +28,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param goal Funding goal */ constructor (uint256 goal) public { - require(goal > 0); + require(goal > 0, "from OpenZeppelin's:RefundableCrowdsale.sol:constructor()."); _escrow = new RefundEscrow(wallet()); _goal = goal; } @@ -45,8 +45,8 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param refundee Whose refund will be claimed. */ function claimRefund(address payable refundee) public { - require(finalized()); - require(!goalReached()); + require(finalized(), "from OpenZeppelin's:RefundableCrowdsale.sol:claimRefund(). Call to finalized() returned false."); + require(!goalReached(), "from OpenZeppelin's:RefundableCrowdsale.sol:claimRefund(). Call to goalReached() returned true."); _escrow.withdraw(refundee); } diff --git a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol index 0dd351ed549..1626a162466 100644 --- a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol @@ -12,8 +12,8 @@ import "./PostDeliveryCrowdsale.sol"; */ contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale { function withdrawTokens(address beneficiary) public { - require(finalized()); - require(goalReached()); + require(finalized(), "from OpenZeppelin's:RefundablePostDeliveryCrowdsale.sol:withdrawTokens(). Call to finalized() returned false."); + require(goalReached(), "from OpenZeppelin's:RefundablePostDeliveryCrowdsale.sol:withdrawTokens(). Call to goalReached() returned false."); super.withdrawTokens(beneficiary); } diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index e7f545f5a03..ffb1b4d683e 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -21,7 +21,7 @@ contract AllowanceCrowdsale is Crowdsale { * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale */ constructor (address tokenWallet) public { - require(tokenWallet != address(0)); + require(tokenWallet != address(0), "from OpenZeppelin's:AllowanceCrowdsale.sol:constructor()."); _tokenWallet = tokenWallet; } diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index b6b07ec8e46..bdd9bafca7b 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -16,6 +16,6 @@ contract MintedCrowdsale is Crowdsale { */ function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { // Potentially dangerous assumption about the type of the token. - require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount)); + require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), "from OpenZeppelin's:MintedCrowdsale.sol:_deliverTokens()."); } } diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 446b41d2e72..98c54c4a6ad 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -21,8 +21,8 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale */ constructor (uint256 initialRate, uint256 finalRate) public { - require(finalRate > 0); - require(initialRate > finalRate); + require(finalRate > 0, "from OpenZeppelin's:IncreasingPriceCrowdsale.sol:constructor(). finalRate = 0."); + require(initialRate > finalRate, "from OpenZeppelin's:IncreasingPriceCrowdsale.sol:constructor(). initialRate < finalRate."); _initialRate = initialRate; _finalRate = finalRate; } diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 9de2fe125f4..c0621efa35e 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -17,7 +17,7 @@ contract CappedCrowdsale is Crowdsale { * @param cap Max amount of wei to be contributed */ constructor (uint256 cap) public { - require(cap > 0); + require(cap > 0, "from OpenZeppelin's:CappedCrowdsale.sol:constructor()."); _cap = cap; } @@ -43,6 +43,6 @@ contract CappedCrowdsale is Crowdsale { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); - require(weiRaised().add(weiAmount) <= _cap); + require(weiRaised().add(weiAmount) <= _cap, "from OpenZeppelin's:CappedCrowdsale.sol:_preValidatePurchase()."); } } diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 9c317e13b1d..33568f11b83 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -48,7 +48,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); - require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary]); + require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "from OpenZeppelin's:IndividuallyCappedCrowdsale.sol:_preValidatePurchase()."); } /** diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index f8505f6f006..218c1193b02 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -24,7 +24,7 @@ contract TimedCrowdsale is Crowdsale { * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { - require(isOpen()); + require(isOpen(), "from OpenZeppelin's:TimedCrowdsale.sol:onlyWhileOpen()."); _; } @@ -35,8 +35,8 @@ contract TimedCrowdsale is Crowdsale { */ constructor (uint256 openingTime, uint256 closingTime) public { // solhint-disable-next-line not-rely-on-time - require(openingTime >= block.timestamp); - require(closingTime > openingTime); + require(openingTime >= block.timestamp, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). openingTime < block.timestamp."); + require(closingTime > openingTime, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). closingTime <= openingTime."); _openingTime = openingTime; _closingTime = closingTime; @@ -87,8 +87,8 @@ contract TimedCrowdsale is Crowdsale { * @param newClosingTime Crowdsale closing time */ function _extendTime(uint256 newClosingTime) internal { - require(!hasClosed()); - require(newClosingTime > _closingTime); + require(!hasClosed(), "from OpenZeppelin's:TimedCrowdsale.sol:_extendTime(). Crowdsale has already closed."); + require(newClosingTime > _closingTime, "from OpenZeppelin's:TimedCrowdsale.sol:_extendTime(). New closing time is < previous closing time."); emit TimedCrowdsaleExtended(_closingTime, newClosingTime); _closingTime = newClosingTime; diff --git a/contracts/crowdsale/validation/WhitelistCrowdsale.sol b/contracts/crowdsale/validation/WhitelistCrowdsale.sol index 9453e4702b6..e7dd567b538 100644 --- a/contracts/crowdsale/validation/WhitelistCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistCrowdsale.sol @@ -15,7 +15,7 @@ contract WhitelistCrowdsale is WhitelistedRole, Crowdsale { * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { - require(isWhitelisted(_beneficiary)); + require(isWhitelisted(_beneficiary), "from OpenZeppelin's:WhitelistCrowdsale.sol:_preValidatePurchase()."); super._preValidatePurchase(_beneficiary, _weiAmount); } } diff --git a/contracts/drafts/ERC20Migrator.sol b/contracts/drafts/ERC20Migrator.sol index 18ad0df3a8b..8999ca2bbba 100644 --- a/contracts/drafts/ERC20Migrator.sol +++ b/contracts/drafts/ERC20Migrator.sol @@ -44,7 +44,7 @@ contract ERC20Migrator { * @param legacyToken address of the old token contract */ constructor (IERC20 legacyToken) public { - require(address(legacyToken) != address(0)); + require(address(legacyToken) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:constructor()."); _legacyToken = legacyToken; } @@ -68,9 +68,9 @@ contract ERC20Migrator { * @param newToken_ the token that will be minted */ function beginMigration(ERC20Mintable newToken_) public { - require(address(_newToken) == address(0)); - require(address(newToken_) != address(0)); - require(newToken_.isMinter(address(this))); + require(address(_newToken) == address(0), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). _newToken != address(0)"); + require(address(newToken_) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). newToken_ cannot be address(0)"); + require(newToken_.isMinter(address(this)), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). address(this) is not a minter for newToken_."); _newToken = newToken_; } @@ -82,7 +82,7 @@ contract ERC20Migrator { * @param amount amount of tokens to be migrated */ function migrate(address account, uint256 amount) public { - require(address(_newToken) != address(0)); + require(address(_newToken) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:migrate()."); _legacyToken.safeTransferFrom(account, address(this), amount); _newToken.mint(account, amount); } diff --git a/contracts/drafts/ERC20Snapshot.sol b/contracts/drafts/ERC20Snapshot.sol index 46836437c47..bd30bcde69f 100644 --- a/contracts/drafts/ERC20Snapshot.sol +++ b/contracts/drafts/ERC20Snapshot.sol @@ -101,8 +101,8 @@ contract ERC20Snapshot is ERC20 { function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { - require(snapshotId > 0); - require(snapshotId <= _currentSnapshotId.current()); + require(snapshotId > 0, "from OpenZeppelin's:ERC20Snapshot.sol:_valueAt(). snapshotId < = 0."); + require(snapshotId <= _currentSnapshotId.current(), "from OpenZeppelin's:ERC20Snapshot.sol:_valueAt(). snapshotId > current snapshotId."); uint256 index = snapshots.ids.findUpperBound(snapshotId); diff --git a/contracts/drafts/SignatureBouncer.sol b/contracts/drafts/SignatureBouncer.sol index 1fee257642f..b86ca869c03 100644 --- a/contracts/drafts/SignatureBouncer.sol +++ b/contracts/drafts/SignatureBouncer.sol @@ -51,7 +51,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature of a signer was provided */ modifier onlyValidSignature(bytes memory signature) { - require(_isValidSignature(msg.sender, signature)); + require(_isValidSignature(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignature()."); _; } @@ -59,7 +59,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature with a specified method of a signer was provided */ modifier onlyValidSignatureAndMethod(bytes memory signature) { - require(_isValidSignatureAndMethod(msg.sender, signature)); + require(_isValidSignatureAndMethod(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignatureAndMethod()."); _; } @@ -67,7 +67,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature with a specified method and params of a signer was provided */ modifier onlyValidSignatureAndData(bytes memory signature) { - require(_isValidSignatureAndData(msg.sender, signature)); + require(_isValidSignatureAndData(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignatureAndData()."); _; } @@ -97,7 +97,7 @@ contract SignatureBouncer is SignerRole { * @return bool */ function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) { - require(msg.data.length > _SIGNATURE_SIZE); + require(msg.data.length > _SIGNATURE_SIZE, "from OpenZeppelin's:SignatureBouncer.sol:_isValidSignatureAndData()."); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { diff --git a/contracts/drafts/SignedSafeMath.sol b/contracts/drafts/SignedSafeMath.sol index b969e1f74b7..9c7377bf0bb 100644 --- a/contracts/drafts/SignedSafeMath.sol +++ b/contracts/drafts/SignedSafeMath.sol @@ -18,10 +18,10 @@ library SignedSafeMath { return 0; } - require(!(a == -1 && b == INT256_MIN)); // This is the only case of overflow not detected by the check below + require(!(a == -1 && b == INT256_MIN), "from OpenZeppelin's:SignedSafeMath.sol:mul(). Detected overflow."); // This is the only case of overflow not detected by the check below int256 c = a * b; - require(c / a == b); + require(c / a == b, "from OpenZeppelin's:SignedSafeMath.sol:mul(). c/a != b. "); return c; } @@ -30,8 +30,8 @@ library SignedSafeMath { * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. */ function div(int256 a, int256 b) internal pure returns (int256) { - require(b != 0); // Solidity only automatically asserts when dividing by 0 - require(!(b == -1 && a == INT256_MIN)); // This is the only case of overflow + require(b != 0, "from OpenZeppelin's:SignedSafeMath.sol:div(). Divide by zero error."); // Solidity only automatically asserts when dividing by 0 + require(!(b == -1 && a == INT256_MIN), "from OpenZeppelin's:SignedSafeMath.sol:div(). Detected overflow."); // This is the only case of overflow int256 c = a / b; @@ -43,7 +43,7 @@ library SignedSafeMath { */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; - require((b >= 0 && c <= a) || (b < 0 && c > a)); + require((b >= 0 && c <= a) || (b < 0 && c > a), "from OpenZeppelin's:SignedSafeMath.sol:sub()."); return c; } @@ -53,7 +53,7 @@ library SignedSafeMath { */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; - require((b >= 0 && c >= a) || (b < 0 && c < a)); + require((b >= 0 && c >= a) || (b < 0 && c < a), "from OpenZeppelin's:SignedSafeMath.sol:add()."); return c; } diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index 636f94bf17d..f400d31f949 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -47,10 +47,10 @@ contract TokenVesting is Ownable { * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { - require(beneficiary != address(0)); - require(cliffDuration <= duration); - require(duration > 0); - require(start.add(duration) > block.timestamp); + require(beneficiary != address(0), "from OpenZeppelin's:TokenVesting.sol:constructor(). beneficiary is address(0)."); + require(cliffDuration <= duration, "from OpenZeppelin's:TokenVesting.sol:constructor(). cliffDuration > duration."); + require(duration > 0, "from OpenZeppelin's:TokenVesting.sol:constructor(). duration <= 0."); + require(start.add(duration) > block.timestamp, "from OpenZeppelin's:TokenVesting.sol:constructor(). start.add(duration) < block.timestamp."); _beneficiary = beneficiary; _revocable = revocable; @@ -115,7 +115,7 @@ contract TokenVesting is Ownable { function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); - require(unreleased > 0); + require(unreleased > 0, "from OpenZeppelin's:TokenVesting.sol:release()."); _released[address(token)] = _released[address(token)].add(unreleased); @@ -130,8 +130,8 @@ contract TokenVesting is Ownable { * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { - require(_revocable); - require(!_revoked[address(token)]); + require(_revocable, "from OpenZeppelin's:TokenVesting.sol:revoke(). _revocable is false."); + require(!_revoked[address(token)], "from OpenZeppelin's:TokenVesting.sol:revoke(). Token vesting already revoked."); uint256 balance = token.balanceOf(address(this)); diff --git a/contracts/examples/SampleCrowdsale.sol b/contracts/examples/SampleCrowdsale.sol index ac8aac11dec..77a1cc0daed 100644 --- a/contracts/examples/SampleCrowdsale.sol +++ b/contracts/examples/SampleCrowdsale.sol @@ -48,6 +48,6 @@ contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsal { //As goal needs to be met for a successful crowdsale //the value needs to less or equal than a cap which is limit for accepted funds - require(goal <= cap); + require(goal <= cap, "from OpenZeppelin's:SampleCrowdsale.sol:constructor()."); } } diff --git a/contracts/introspection/ERC165.sol b/contracts/introspection/ERC165.sol index 3bc0f2db912..0130934dc7c 100644 --- a/contracts/introspection/ERC165.sol +++ b/contracts/introspection/ERC165.sol @@ -38,7 +38,7 @@ contract ERC165 is IERC165 { * @dev internal method for registering an interface */ function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff); + require(interfaceId != 0xffffffff, "from OpenZeppelin's:ERC165.sol:_registerInterface()."); _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index a1a715f5122..ef2186c5471 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -27,7 +27,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { - require(!_paused); + require(!_paused, "from OpenZeppelin's:Pausable.sol:whenNotPaused()."); _; } @@ -35,7 +35,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { - require(_paused); + require(_paused, "from OpenZeppelin's:Pausable.sol:whenPaused()."); _; } diff --git a/contracts/math/SafeMath.sol b/contracts/math/SafeMath.sol index 5dd4bb903d0..73dbb166659 100644 --- a/contracts/math/SafeMath.sol +++ b/contracts/math/SafeMath.sol @@ -17,7 +17,7 @@ library SafeMath { } uint256 c = a * b; - require(c / a == b); + require(c / a == b, "from OpenZeppelin's:SafeMath.sol:mul()."); return c; } @@ -27,7 +27,7 @@ library SafeMath { */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 - require(b > 0); + require(b > 0, "from OpenZeppelin's:SafeMath.sol:div()."); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold @@ -38,7 +38,7 @@ library SafeMath { * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { - require(b <= a); + require(b <= a, "from OpenZeppelin's:SafeMath.sol:sub()."); uint256 c = a - b; return c; @@ -49,7 +49,7 @@ library SafeMath { */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; - require(c >= a); + require(c >= a, "from OpenZeppelin's:SafeMath.sol:add()."); return c; } @@ -59,7 +59,7 @@ library SafeMath { * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { - require(b != 0); + require(b != 0, "from OpenZeppelin's:SafeMath.sol:mod()."); return a % b; } } diff --git a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol index 205df0bb1ad..c50bdb0bd9e 100644 --- a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +++ b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol @@ -43,7 +43,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { * @dev private method for registering an interface */ function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff); + require(interfaceId != 0xffffffff, "from OpenZeppelin's:ERC165InterfacesSupported.sol:_registerInterface()."); _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/mocks/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index 7dd9d3ee6c4..fa91e0e1d2f 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -16,7 +16,7 @@ contract ERC721ReceiverMock is IERC721Receiver { function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4) { - require(!_reverts); + require(!_reverts, "from OpenZeppelin's:ERC721ReceiverMock.sol:onERC721Received()."); emit Received(operator, from, tokenId, data, gasleft()); return _retval; } diff --git a/contracts/mocks/ReentrancyAttack.sol b/contracts/mocks/ReentrancyAttack.sol index 7f7fd35d4db..d0bc76c1182 100644 --- a/contracts/mocks/ReentrancyAttack.sol +++ b/contracts/mocks/ReentrancyAttack.sol @@ -4,6 +4,6 @@ contract ReentrancyAttack { function callSender(bytes4 data) public { // solhint-disable-next-line avoid-low-level-calls (bool success,) = msg.sender.call(abi.encodeWithSelector(data)); - require(success); + require(success, "from OpenZeppelin's:ReentrancyAttack.sol:callSender()."); } } diff --git a/contracts/mocks/ReentrancyMock.sol b/contracts/mocks/ReentrancyMock.sol index bf14a8f3504..a8dbf6fe357 100644 --- a/contracts/mocks/ReentrancyMock.sol +++ b/contracts/mocks/ReentrancyMock.sol @@ -26,7 +26,7 @@ contract ReentrancyMock is ReentrancyGuard { count(); // solhint-disable-next-line avoid-low-level-calls (bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); - require(success); + require(success, "from OpenZeppelin's:ReentrancyMock.sol:countThisRecursive()."); } } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index b69d98b528e..fd7c483fa09 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -26,7 +26,7 @@ contract ERC20ReturnFalseMock { } function allowance(address, address) public view returns (uint256) { - require(_dummy == 0); + require(_dummy == 0, "from OpenZeppelin's:SafeERC20Helper.sol:allowance()."); return 0; } } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 9780c07fd26..ab1286e7fb7 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -30,7 +30,7 @@ contract Ownable { * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { - require(isOwner()); + require(isOwner(), "from OpenZeppelin's:Ownable.sol:onlyOwner()."); _; } @@ -66,7 +66,7 @@ contract Ownable { * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { - require(newOwner != address(0)); + require(newOwner != address(0), "from OpenZeppelin's:Ownable.sol:_transferOwnership()."); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } diff --git a/contracts/ownership/Secondary.sol b/contracts/ownership/Secondary.sol index 93ed425e444..3b31fdc3490 100644 --- a/contracts/ownership/Secondary.sol +++ b/contracts/ownership/Secondary.sol @@ -23,7 +23,7 @@ contract Secondary { * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { - require(msg.sender == _primary); + require(msg.sender == _primary, "from OpenZeppelin's:Secondary.sol:onlyPrimary()."); _; } @@ -39,7 +39,7 @@ contract Secondary { * @param recipient The address of new primary. */ function transferPrimary(address recipient) public onlyPrimary { - require(recipient != address(0)); + require(recipient != address(0), "from OpenZeppelin's:Secondary.sol:transferPrimary()."); _primary = recipient; emit PrimaryTransferred(_primary); } diff --git a/contracts/payment/PaymentSplitter.sol b/contracts/payment/PaymentSplitter.sol index f7e56389ef4..2e25d84b2f3 100644 --- a/contracts/payment/PaymentSplitter.sol +++ b/contracts/payment/PaymentSplitter.sol @@ -25,8 +25,8 @@ contract PaymentSplitter { * @dev Constructor */ constructor (address[] memory payees, uint256[] memory shares) public payable { - require(payees.length == shares.length); - require(payees.length > 0); + require(payees.length == shares.length, "from OpenZeppelin's:PaymentSplitter.sol:constructor(). payees.length != shares.length."); + require(payees.length > 0, "from OpenZeppelin's:PaymentSplitter.sol:constructor(). payees.length <= 0."); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares[i]); @@ -80,12 +80,12 @@ contract PaymentSplitter { * @param account Whose payments will be released. */ function release(address payable account) public { - require(_shares[account] > 0); + require(_shares[account] > 0, "from OpenZeppelin's:PaymentSplitter.sol:release(). _shares[account] <= 0."); uint256 totalReceived = address(this).balance.add(_totalReleased); uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); - require(payment != 0); + require(payment != 0, "from OpenZeppelin's:PaymentSplitter.sol:release(). payment is 0."); _released[account] = _released[account].add(payment); _totalReleased = _totalReleased.add(payment); @@ -100,9 +100,9 @@ contract PaymentSplitter { * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { - require(account != address(0)); - require(shares_ > 0); - require(_shares[account] == 0); + require(account != address(0), "from OpenZeppelin's:PaymentSplitter.sol:_addPayee(). account is address(0)."); + require(shares_ > 0, "from OpenZeppelin's:PaymentSplitter.sol:_addPayee(). shares_ <= 0."); + require(_shares[account] == 0, "from OpenZeppelin's:PaymentSplitter.sol:_addPayee(). _shares[account] != 0."); _payees.push(account); _shares[account] = shares_; diff --git a/contracts/payment/escrow/ConditionalEscrow.sol b/contracts/payment/escrow/ConditionalEscrow.sol index 4b221379219..d6c537dcd2b 100644 --- a/contracts/payment/escrow/ConditionalEscrow.sol +++ b/contracts/payment/escrow/ConditionalEscrow.sol @@ -16,7 +16,7 @@ contract ConditionalEscrow is Escrow { function withdrawalAllowed(address payee) public view returns (bool); function withdraw(address payable payee) public { - require(withdrawalAllowed(payee)); + require(withdrawalAllowed(payee), "from OpenZeppelin's:ConditionalEscrow.sol:withdraw()."); super.withdraw(payee); } } diff --git a/contracts/payment/escrow/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol index 8c3904779fc..29418056593 100644 --- a/contracts/payment/escrow/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -27,7 +27,7 @@ contract RefundEscrow is ConditionalEscrow { * @param beneficiary The beneficiary of the deposits. */ constructor (address payable beneficiary) public { - require(beneficiary != address(0)); + require(beneficiary != address(0), "from OpenZeppelin's:RefundEscrow.sol:constructor()."); _beneficiary = beneficiary; _state = State.Active; } @@ -51,7 +51,7 @@ contract RefundEscrow is 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, "from OpenZeppelin's:RefundEscrow.sol:deposit()."); super.deposit(refundee); } @@ -60,7 +60,7 @@ contract RefundEscrow is ConditionalEscrow { * further deposits. */ function close() public onlyPrimary { - require(_state == State.Active); + require(_state == State.Active, "from OpenZeppelin's:RefundEscrow.sol:close()."); _state = State.Closed; emit RefundsClosed(); } @@ -69,7 +69,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Allows for refunds to take place, rejecting further deposits. */ function enableRefunds() public onlyPrimary { - require(_state == State.Active); + require(_state == State.Active, "from OpenZeppelin's:RefundEscrow.sol:enableRefunds()."); _state = State.Refunding; emit RefundsEnabled(); } @@ -78,7 +78,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Withdraws the beneficiary's funds. */ function beneficiaryWithdraw() public { - require(_state == State.Closed); + require(_state == State.Closed, "from OpenZeppelin's:RefundEscrow.sol:beneficiaryWithdraw()."); _beneficiary.transfer(address(this).balance); } diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 81bd49fe518..e269aaa8652 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0)); + require(to != address(0), "from OpenZeppelin's:ERC20.sol:_transfer()."); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0)); + require(account != address(0), "from OpenZeppelin's:ERC20.sol:_mint()."); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0)); + require(account != address(0), "from OpenZeppelin's:ERC20.sol:_burn()."); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0)); - require(owner != address(0)); + require(spender != address(0), "from OpenZeppelin's:ERC20.sol:_approve(). spender is address(0)."); + require(owner != address(0), "from OpenZeppelin's:ERC20.sol:_approve(). owner is address(0)."); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index 56964bc3534..c9261fccf8e 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -10,7 +10,7 @@ contract ERC20Capped is ERC20Mintable { uint256 private _cap; constructor (uint256 cap) public { - require(cap > 0); + require(cap > 0, "from OpenZeppelin's:ERC20Capped.sol:constructor()."); _cap = cap; } @@ -22,7 +22,7 @@ contract ERC20Capped is ERC20Mintable { } function _mint(address account, uint256 value) internal { - require(totalSupply().add(value) <= _cap); + require(totalSupply().add(value) <= _cap, "from OpenZeppelin's:ERC20Capped.sol:_mint()."); super._mint(account, value); } } diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 4aaf43cd2f0..add0095bd2f 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -29,7 +29,7 @@ library SafeERC20 { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' - require((value == 0) || (token.allowance(address(this), spender) == 0)); + require((value == 0) || (token.allowance(address(this), spender) == 0), "from OpenZeppelin's:SafeERC20.sol:safeApprove()."); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } @@ -58,14 +58,14 @@ library SafeERC20 { // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. - require(address(token).isContract()); + require(address(token).isContract(), "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). token address is not a contract address."); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); - require(success); + require(success, "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). Low-level call() returned false."); if (returndata.length > 0) { // Return data is optional - require(abi.decode(returndata, (bool))); + require(abi.decode(returndata, (bool)), "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). abi.decode()"); } } } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 0d8a052c602..02b23ea7e42 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -21,7 +21,7 @@ contract TokenTimelock { constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { // solhint-disable-next-line not-rely-on-time - require(releaseTime > block.timestamp); + require(releaseTime > block.timestamp, "from OpenZeppelin's:TokenTimelock.sol:constructor()."); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime; @@ -53,10 +53,10 @@ contract TokenTimelock { */ function release() public { // solhint-disable-next-line not-rely-on-time - require(block.timestamp >= _releaseTime); + require(block.timestamp >= _releaseTime, "from OpenZeppelin's:TokenTimelock.sol:release(). block.timestamp < _releaseTime."); uint256 amount = _token.balanceOf(address(this)); - require(amount > 0); + require(amount > 0, "from OpenZeppelin's:TokenTimelock.sol:release(). amount <= 0."); _token.safeTransfer(_beneficiary, amount); } diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 64db06e41a0..edc7039d53b 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0)); + require(owner != address(0), "from OpenZeppelin's:ERC721.sol:balanceOf()."); return _ownedTokensCount[owner].current(); } @@ -68,7 +68,7 @@ contract ERC721 is ERC165, IERC721 { */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; - require(owner != address(0)); + require(owner != address(0), "from OpenZeppelin's:ERC721.sol:ownerOf()."); return owner; } @@ -82,8 +82,8 @@ contract ERC721 is ERC165, IERC721 { */ function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); - require(to != owner); - require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); + require(to != owner, "from OpenZeppelin's:ERC721.sol:approve(). to == owner."); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "from OpenZeppelin's:ERC721.sol:approve(). msg.sender is neither the owner nor an approved account."); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); @@ -96,7 +96,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId)); + require(_exists(tokenId), "from OpenZeppelin's:ERC721.sol:getApproved()."); return _tokenApprovals[tokenId]; } @@ -107,7 +107,7 @@ contract ERC721 is ERC165, IERC721 { * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { - require(to != msg.sender); + require(to != msg.sender, "from OpenZeppelin's:ERC721.sol:setApprovalForAll()."); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } @@ -131,7 +131,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId)); + require(_isApprovedOrOwner(msg.sender, tokenId), "from OpenZeppelin's:ERC721.sol:transferFrom()."); _transferFrom(from, to, tokenId); } @@ -165,7 +165,7 @@ contract ERC721 is ERC165, IERC721 { */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); - require(_checkOnERC721Received(from, to, tokenId, _data)); + require(_checkOnERC721Received(from, to, tokenId, _data), "from OpenZeppelin's:ERC721.sol:safeTransferFrom()."); } /** @@ -197,8 +197,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0)); - require(!_exists(tokenId)); + require(to != address(0), "from OpenZeppelin's:ERC721.sol:_mint(). to == address(0)."); + require(!_exists(tokenId), "from OpenZeppelin's:ERC721.sol:_mint(). _exists(tokenId) is true."); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); @@ -214,7 +214,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner); + require(ownerOf(tokenId) == owner, "from OpenZeppelin's:ERC721.sol:_burn()."); _clearApproval(tokenId); @@ -241,8 +241,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from); - require(to != address(0)); + require(ownerOf(tokenId) == from, "from OpenZeppelin's:ERC721.sol:_transferFrom(). ownerOf(tokenId) != from."); + require(to != address(0), "from OpenZeppelin's:ERC721.sol:_transferFrom(). to == address(0)."); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index e2dc6cf7724..af25b967ffa 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -12,7 +12,7 @@ contract ERC721Burnable is ERC721 { * @param tokenId uint256 id of the ERC721 token to be burned. */ function burn(uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId)); + require(_isApprovedOrOwner(msg.sender, tokenId), "from OpenZeppelin's:ERC721Burnable.sol:burn()."); _burn(tokenId); } } diff --git a/contracts/token/ERC721/ERC721Enumerable.sol b/contracts/token/ERC721/ERC721Enumerable.sol index 0b5fd9c0979..93c535e110e 100644 --- a/contracts/token/ERC721/ERC721Enumerable.sol +++ b/contracts/token/ERC721/ERC721Enumerable.sol @@ -44,7 +44,7 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { * @return uint256 token ID at the given index of the tokens list owned by the requested address */ function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { - require(index < balanceOf(owner)); + require(index < balanceOf(owner), "from OpenZeppelin's:ERC721Enumerable.sol:tokenOfOwnerByIndex()."); return _ownedTokens[owner][index]; } @@ -63,7 +63,7 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { * @return uint256 token ID at the given index of the tokens list */ function tokenByIndex(uint256 index) public view returns (uint256) { - require(index < totalSupply()); + require(index < totalSupply(), "from OpenZeppelin's:ERC721Enumerable.sol:tokenByIndex()."); return _allTokens[index]; } diff --git a/contracts/token/ERC721/ERC721Metadata.sol b/contracts/token/ERC721/ERC721Metadata.sol index 0da71d0bf20..6b943593979 100644 --- a/contracts/token/ERC721/ERC721Metadata.sol +++ b/contracts/token/ERC721/ERC721Metadata.sol @@ -55,7 +55,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId)); + require(_exists(tokenId), "from OpenZeppelin's:ERC721Metadata.sol:tokenURI()."); return _tokenURIs[tokenId]; } @@ -66,7 +66,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { - require(_exists(tokenId)); + require(_exists(tokenId), "from OpenZeppelin's:ERC721Metadata.sol:_setTokenURI()."); _tokenURIs[tokenId] = uri; } diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol index 36186d1ed52..891c10a88ee 100644 --- a/contracts/utils/ReentrancyGuard.sol +++ b/contracts/utils/ReentrancyGuard.sol @@ -27,6 +27,6 @@ contract ReentrancyGuard { _guardCounter += 1; uint256 localCounter = _guardCounter; _; - require(localCounter == _guardCounter); + require(localCounter == _guardCounter, "from OpenZeppelin's:ReentrancyGuard.sol:nonReentrant()."); } } From 111b790d811e376c6f59509d6b01482d3fd063f9 Mon Sep 17 00:00:00 2001 From: balajipachai Date: Tue, 2 Apr 2019 00:36:43 +0530 Subject: [PATCH 03/20] Fixed solhint errors. --- contracts/crowdsale/Crowdsale.sol | 2 ++ contracts/crowdsale/distribution/RefundableCrowdsale.sol | 2 ++ .../distribution/RefundablePostDeliveryCrowdsale.sol | 2 ++ contracts/crowdsale/emission/MintedCrowdsale.sol | 1 + contracts/crowdsale/price/IncreasingPriceCrowdsale.sol | 1 + .../crowdsale/validation/IndividuallyCappedCrowdsale.sol | 1 + contracts/crowdsale/validation/TimedCrowdsale.sol | 5 ++++- contracts/drafts/ERC20Migrator.sol | 3 +++ contracts/drafts/ERC20Snapshot.sol | 1 + contracts/drafts/SignatureBouncer.sol | 4 ++++ contracts/drafts/SignedSafeMath.sol | 3 +++ contracts/drafts/TokenVesting.sol | 4 ++++ contracts/payment/PaymentSplitter.sol | 1 + contracts/token/ERC20/SafeERC20.sol | 4 +++- contracts/token/ERC20/TokenTimelock.sol | 3 ++- contracts/token/ERC721/ERC721.sol | 1 + 16 files changed, 35 insertions(+), 3 deletions(-) diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 5d1cfcba6f2..5fbe6119d3d 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -56,6 +56,7 @@ contract Crowdsale is ReentrancyGuard { constructor (uint256 rate, address payable wallet, IERC20 token) public { require(rate > 0, "from OpenZeppelin's:Crowdsale.sol:constructor(). rate <= 0."); require(wallet != address(0), "from OpenZeppelin's:Crowdsale.sol:constructor(). wallet cannot be address(0)."); + // solhint-disable-next-line max-line-length require(address(token) != address(0), "from OpenZeppelin's:Crowdsale.sol:constructor(). token address cannot be address(0)."); _rate = rate; @@ -136,6 +137,7 @@ contract Crowdsale is ReentrancyGuard { * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { + // solhint-disable-next-line max-line-length require(beneficiary != address(0), "from OpenZeppelin's:Crowdsale.sol:_preValidatePurchase(). beneficiary address cannot be address(0."); require(weiAmount != 0, "from OpenZeppelin's:Crowdsale.sol:_preValidatePurchase(). weiAmount = 0."); } diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index 9ee13be5123..89d7737dd41 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -45,7 +45,9 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param refundee Whose refund will be claimed. */ function claimRefund(address payable refundee) public { + // solhint-disable-next-line max-line-length require(finalized(), "from OpenZeppelin's:RefundableCrowdsale.sol:claimRefund(). Call to finalized() returned false."); + // solhint-disable-next-line max-line-length require(!goalReached(), "from OpenZeppelin's:RefundableCrowdsale.sol:claimRefund(). Call to goalReached() returned true."); _escrow.withdraw(refundee); diff --git a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol index 1626a162466..32eefe7fb67 100644 --- a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol @@ -12,7 +12,9 @@ import "./PostDeliveryCrowdsale.sol"; */ contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale { function withdrawTokens(address beneficiary) public { + // solhint-disable-next-line max-line-length require(finalized(), "from OpenZeppelin's:RefundablePostDeliveryCrowdsale.sol:withdrawTokens(). Call to finalized() returned false."); + // solhint-disable-next-line max-line-length require(goalReached(), "from OpenZeppelin's:RefundablePostDeliveryCrowdsale.sol:withdrawTokens(). Call to goalReached() returned false."); super.withdrawTokens(beneficiary); diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index bdd9bafca7b..defdff6c440 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -16,6 +16,7 @@ contract MintedCrowdsale is Crowdsale { */ function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { // Potentially dangerous assumption about the type of the token. + // solhint-disable-next-line max-line-length require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), "from OpenZeppelin's:MintedCrowdsale.sol:_deliverTokens()."); } } diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 98c54c4a6ad..0c20fba4392 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -22,6 +22,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { */ constructor (uint256 initialRate, uint256 finalRate) public { require(finalRate > 0, "from OpenZeppelin's:IncreasingPriceCrowdsale.sol:constructor(). finalRate = 0."); + // solhint-disable-next-line max-line-length require(initialRate > finalRate, "from OpenZeppelin's:IncreasingPriceCrowdsale.sol:constructor(). initialRate < finalRate."); _initialRate = initialRate; _finalRate = finalRate; diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 33568f11b83..90105d9fcb0 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -48,6 +48,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); + // solhint-disable-next-line max-line-length require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "from OpenZeppelin's:IndividuallyCappedCrowdsale.sol:_preValidatePurchase()."); } diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 218c1193b02..e2223097cc8 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -35,7 +35,9 @@ contract TimedCrowdsale is Crowdsale { */ constructor (uint256 openingTime, uint256 closingTime) public { // solhint-disable-next-line not-rely-on-time - require(openingTime >= block.timestamp, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). openingTime < block.timestamp."); + // solhint-disable-next-line max-line-length + require(openingTime >= block.timestamp, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). openingTime < block.timestamp."); + // solhint-disable-next-line max-line-length require(closingTime > openingTime, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). closingTime <= openingTime."); _openingTime = openingTime; @@ -88,6 +90,7 @@ contract TimedCrowdsale is Crowdsale { */ function _extendTime(uint256 newClosingTime) internal { require(!hasClosed(), "from OpenZeppelin's:TimedCrowdsale.sol:_extendTime(). Crowdsale has already closed."); + // solhint-disable-next-line max-line-length require(newClosingTime > _closingTime, "from OpenZeppelin's:TimedCrowdsale.sol:_extendTime(). New closing time is < previous closing time."); emit TimedCrowdsaleExtended(_closingTime, newClosingTime); diff --git a/contracts/drafts/ERC20Migrator.sol b/contracts/drafts/ERC20Migrator.sol index 8999ca2bbba..47ee917b5b8 100644 --- a/contracts/drafts/ERC20Migrator.sol +++ b/contracts/drafts/ERC20Migrator.sol @@ -68,8 +68,11 @@ contract ERC20Migrator { * @param newToken_ the token that will be minted */ function beginMigration(ERC20Mintable newToken_) public { + // solhint-disable-next-line max-line-length require(address(_newToken) == address(0), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). _newToken != address(0)"); + // solhint-disable-next-line max-line-length require(address(newToken_) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). newToken_ cannot be address(0)"); + // solhint-disable-next-line max-line-length require(newToken_.isMinter(address(this)), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). address(this) is not a minter for newToken_."); _newToken = newToken_; diff --git a/contracts/drafts/ERC20Snapshot.sol b/contracts/drafts/ERC20Snapshot.sol index bd30bcde69f..5fbdf6c8624 100644 --- a/contracts/drafts/ERC20Snapshot.sol +++ b/contracts/drafts/ERC20Snapshot.sol @@ -102,6 +102,7 @@ contract ERC20Snapshot is ERC20 { private view returns (bool, uint256) { require(snapshotId > 0, "from OpenZeppelin's:ERC20Snapshot.sol:_valueAt(). snapshotId < = 0."); + // solhint-disable-next-line max-line-length require(snapshotId <= _currentSnapshotId.current(), "from OpenZeppelin's:ERC20Snapshot.sol:_valueAt(). snapshotId > current snapshotId."); uint256 index = snapshots.ids.findUpperBound(snapshotId); diff --git a/contracts/drafts/SignatureBouncer.sol b/contracts/drafts/SignatureBouncer.sol index b86ca869c03..550a0daded6 100644 --- a/contracts/drafts/SignatureBouncer.sol +++ b/contracts/drafts/SignatureBouncer.sol @@ -51,6 +51,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature of a signer was provided */ modifier onlyValidSignature(bytes memory signature) { + // solhint-disable-next-line max-line-length require(_isValidSignature(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignature()."); _; } @@ -59,6 +60,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature with a specified method of a signer was provided */ modifier onlyValidSignatureAndMethod(bytes memory signature) { + // solhint-disable-next-line max-line-length require(_isValidSignatureAndMethod(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignatureAndMethod()."); _; } @@ -67,6 +69,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature with a specified method and params of a signer was provided */ modifier onlyValidSignatureAndData(bytes memory signature) { + // solhint-disable-next-line max-line-length require(_isValidSignatureAndData(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignatureAndData()."); _; } @@ -97,6 +100,7 @@ contract SignatureBouncer is SignerRole { * @return bool */ function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) { + // solhint-disable-next-line max-line-length require(msg.data.length > _SIGNATURE_SIZE, "from OpenZeppelin's:SignatureBouncer.sol:_isValidSignatureAndData()."); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); diff --git a/contracts/drafts/SignedSafeMath.sol b/contracts/drafts/SignedSafeMath.sol index 9c7377bf0bb..cbb4ec17935 100644 --- a/contracts/drafts/SignedSafeMath.sol +++ b/contracts/drafts/SignedSafeMath.sol @@ -18,6 +18,7 @@ library SignedSafeMath { return 0; } + // solhint-disable-next-line max-line-length require(!(a == -1 && b == INT256_MIN), "from OpenZeppelin's:SignedSafeMath.sol:mul(). Detected overflow."); // This is the only case of overflow not detected by the check below int256 c = a * b; @@ -30,7 +31,9 @@ library SignedSafeMath { * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. */ function div(int256 a, int256 b) internal pure returns (int256) { + // solhint-disable-next-line max-line-length require(b != 0, "from OpenZeppelin's:SignedSafeMath.sol:div(). Divide by zero error."); // Solidity only automatically asserts when dividing by 0 + // solhint-disable-next-line max-line-length require(!(b == -1 && a == INT256_MIN), "from OpenZeppelin's:SignedSafeMath.sol:div(). Detected overflow."); // This is the only case of overflow int256 c = a / b; diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index f400d31f949..b145b922bb6 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -47,9 +47,12 @@ contract TokenVesting is Ownable { * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { + // solhint-disable-next-line max-line-length require(beneficiary != address(0), "from OpenZeppelin's:TokenVesting.sol:constructor(). beneficiary is address(0)."); + // solhint-disable-next-line max-line-length require(cliffDuration <= duration, "from OpenZeppelin's:TokenVesting.sol:constructor(). cliffDuration > duration."); require(duration > 0, "from OpenZeppelin's:TokenVesting.sol:constructor(). duration <= 0."); + // solhint-disable-next-line max-line-length require(start.add(duration) > block.timestamp, "from OpenZeppelin's:TokenVesting.sol:constructor(). start.add(duration) < block.timestamp."); _beneficiary = beneficiary; @@ -131,6 +134,7 @@ contract TokenVesting is Ownable { */ function revoke(IERC20 token) public onlyOwner { require(_revocable, "from OpenZeppelin's:TokenVesting.sol:revoke(). _revocable is false."); + // solhint-disable-next-line max-line-length require(!_revoked[address(token)], "from OpenZeppelin's:TokenVesting.sol:revoke(). Token vesting already revoked."); uint256 balance = token.balanceOf(address(this)); diff --git a/contracts/payment/PaymentSplitter.sol b/contracts/payment/PaymentSplitter.sol index 2e25d84b2f3..2a0e4324aa5 100644 --- a/contracts/payment/PaymentSplitter.sol +++ b/contracts/payment/PaymentSplitter.sol @@ -25,6 +25,7 @@ contract PaymentSplitter { * @dev Constructor */ constructor (address[] memory payees, uint256[] memory shares) public payable { + // solhint-disable-next-line max-line-length require(payees.length == shares.length, "from OpenZeppelin's:PaymentSplitter.sol:constructor(). payees.length != shares.length."); require(payees.length > 0, "from OpenZeppelin's:PaymentSplitter.sol:constructor(). payees.length <= 0."); diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index add0095bd2f..d84370e88b1 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -29,6 +29,7 @@ library SafeERC20 { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' + // solhint-disable-next-line max-line-length require((value == 0) || (token.allowance(address(this), spender) == 0), "from OpenZeppelin's:SafeERC20.sol:safeApprove()."); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } @@ -57,7 +58,7 @@ library SafeERC20 { // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. - + // solhint-disable-next-line max-line-length require(address(token).isContract(), "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). token address is not a contract address."); // solhint-disable-next-line avoid-low-level-calls @@ -65,6 +66,7 @@ library SafeERC20 { require(success, "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). Low-level call() returned false."); if (returndata.length > 0) { // Return data is optional + // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). abi.decode()"); } } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 02b23ea7e42..d3195d7df64 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -53,7 +53,8 @@ contract TokenTimelock { */ function release() public { // solhint-disable-next-line not-rely-on-time - require(block.timestamp >= _releaseTime, "from OpenZeppelin's:TokenTimelock.sol:release(). block.timestamp < _releaseTime."); + // solhint-disable-next-line max-line-length + require(block.timestamp >= _releaseTime, "from OpenZeppelin's:TokenTimelock.sol:release(). block.timestamp < _releaseTime."); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "from OpenZeppelin's:TokenTimelock.sol:release(). amount <= 0."); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index edc7039d53b..78f25a4cd30 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -83,6 +83,7 @@ contract ERC721 is ERC165, IERC721 { function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "from OpenZeppelin's:ERC721.sol:approve(). to == owner."); + // solhint-disable-next-line max-line-length require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "from OpenZeppelin's:ERC721.sol:approve(). msg.sender is neither the owner nor an approved account."); _tokenApprovals[tokenId] = to; From 92d580a702c270c90569250a3dd13297bb885bba Mon Sep 17 00:00:00 2001 From: balajipachai Date: Sat, 6 Apr 2019 11:59:18 +0530 Subject: [PATCH 04/20] Updated PR as per issue #1709 --- contracts/access/Roles.sol | 10 +++---- contracts/access/roles/CapperRole.sol | 2 +- contracts/access/roles/MinterRole.sol | 2 +- contracts/access/roles/PauserRole.sol | 2 +- contracts/access/roles/SignerRole.sol | 2 +- contracts/access/roles/WhitelistAdminRole.sol | 2 +- contracts/access/roles/WhitelistedRole.sol | 2 +- contracts/crowdsale/Crowdsale.sol | 10 +++---- .../distribution/FinalizableCrowdsale.sol | 4 +-- .../distribution/PostDeliveryCrowdsale.sol | 4 +-- .../distribution/RefundableCrowdsale.sol | 8 +++--- .../RefundablePostDeliveryCrowdsale.sol | 7 +++-- .../crowdsale/emission/AllowanceCrowdsale.sol | 2 +- .../crowdsale/emission/MintedCrowdsale.sol | 6 +++-- .../price/IncreasingPriceCrowdsale.sol | 4 +-- .../crowdsale/validation/CappedCrowdsale.sol | 4 +-- .../IndividuallyCappedCrowdsale.sol | 2 +- .../crowdsale/validation/TimedCrowdsale.sol | 11 ++++---- .../validation/WhitelistCrowdsale.sol | 2 +- contracts/drafts/ERC20Migrator.sol | 10 +++---- contracts/drafts/ERC20Snapshot.sol | 4 +-- contracts/drafts/SignatureBouncer.sol | 12 ++++----- contracts/drafts/SignedSafeMath.sol | 15 +++++------ contracts/drafts/TokenVesting.sol | 16 +++++------- contracts/introspection/ERC165.sol | 2 +- contracts/lifecycle/Pausable.sol | 4 +-- contracts/ownership/Ownable.sol | 4 +-- contracts/ownership/Secondary.sol | 4 +-- contracts/payment/PaymentSplitter.sol | 14 +++++----- .../payment/escrow/ConditionalEscrow.sol | 2 +- contracts/payment/escrow/RefundEscrow.sol | 10 +++---- contracts/token/ERC20/ERC20.sol | 10 +++---- contracts/token/ERC20/ERC20Capped.sol | 4 +-- contracts/token/ERC20/SafeERC20.sol | 8 +++--- contracts/token/ERC20/TokenTimelock.sol | 7 +++-- contracts/token/ERC721/ERC721.sol | 26 +++++++++---------- contracts/token/ERC721/ERC721Burnable.sol | 3 ++- contracts/token/ERC721/ERC721Enumerable.sol | 4 +-- contracts/token/ERC721/ERC721Metadata.sol | 4 +-- contracts/utils/ReentrancyGuard.sol | 2 +- 40 files changed, 121 insertions(+), 130 deletions(-) diff --git a/contracts/access/Roles.sol b/contracts/access/Roles.sol index 176f5dad8dc..fdc610f1e81 100644 --- a/contracts/access/Roles.sol +++ b/contracts/access/Roles.sol @@ -13,8 +13,8 @@ library Roles { * @dev give an account access to this role */ function add(Role storage role, address account) internal { - require(account != address(0), "from OpenZeppelin's:Roles.sol:add(). account cannot be address(0)"); - require(!has(role, account), "from OpenZeppelin's:Roles.sol:add() . account already has this role."); + require(account != address(0), "Roles: can only add non zero-account."); + require(!has(role, account), "Roles: account has already given access to this role."); role.bearer[account] = true; } @@ -23,8 +23,8 @@ library Roles { * @dev remove an account's access to this role */ function remove(Role storage role, address account) internal { - require(account != address(0), "from OpenZeppelin's:Roles.sol:remove(). account cannot be address(0)"); - require(has(role, account), "from OpenZeppelin's:Roles.sol:remove(). account doesn't have this role."); + require(account != address(0), "Roles: can only remove non zero-account."); + require(has(role, account), "Roles: account does not have access to this role to remove."); role.bearer[account] = false; } @@ -34,7 +34,7 @@ library Roles { * @return bool */ function has(Role storage role, address account) internal view returns (bool) { - require(account != address(0), "from OpenZeppelin's:Roles.sol:has(). account cannot be address(0)"); + require(account != address(0), "Roles: if an account has this role can be checked for non zero-account."); return role.bearer[account]; } } diff --git a/contracts/access/roles/CapperRole.sol b/contracts/access/roles/CapperRole.sol index 1343939722d..0e6321d9229 100644 --- a/contracts/access/roles/CapperRole.sol +++ b/contracts/access/roles/CapperRole.sol @@ -15,7 +15,7 @@ contract CapperRole { } modifier onlyCapper() { - require(isCapper(msg.sender), "from OpenZeppelin's:CapperRole.sol:onlyCapper()."); + require(isCapper(msg.sender), "CapperRole: caller doesn't have the Capper role."); _; } diff --git a/contracts/access/roles/MinterRole.sol b/contracts/access/roles/MinterRole.sol index 327ccfa8a6b..ba350acb1c6 100644 --- a/contracts/access/roles/MinterRole.sol +++ b/contracts/access/roles/MinterRole.sol @@ -15,7 +15,7 @@ contract MinterRole { } modifier onlyMinter() { - require(isMinter(msg.sender), "from OpenZeppelin's:MinterRole.sol:onlyMinter()."); + require(isMinter(msg.sender), "MinterRole: caller doesn't have the Minter role."); _; } diff --git a/contracts/access/roles/PauserRole.sol b/contracts/access/roles/PauserRole.sol index 95488afcb50..cc2ca65766c 100644 --- a/contracts/access/roles/PauserRole.sol +++ b/contracts/access/roles/PauserRole.sol @@ -15,7 +15,7 @@ contract PauserRole { } modifier onlyPauser() { - require(isPauser(msg.sender), "from OpenZeppelin's:PauserRole.sol:onlyPauser()."); + require(isPauser(msg.sender), "PauserRole: caller doesn't have the Pauser role."); _; } diff --git a/contracts/access/roles/SignerRole.sol b/contracts/access/roles/SignerRole.sol index 9be6752197d..22a42999dbe 100644 --- a/contracts/access/roles/SignerRole.sol +++ b/contracts/access/roles/SignerRole.sol @@ -15,7 +15,7 @@ contract SignerRole { } modifier onlySigner() { - require(isSigner(msg.sender), "from OpenZeppelin's:SignerRole.sol:onlySigner()."); + require(isSigner(msg.sender), "SignerRole: caller doesn't have the Signer role."); _; } diff --git a/contracts/access/roles/WhitelistAdminRole.sol b/contracts/access/roles/WhitelistAdminRole.sol index 223d904db14..8a7255fe9df 100644 --- a/contracts/access/roles/WhitelistAdminRole.sol +++ b/contracts/access/roles/WhitelistAdminRole.sol @@ -19,7 +19,7 @@ contract WhitelistAdminRole { } modifier onlyWhitelistAdmin() { - require(isWhitelistAdmin(msg.sender), "from OpenZeppelin's:WhitelistAdminRole.sol:onlyWhitelistAdmin()."); + require(isWhitelistAdmin(msg.sender), "WhitelistAdminRole: caller doesn't have the WhitelistAdmin role."); _; } diff --git a/contracts/access/roles/WhitelistedRole.sol b/contracts/access/roles/WhitelistedRole.sol index 180289a9b3d..95af0373785 100644 --- a/contracts/access/roles/WhitelistedRole.sol +++ b/contracts/access/roles/WhitelistedRole.sol @@ -18,7 +18,7 @@ contract WhitelistedRole is WhitelistAdminRole { Roles.Role private _whitelisteds; modifier onlyWhitelisted() { - require(isWhitelisted(msg.sender), "from OpenZeppelin's:WhitelistedRole.sol:onlyWhitelisted()."); + require(isWhitelisted(msg.sender), "WhitelistedRole: caller doesn't have the Whitelist role."); _; } diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 5fbe6119d3d..21e01e1e4bc 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -54,10 +54,10 @@ contract Crowdsale is ReentrancyGuard { * @param token Address of the token being sold */ constructor (uint256 rate, address payable wallet, IERC20 token) public { - require(rate > 0, "from OpenZeppelin's:Crowdsale.sol:constructor(). rate <= 0."); - require(wallet != address(0), "from OpenZeppelin's:Crowdsale.sol:constructor(). wallet cannot be address(0)."); + require(rate > 0, "Crowdsale: rate is 0."); + require(wallet != address(0), "Crowdsale: wallet address can only be non-zero address."); // solhint-disable-next-line max-line-length - require(address(token) != address(0), "from OpenZeppelin's:Crowdsale.sol:constructor(). token address cannot be address(0)."); + require(address(token) != address(0), "Crowdsale: token address can only be non-zero address."); _rate = rate; _wallet = wallet; @@ -138,8 +138,8 @@ contract Crowdsale is ReentrancyGuard { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { // solhint-disable-next-line max-line-length - require(beneficiary != address(0), "from OpenZeppelin's:Crowdsale.sol:_preValidatePurchase(). beneficiary address cannot be address(0."); - require(weiAmount != 0, "from OpenZeppelin's:Crowdsale.sol:_preValidatePurchase(). weiAmount = 0."); + require(beneficiary != address(0), "Crowdsale: beneficiary address can only be non-zero address."); + require(weiAmount != 0, "Crowdsale: weiAmount is 0."); } /** diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index 7d3fc4129fa..0ff42a80be9 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -31,8 +31,8 @@ contract FinalizableCrowdsale is TimedCrowdsale { * work. Calls the contract's finalization function. */ function finalize() public { - require(!_finalized, "from OpenZeppelin's:FinalizableCrowdsale.sol:finalize(). _finalized is true."); - require(hasClosed(), "from OpenZeppelin's:FinalizableCrowdsale.sol:finalize(). hasClosed() is false."); + require(!_finalized, "FinalizableCrowdsale: crowdsale is already finalized."); + require(hasClosed(), "FinalizableCrowdsale: crowdsale has not been closed yet."); _finalized = true; diff --git a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol index 59437d7f38f..a2c3d3e1ab7 100644 --- a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol @@ -17,9 +17,9 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { - require(hasClosed(), "from OpenZeppelin's:PostDeliveryCrowdsale.sol:withdrawTokens(). hasClosed() is false."); + require(hasClosed(), "PostDeliveryCrowdsale: crowdsale has not been closed yet."); uint256 amount = _balances[beneficiary]; - require(amount > 0, "from OpenZeppelin's:PostDeliveryCrowdsale.sol:withdrawTokens(). amount is <= 0."); + require(amount > 0, "PostDeliveryCrowdsale: withdrawal amount is 0."); _balances[beneficiary] = 0; _deliverTokens(beneficiary, amount); } diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index 89d7737dd41..1801e2ab7c0 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -28,7 +28,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param goal Funding goal */ constructor (uint256 goal) public { - require(goal > 0, "from OpenZeppelin's:RefundableCrowdsale.sol:constructor()."); + require(goal > 0, "RefundableCrowdsale: "); _escrow = new RefundEscrow(wallet()); _goal = goal; } @@ -45,10 +45,8 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param refundee Whose refund will be claimed. */ function claimRefund(address payable refundee) public { - // solhint-disable-next-line max-line-length - require(finalized(), "from OpenZeppelin's:RefundableCrowdsale.sol:claimRefund(). Call to finalized() returned false."); - // solhint-disable-next-line max-line-length - require(!goalReached(), "from OpenZeppelin's:RefundableCrowdsale.sol:claimRefund(). Call to goalReached() returned true."); + require(finalized(), "RefundableCrowdsale: crowdsale has not been finalized yet."); + require(!goalReached(), "RefundableCrowdsale: funding goal has already reached, cannot claim refund."); _escrow.withdraw(refundee); } diff --git a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol index 32eefe7fb67..0fc70e133fc 100644 --- a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol @@ -12,10 +12,9 @@ import "./PostDeliveryCrowdsale.sol"; */ contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale { function withdrawTokens(address beneficiary) public { - // solhint-disable-next-line max-line-length - require(finalized(), "from OpenZeppelin's:RefundablePostDeliveryCrowdsale.sol:withdrawTokens(). Call to finalized() returned false."); - // solhint-disable-next-line max-line-length - require(goalReached(), "from OpenZeppelin's:RefundablePostDeliveryCrowdsale.sol:withdrawTokens(). Call to goalReached() returned false."); + require(finalized(), "RefundablePostDeliveryCrowdsale: crowdsale has not been finalized yet."); + //solhint-disable-next-line max-line-length + require(goalReached(), "RefundablePostDeliveryCrowdsale: funding goal has not reached, cannot withdraw tokens."); super.withdrawTokens(beneficiary); } diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index ffb1b4d683e..a02e637aa25 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -21,7 +21,7 @@ contract AllowanceCrowdsale is Crowdsale { * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale */ constructor (address tokenWallet) public { - require(tokenWallet != address(0), "from OpenZeppelin's:AllowanceCrowdsale.sol:constructor()."); + require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet address can only be non-zero address."); _tokenWallet = tokenWallet; } diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index defdff6c440..45720d85350 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -16,7 +16,9 @@ contract MintedCrowdsale is Crowdsale { */ function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { // Potentially dangerous assumption about the type of the token. - // solhint-disable-next-line max-line-length - require(ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), "from OpenZeppelin's:MintedCrowdsale.sol:_deliverTokens()."); + require( + ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), + "MintedCrowdsale: assumption about the type of the token failed." + ); } } diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 0c20fba4392..654c2159343 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -21,9 +21,9 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale */ constructor (uint256 initialRate, uint256 finalRate) public { - require(finalRate > 0, "from OpenZeppelin's:IncreasingPriceCrowdsale.sol:constructor(). finalRate = 0."); + require(finalRate > 0, "IncreasingPriceCrowdsale: final rate of token is 0."); // solhint-disable-next-line max-line-length - require(initialRate > finalRate, "from OpenZeppelin's:IncreasingPriceCrowdsale.sol:constructor(). initialRate < finalRate."); + require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate of token is less than final rate of token."); _initialRate = initialRate; _finalRate = finalRate; } diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index c0621efa35e..70bdc538256 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -17,7 +17,7 @@ contract CappedCrowdsale is Crowdsale { * @param cap Max amount of wei to be contributed */ constructor (uint256 cap) public { - require(cap > 0, "from OpenZeppelin's:CappedCrowdsale.sol:constructor()."); + require(cap > 0, "CappedCrowdsale: max amount of wei to be contributed is 0."); _cap = cap; } @@ -43,6 +43,6 @@ contract CappedCrowdsale is Crowdsale { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); - require(weiRaised().add(weiAmount) <= _cap, "from OpenZeppelin's:CappedCrowdsale.sol:_preValidatePurchase()."); + require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: invalid purchase."); } } diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 90105d9fcb0..3302952dd02 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -49,7 +49,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); // solhint-disable-next-line max-line-length - require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "from OpenZeppelin's:IndividuallyCappedCrowdsale.sol:_preValidatePurchase()."); + require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: invalid purchase."); } /** diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index e2223097cc8..97d8025f1e0 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -24,7 +24,7 @@ contract TimedCrowdsale is Crowdsale { * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { - require(isOpen(), "from OpenZeppelin's:TimedCrowdsale.sol:onlyWhileOpen()."); + require(isOpen(), "TimedCrowdsale: "); _; } @@ -35,10 +35,9 @@ contract TimedCrowdsale is Crowdsale { */ constructor (uint256 openingTime, uint256 closingTime) public { // solhint-disable-next-line not-rely-on-time + require(openingTime >= block.timestamp, "TimedCrowdsale: crowdsale opening time is < current time."); // solhint-disable-next-line max-line-length - require(openingTime >= block.timestamp, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). openingTime < block.timestamp."); - // solhint-disable-next-line max-line-length - require(closingTime > openingTime, "from OpenZeppelin's:TimedCrowdsale.sol:constructor(). closingTime <= openingTime."); + require(closingTime > openingTime, "TimedCrowdsale: crowdsale closing time is <= crowdsale opening time."); _openingTime = openingTime; _closingTime = closingTime; @@ -89,9 +88,9 @@ contract TimedCrowdsale is Crowdsale { * @param newClosingTime Crowdsale closing time */ function _extendTime(uint256 newClosingTime) internal { - require(!hasClosed(), "from OpenZeppelin's:TimedCrowdsale.sol:_extendTime(). Crowdsale has already closed."); + require(!hasClosed(), "TimedCrowdsale: "); // solhint-disable-next-line max-line-length - require(newClosingTime > _closingTime, "from OpenZeppelin's:TimedCrowdsale.sol:_extendTime(). New closing time is < previous closing time."); + require(newClosingTime > _closingTime, "TimedCrowdsale: "); emit TimedCrowdsaleExtended(_closingTime, newClosingTime); _closingTime = newClosingTime; diff --git a/contracts/crowdsale/validation/WhitelistCrowdsale.sol b/contracts/crowdsale/validation/WhitelistCrowdsale.sol index e7dd567b538..bd7a395728a 100644 --- a/contracts/crowdsale/validation/WhitelistCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistCrowdsale.sol @@ -15,7 +15,7 @@ contract WhitelistCrowdsale is WhitelistedRole, Crowdsale { * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { - require(isWhitelisted(_beneficiary), "from OpenZeppelin's:WhitelistCrowdsale.sol:_preValidatePurchase()."); + require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelist role."); super._preValidatePurchase(_beneficiary, _weiAmount); } } diff --git a/contracts/drafts/ERC20Migrator.sol b/contracts/drafts/ERC20Migrator.sol index 47ee917b5b8..921f3879412 100644 --- a/contracts/drafts/ERC20Migrator.sol +++ b/contracts/drafts/ERC20Migrator.sol @@ -44,7 +44,7 @@ contract ERC20Migrator { * @param legacyToken address of the old token contract */ constructor (IERC20 legacyToken) public { - require(address(legacyToken) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:constructor()."); + require(address(legacyToken) != address(0), "ERC20Migrator: "); _legacyToken = legacyToken; } @@ -69,11 +69,11 @@ contract ERC20Migrator { */ function beginMigration(ERC20Mintable newToken_) public { // solhint-disable-next-line max-line-length - require(address(_newToken) == address(0), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). _newToken != address(0)"); + require(address(_newToken) == address(0), "ERC20Migrator: "); // solhint-disable-next-line max-line-length - require(address(newToken_) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). newToken_ cannot be address(0)"); + require(address(newToken_) != address(0), "ERC20Migrator: "); // solhint-disable-next-line max-line-length - require(newToken_.isMinter(address(this)), "from OpenZeppelin's:ERC20Migrator.sol:beginMigration(). address(this) is not a minter for newToken_."); + require(newToken_.isMinter(address(this)), "ERC20Migrator: "); _newToken = newToken_; } @@ -85,7 +85,7 @@ contract ERC20Migrator { * @param amount amount of tokens to be migrated */ function migrate(address account, uint256 amount) public { - require(address(_newToken) != address(0), "from OpenZeppelin's:ERC20Migrator.sol:migrate()."); + require(address(_newToken) != address(0), "ERC20Migrator: new token address can only be non-zero address."); _legacyToken.safeTransferFrom(account, address(this), amount); _newToken.mint(account, amount); } diff --git a/contracts/drafts/ERC20Snapshot.sol b/contracts/drafts/ERC20Snapshot.sol index 5fbdf6c8624..69f907342ab 100644 --- a/contracts/drafts/ERC20Snapshot.sol +++ b/contracts/drafts/ERC20Snapshot.sol @@ -101,9 +101,9 @@ contract ERC20Snapshot is ERC20 { function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { - require(snapshotId > 0, "from OpenZeppelin's:ERC20Snapshot.sol:_valueAt(). snapshotId < = 0."); + require(snapshotId > 0, "ERC20Snapshot: the snapshot id is 0."); // solhint-disable-next-line max-line-length - require(snapshotId <= _currentSnapshotId.current(), "from OpenZeppelin's:ERC20Snapshot.sol:_valueAt(). snapshotId > current snapshotId."); + require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: the provided snapshot id > current snapshot id."); uint256 index = snapshots.ids.findUpperBound(snapshotId); diff --git a/contracts/drafts/SignatureBouncer.sol b/contracts/drafts/SignatureBouncer.sol index 550a0daded6..2f307a8b479 100644 --- a/contracts/drafts/SignatureBouncer.sol +++ b/contracts/drafts/SignatureBouncer.sol @@ -51,8 +51,7 @@ contract SignatureBouncer is SignerRole { * @dev requires that a valid signature of a signer was provided */ modifier onlyValidSignature(bytes memory signature) { - // solhint-disable-next-line max-line-length - require(_isValidSignature(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignature()."); + require(_isValidSignature(msg.sender, signature), "SignatureBouncer: invalid caller signature."); _; } @@ -61,16 +60,16 @@ contract SignatureBouncer is SignerRole { */ modifier onlyValidSignatureAndMethod(bytes memory signature) { // solhint-disable-next-line max-line-length - require(_isValidSignatureAndMethod(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignatureAndMethod()."); + require(_isValidSignatureAndMethod(msg.sender, signature), "SignatureBouncer: invalid caller signature for method."); _; } /** - * @dev requires that a valid signature with a specified method and params of a signer was provided +. * @dev requires that a valid signature with a specified method and params of a signer was provided */ modifier onlyValidSignatureAndData(bytes memory signature) { // solhint-disable-next-line max-line-length - require(_isValidSignatureAndData(msg.sender, signature), "from OpenZeppelin's:SignatureBouncer.sol:onlyValidSignatureAndData()."); + require(_isValidSignatureAndData(msg.sender, signature), "SignatureBouncer: invalid caller signature for data."); _; } @@ -100,8 +99,7 @@ contract SignatureBouncer is SignerRole { * @return bool */ function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) { - // solhint-disable-next-line max-line-length - require(msg.data.length > _SIGNATURE_SIZE, "from OpenZeppelin's:SignatureBouncer.sol:_isValidSignatureAndData()."); + require(msg.data.length > _SIGNATURE_SIZE, "SignatureBouncer: length of caller data is < 96."); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { diff --git a/contracts/drafts/SignedSafeMath.sol b/contracts/drafts/SignedSafeMath.sol index cbb4ec17935..c93ee36e753 100644 --- a/contracts/drafts/SignedSafeMath.sol +++ b/contracts/drafts/SignedSafeMath.sol @@ -18,11 +18,10 @@ library SignedSafeMath { return 0; } - // solhint-disable-next-line max-line-length - require(!(a == -1 && b == INT256_MIN), "from OpenZeppelin's:SignedSafeMath.sol:mul(). Detected overflow."); // This is the only case of overflow not detected by the check below + require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: (a == -1 && b == -2**255)"); int256 c = a * b; - require(c / a == b, "from OpenZeppelin's:SignedSafeMath.sol:mul(). c/a != b. "); + require(c / a == b, "SignedSafeMath: c / a == b"); return c; } @@ -31,10 +30,8 @@ library SignedSafeMath { * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. */ function div(int256 a, int256 b) internal pure returns (int256) { - // solhint-disable-next-line max-line-length - require(b != 0, "from OpenZeppelin's:SignedSafeMath.sol:div(). Divide by zero error."); // Solidity only automatically asserts when dividing by 0 - // solhint-disable-next-line max-line-length - require(!(b == -1 && a == INT256_MIN), "from OpenZeppelin's:SignedSafeMath.sol:div(). Detected overflow."); // This is the only case of overflow + require(b != 0, "SignedSafeMath: division by zero."); + require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: (b == -1 && a == -2**255)"); int256 c = a / b; @@ -46,7 +43,7 @@ library SignedSafeMath { */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; - require((b >= 0 && c <= a) || (b < 0 && c > a), "from OpenZeppelin's:SignedSafeMath.sol:sub()."); + require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: (b >= 0 && c <= a) || (b < 0 && c > a)"); return c; } @@ -56,7 +53,7 @@ library SignedSafeMath { */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; - require((b >= 0 && c >= a) || (b < 0 && c < a), "from OpenZeppelin's:SignedSafeMath.sol:add()."); + require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: (b >= 0 && c >= a) || (b < 0 && c < a)"); return c; } diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index b145b922bb6..cdfc9f05716 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -47,13 +47,12 @@ contract TokenVesting is Ownable { * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { + require(beneficiary != address(0), "TokenVesting: beneficiary can only be non-zero address."); // solhint-disable-next-line max-line-length - require(beneficiary != address(0), "from OpenZeppelin's:TokenVesting.sol:constructor(). beneficiary is address(0)."); + require(cliffDuration <= duration, "TokenVesting: duration when tokens begin to vest > duration in which tokens will vest."); + require(duration > 0, "TokenVesting: duration in which tokens will vest is 0."); // solhint-disable-next-line max-line-length - require(cliffDuration <= duration, "from OpenZeppelin's:TokenVesting.sol:constructor(). cliffDuration > duration."); - require(duration > 0, "from OpenZeppelin's:TokenVesting.sol:constructor(). duration <= 0."); - // solhint-disable-next-line max-line-length - require(start.add(duration) > block.timestamp, "from OpenZeppelin's:TokenVesting.sol:constructor(). start.add(duration) < block.timestamp."); + require(start.add(duration) > block.timestamp, "TokenVesting: time at which vesting starts must be < current block timestamp."); _beneficiary = beneficiary; _revocable = revocable; @@ -118,7 +117,7 @@ contract TokenVesting is Ownable { function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); - require(unreleased > 0, "from OpenZeppelin's:TokenVesting.sol:release()."); + require(unreleased > 0, "TokenVesting: number of vested tokens is 0."); _released[address(token)] = _released[address(token)].add(unreleased); @@ -133,9 +132,8 @@ contract TokenVesting is Ownable { * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { - require(_revocable, "from OpenZeppelin's:TokenVesting.sol:revoke(). _revocable is false."); - // solhint-disable-next-line max-line-length - require(!_revoked[address(token)], "from OpenZeppelin's:TokenVesting.sol:revoke(). Token vesting already revoked."); + require(_revocable, "TokenVesting: can only revoke if revoking is allowed."); + require(!_revoked[address(token)], "TokenVesting: revoked for a token address is set to true."); uint256 balance = token.balanceOf(address(this)); diff --git a/contracts/introspection/ERC165.sol b/contracts/introspection/ERC165.sol index 0130934dc7c..74623163bbe 100644 --- a/contracts/introspection/ERC165.sol +++ b/contracts/introspection/ERC165.sol @@ -38,7 +38,7 @@ contract ERC165 is IERC165 { * @dev internal method for registering an interface */ function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff, "from OpenZeppelin's:ERC165.sol:_registerInterface()."); + require(interfaceId != 0xffffffff, "ERC165: invalid interface id."); _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index ef2186c5471..f35d9788cb5 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -27,7 +27,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { - require(!_paused, "from OpenZeppelin's:Pausable.sol:whenNotPaused()."); + require(!_paused, "Pausable: !_paused."); _; } @@ -35,7 +35,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { - require(_paused, "from OpenZeppelin's:Pausable.sol:whenPaused()."); + require(_paused, "Pausable: _paused."); _; } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index ab1286e7fb7..5472e5d1a4f 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -30,7 +30,7 @@ contract Ownable { * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { - require(isOwner(), "from OpenZeppelin's:Ownable.sol:onlyOwner()."); + require(isOwner(), "Ownable: "); _; } @@ -66,7 +66,7 @@ contract Ownable { * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { - require(newOwner != address(0), "from OpenZeppelin's:Ownable.sol:_transferOwnership()."); + require(newOwner != address(0), "Ownable: new owner can only be non-zero address."); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } diff --git a/contracts/ownership/Secondary.sol b/contracts/ownership/Secondary.sol index 3b31fdc3490..b8ff0ed81f2 100644 --- a/contracts/ownership/Secondary.sol +++ b/contracts/ownership/Secondary.sol @@ -23,7 +23,7 @@ contract Secondary { * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { - require(msg.sender == _primary, "from OpenZeppelin's:Secondary.sol:onlyPrimary()."); + require(msg.sender == _primary, "Secondary: "); _; } @@ -39,7 +39,7 @@ contract Secondary { * @param recipient The address of new primary. */ function transferPrimary(address recipient) public onlyPrimary { - require(recipient != address(0), "from OpenZeppelin's:Secondary.sol:transferPrimary()."); + require(recipient != address(0), "Secondary: recipient address can only be non-zero address."); _primary = recipient; emit PrimaryTransferred(_primary); } diff --git a/contracts/payment/PaymentSplitter.sol b/contracts/payment/PaymentSplitter.sol index 2a0e4324aa5..64de54b973f 100644 --- a/contracts/payment/PaymentSplitter.sol +++ b/contracts/payment/PaymentSplitter.sol @@ -26,8 +26,8 @@ contract PaymentSplitter { */ constructor (address[] memory payees, uint256[] memory shares) public payable { // solhint-disable-next-line max-line-length - require(payees.length == shares.length, "from OpenZeppelin's:PaymentSplitter.sol:constructor(). payees.length != shares.length."); - require(payees.length > 0, "from OpenZeppelin's:PaymentSplitter.sol:constructor(). payees.length <= 0."); + require(payees.length == shares.length, "PaymentSplitter: "); + require(payees.length > 0, "PaymentSplitter: "); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares[i]); @@ -81,12 +81,12 @@ contract PaymentSplitter { * @param account Whose payments will be released. */ function release(address payable account) public { - require(_shares[account] > 0, "from OpenZeppelin's:PaymentSplitter.sol:release(). _shares[account] <= 0."); + require(_shares[account] > 0, "PaymentSplitter: "); uint256 totalReceived = address(this).balance.add(_totalReleased); uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); - require(payment != 0, "from OpenZeppelin's:PaymentSplitter.sol:release(). payment is 0."); + require(payment != 0, "PaymentSplitter: "); _released[account] = _released[account].add(payment); _totalReleased = _totalReleased.add(payment); @@ -101,9 +101,9 @@ contract PaymentSplitter { * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { - require(account != address(0), "from OpenZeppelin's:PaymentSplitter.sol:_addPayee(). account is address(0)."); - require(shares_ > 0, "from OpenZeppelin's:PaymentSplitter.sol:_addPayee(). shares_ <= 0."); - require(_shares[account] == 0, "from OpenZeppelin's:PaymentSplitter.sol:_addPayee(). _shares[account] != 0."); + require(account != address(0), "PaymentSplitter: account can only be non-zero address."); + require(shares_ > 0, "PaymentSplitter: the shares must be > 0."); + require(_shares[account] == 0, "PaymentSplitter: _shares[account] == 0."); _payees.push(account); _shares[account] = shares_; diff --git a/contracts/payment/escrow/ConditionalEscrow.sol b/contracts/payment/escrow/ConditionalEscrow.sol index d6c537dcd2b..031de5957b8 100644 --- a/contracts/payment/escrow/ConditionalEscrow.sol +++ b/contracts/payment/escrow/ConditionalEscrow.sol @@ -16,7 +16,7 @@ contract ConditionalEscrow is Escrow { function withdrawalAllowed(address payee) public view returns (bool); function withdraw(address payable payee) public { - require(withdrawalAllowed(payee), "from OpenZeppelin's:ConditionalEscrow.sol:withdraw()."); + require(withdrawalAllowed(payee), "ConditionalEscrow: payee should have been allowed to withdraw."); super.withdraw(payee); } } diff --git a/contracts/payment/escrow/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol index 29418056593..84e97872992 100644 --- a/contracts/payment/escrow/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -27,7 +27,7 @@ contract RefundEscrow is ConditionalEscrow { * @param beneficiary The beneficiary of the deposits. */ constructor (address payable beneficiary) public { - require(beneficiary != address(0), "from OpenZeppelin's:RefundEscrow.sol:constructor()."); + require(beneficiary != address(0), "RefundEscrow: beneficiary can only be non-zero address."); _beneficiary = beneficiary; _state = State.Active; } @@ -51,7 +51,7 @@ contract RefundEscrow is ConditionalEscrow { * @param refundee The address funds will be sent to if a refund occurs. */ function deposit(address refundee) public payable { - require(_state == State.Active, "from OpenZeppelin's:RefundEscrow.sol:deposit()."); + require(_state == State.Active, "RefundEscrow: _state == State.Active in deposit()."); super.deposit(refundee); } @@ -60,7 +60,7 @@ contract RefundEscrow is ConditionalEscrow { * further deposits. */ function close() public onlyPrimary { - require(_state == State.Active, "from OpenZeppelin's:RefundEscrow.sol:close()."); + require(_state == State.Active, "RefundEscrow: _state == State.Active in close()."); _state = State.Closed; emit RefundsClosed(); } @@ -69,7 +69,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Allows for refunds to take place, rejecting further deposits. */ function enableRefunds() public onlyPrimary { - require(_state == State.Active, "from OpenZeppelin's:RefundEscrow.sol:enableRefunds()."); + require(_state == State.Active, "RefundEscrow: _state == State.Active in enableRefunds()."); _state = State.Refunding; emit RefundsEnabled(); } @@ -78,7 +78,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Withdraws the beneficiary's funds. */ function beneficiaryWithdraw() public { - require(_state == State.Closed, "from OpenZeppelin's:RefundEscrow.sol:beneficiaryWithdraw()."); + require(_state == State.Closed, "RefundEscrow: _state == State.Closed."); _beneficiary.transfer(address(this).balance); } diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index e269aaa8652..55e95784b17 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0), "from OpenZeppelin's:ERC20.sol:_transfer()."); + require(to != address(0), "ERC20: "); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0), "from OpenZeppelin's:ERC20.sol:_mint()."); + require(account != address(0), "ERC20: "); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0), "from OpenZeppelin's:ERC20.sol:_burn()."); + require(account != address(0), "ERC20: "); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0), "from OpenZeppelin's:ERC20.sol:_approve(). spender is address(0)."); - require(owner != address(0), "from OpenZeppelin's:ERC20.sol:_approve(). owner is address(0)."); + require(spender != address(0), "ERC20: spender can only be non-zero address."); + require(owner != address(0), "ERC20: owner can only be non-zero address."); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index c9261fccf8e..ada543bf000 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -10,7 +10,7 @@ contract ERC20Capped is ERC20Mintable { uint256 private _cap; constructor (uint256 cap) public { - require(cap > 0, "from OpenZeppelin's:ERC20Capped.sol:constructor()."); + require(cap > 0, "ERC20Capped: capacity must be > 0."); _cap = cap; } @@ -22,7 +22,7 @@ contract ERC20Capped is ERC20Mintable { } function _mint(address account, uint256 value) internal { - require(totalSupply().add(value) <= _cap, "from OpenZeppelin's:ERC20Capped.sol:_mint()."); + require(totalSupply().add(value) <= _cap, "ERC20Capped: totalSupply().add(value) <= _cap."); super._mint(account, value); } } diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index d84370e88b1..40ad997a8f5 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -30,7 +30,7 @@ library SafeERC20 { // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length - require((value == 0) || (token.allowance(address(this), spender) == 0), "from OpenZeppelin's:SafeERC20.sol:safeApprove()."); + require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: (value == 0) || (token.allowance(address(this), spender) == 0)"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } @@ -59,15 +59,15 @@ library SafeERC20 { // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length - require(address(token).isContract(), "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). token address is not a contract address."); + require(address(token).isContract(), "SafeERC20: token address is not a contract address."); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); - require(success, "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). Low-level call() returned false."); + require(success, "SafeERC20: the previous call should have succeeded."); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), "from OpenZeppelin's:SafeERC20.sol:callOptionalReturn(). abi.decode()"); + require(abi.decode(returndata, (bool)), "SafeERC20: abi.decode(returndata, (bool))"); } } } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index d3195d7df64..a16fcb8ce82 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -21,7 +21,7 @@ contract TokenTimelock { constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { // solhint-disable-next-line not-rely-on-time - require(releaseTime > block.timestamp, "from OpenZeppelin's:TokenTimelock.sol:constructor()."); + require(releaseTime > block.timestamp, "TokenTimelock: release time < current block time."); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime; @@ -53,11 +53,10 @@ contract TokenTimelock { */ function release() public { // solhint-disable-next-line not-rely-on-time - // solhint-disable-next-line max-line-length - require(block.timestamp >= _releaseTime, "from OpenZeppelin's:TokenTimelock.sol:release(). block.timestamp < _releaseTime."); + require(block.timestamp >= _releaseTime, "TokenTimelock: current block time < release time."); uint256 amount = _token.balanceOf(address(this)); - require(amount > 0, "from OpenZeppelin's:TokenTimelock.sol:release(). amount <= 0."); + require(amount > 0, "TokenTimelock: amount to release is 0."); _token.safeTransfer(_beneficiary, amount); } diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 78f25a4cd30..eb4ef1d89b2 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0), "from OpenZeppelin's:ERC721.sol:balanceOf()."); + require(owner != address(0), "ERC721: owner can only be non-zero address in balanceOf()."); return _ownedTokensCount[owner].current(); } @@ -68,7 +68,7 @@ contract ERC721 is ERC165, IERC721 { */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; - require(owner != address(0), "from OpenZeppelin's:ERC721.sol:ownerOf()."); + require(owner != address(0), "ERC721: owner can only be non-zero address in ownerOf()."); return owner; } @@ -82,9 +82,9 @@ contract ERC721 is ERC165, IERC721 { */ function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); - require(to != owner, "from OpenZeppelin's:ERC721.sol:approve(). to == owner."); + require(to != owner, "ERC721: to address must not be owner address."); // solhint-disable-next-line max-line-length - require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "from OpenZeppelin's:ERC721.sol:approve(). msg.sender is neither the owner nor an approved account."); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: caller should either be the owner or an operator."); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); @@ -97,7 +97,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "from OpenZeppelin's:ERC721.sol:getApproved()."); + require(_exists(tokenId), "ERC721: the tokenId should be in existence."); return _tokenApprovals[tokenId]; } @@ -108,7 +108,7 @@ contract ERC721 is ERC165, IERC721 { * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { - require(to != msg.sender, "from OpenZeppelin's:ERC721.sol:setApprovalForAll()."); + require(to != msg.sender, "ERC721: to address must not be the caller."); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } @@ -132,7 +132,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId), "from OpenZeppelin's:ERC721.sol:transferFrom()."); + require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: "); _transferFrom(from, to, tokenId); } @@ -166,7 +166,7 @@ contract ERC721 is ERC165, IERC721 { */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); - require(_checkOnERC721Received(from, to, tokenId, _data), "from OpenZeppelin's:ERC721.sol:safeTransferFrom()."); + require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: "); } /** @@ -198,8 +198,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0), "from OpenZeppelin's:ERC721.sol:_mint(). to == address(0)."); - require(!_exists(tokenId), "from OpenZeppelin's:ERC721.sol:_mint(). _exists(tokenId) is true."); + require(to != address(0), "ERC721: to address can only be non-zero address."); + require(!_exists(tokenId), "ERC721: !_exists(tokenId)"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); @@ -215,7 +215,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner, "from OpenZeppelin's:ERC721.sol:_burn()."); + require(ownerOf(tokenId) == owner, "ERC721: ownerOf(tokenId) == owner"); _clearApproval(tokenId); @@ -242,8 +242,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from, "from OpenZeppelin's:ERC721.sol:_transferFrom(). ownerOf(tokenId) != from."); - require(to != address(0), "from OpenZeppelin's:ERC721.sol:_transferFrom(). to == address(0)."); + require(ownerOf(tokenId) == from, "ERC721: ownerOf(tokenId) == from"); + require(to != address(0), "ERC721: to can only be a non-zero address."); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index af25b967ffa..58be8660129 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -12,7 +12,8 @@ contract ERC721Burnable is ERC721 { * @param tokenId uint256 id of the ERC721 token to be burned. */ function burn(uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId), "from OpenZeppelin's:ERC721Burnable.sol:burn()."); + //solhint-disable-next-line max-line-length + require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721Burnable: caller can either be the owner or an approved address."); _burn(tokenId); } } diff --git a/contracts/token/ERC721/ERC721Enumerable.sol b/contracts/token/ERC721/ERC721Enumerable.sol index 93c535e110e..d576acfef99 100644 --- a/contracts/token/ERC721/ERC721Enumerable.sol +++ b/contracts/token/ERC721/ERC721Enumerable.sol @@ -44,7 +44,7 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { * @return uint256 token ID at the given index of the tokens list owned by the requested address */ function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { - require(index < balanceOf(owner), "from OpenZeppelin's:ERC721Enumerable.sol:tokenOfOwnerByIndex()."); + require(index < balanceOf(owner), "ERC721Enumerable: index < balanceOf(owner)"); return _ownedTokens[owner][index]; } @@ -63,7 +63,7 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { * @return uint256 token ID at the given index of the tokens list */ function tokenByIndex(uint256 index) public view returns (uint256) { - require(index < totalSupply(), "from OpenZeppelin's:ERC721Enumerable.sol:tokenByIndex()."); + require(index < totalSupply(), "ERC721Enumerable: index < totalSupply()"); return _allTokens[index]; } diff --git a/contracts/token/ERC721/ERC721Metadata.sol b/contracts/token/ERC721/ERC721Metadata.sol index 6b943593979..dac155bcd18 100644 --- a/contracts/token/ERC721/ERC721Metadata.sol +++ b/contracts/token/ERC721/ERC721Metadata.sol @@ -55,7 +55,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId), "from OpenZeppelin's:ERC721Metadata.sol:tokenURI()."); + require(_exists(tokenId), "ERC721Metadata: the tokenId should be in existence in tokenURI()."); return _tokenURIs[tokenId]; } @@ -66,7 +66,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { - require(_exists(tokenId), "from OpenZeppelin's:ERC721Metadata.sol:_setTokenURI()."); + require(_exists(tokenId), "ERC721Metadata: the tokenId should be in existence in _setTokenURI()"); _tokenURIs[tokenId] = uri; } diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol index 891c10a88ee..5b24441c3ef 100644 --- a/contracts/utils/ReentrancyGuard.sol +++ b/contracts/utils/ReentrancyGuard.sol @@ -27,6 +27,6 @@ contract ReentrancyGuard { _guardCounter += 1; uint256 localCounter = _guardCounter; _; - require(localCounter == _guardCounter, "from OpenZeppelin's:ReentrancyGuard.sol:nonReentrant()."); + require(localCounter == _guardCounter, "ReentrancyGuard: localCounter == _guardCounter."); } } From 589b4076cd2a0a7d73881d1b8cc2dcb24c3a4a62 Mon Sep 17 00:00:00 2001 From: Prince Sinha Date: Tue, 9 Apr 2019 12:29:17 +0530 Subject: [PATCH 05/20] changes as per #1709 and openzeppelin forum. --- contracts/token/ERC20/ERC20.sol | 10 +++---- contracts/token/ERC721/ERC721.sol | 35 +++++++++++------------ contracts/token/ERC721/ERC721Burnable.sol | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index f00bbe14f3b..408c76397bf 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0), "Address (to) can't be null !!"); + require(to != address(0), "empty or zero transaction recipient"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0), "Address (to) can't be null !!"); + require(account != address(0), "empty or zero transaction recipient"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0), "Address (to) can't be null !!"); + require(account != address(0), "empty or zero transaction recipient"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0), "Address (spender) can't be null !!"); - require(owner != address(0), "Address (owner) can't be null !!"); + require(spender != address(0), "empty or zero transaction recipient"); + require(owner != address(0), "empty or zero transaction recipient"); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 1ba853d67fd..efd2f0cb9b2 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0), "Address (to) can't be null !!"); + require(owner != address(0), "empty or zero transaction recipient"); return _ownedTokensCount[owner].current(); } @@ -67,9 +67,8 @@ contract ERC721 is ERC165, IERC721 { * @return address currently marked as the owner of the given token ID */ function ownerOf(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "TokenId doesn't exist !!"); address owner = _tokenOwner[tokenId]; - require(owner != address(0), "Address (to) can't be null !!"); + require(owner != address(0), "empty or zero transaction recipient"); return owner; } @@ -82,10 +81,10 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be approved */ function approve(address to, uint256 tokenId) public { - require(_exists(tokenId), "TokenId doesn't exist !!"); + require(_exists(tokenId), "tokenId to approve doesn't exist"); address owner = ownerOf(tokenId); - require(to != owner, "You can't approve yourself !!"); - require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "Only owner of the token can approve !!"); + require(to != owner, "transfer recipient must not be current owner"); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "sender is not owner nor is approved"); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); @@ -98,7 +97,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "TokenId doesn't exists !!"); + require(_exists(tokenId), "tokenId to aprove doesn't exists"); return _tokenApprovals[tokenId]; } @@ -109,7 +108,7 @@ contract ERC721 is ERC165, IERC721 { * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { - require(to != msg.sender, "You can't approve yourself !!"); + require(to != msg.sender, "sender can't be receipent"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } @@ -133,7 +132,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId), "You must be either Owner or Approved by Owner !!"); + require(_isApprovedOrOwner(msg.sender, tokenId),"sender is not owner nor is approved"); _transferFrom(from, to, tokenId); } @@ -150,7 +149,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function safeTransferFrom(address from, address to, uint256 tokenId) public { - safeTransferFrom(from, to, tokenId, ""); + safeTransferFrom(from, to, tokenId); } /** @@ -188,7 +187,7 @@ contract ERC721 is ERC165, IERC721 { * is an operator of the owner, or is the owner of the token */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { - require(_exists(tokenId), "TokenId doesn't exist !!"); + require(_exists(tokenId), "tokenId doesn't exist"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } @@ -200,8 +199,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0), "Address (to) can't be null !!"); - require(!_exists(tokenId), "TokenId already exist !!"); + require(to != address(0), "empty or zero transaction recipient"); + require(!_exists(tokenId), "tokenId to mint already exist"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); @@ -217,8 +216,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(_exists(tokenId), "TokenId doesn't exist !!"); - require(ownerOf(tokenId) == owner, "You are not the owner of this token !!"); + require(_exists(tokenId), "tokenId to burn doesn't exist"); + require(ownerOf(tokenId) == owner, "can only performed by owner"); _clearApproval(tokenId); @@ -245,9 +244,9 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(_exists(tokenId), "TokenId doesn't exist !!"); - require(ownerOf(tokenId) == from, "You are not the owner of this token !!"); - require(to != address(0), "Address (to) can't be null !!"); + require(_exists(tokenId), "tokenId to transfer doesn't exist"); + require(ownerOf(tokenId) == from, "can only performed by owner"); + require(to != address(0), "empty or zero transaction recipient"); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index 5181d7bc5e4..d20b5bc12c7 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -12,7 +12,7 @@ contract ERC721Burnable is ERC721 { * @param tokenId uint256 id of the ERC721 token to be burned. */ function burn(uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId), "You must be either Owner or Approved by Owner !!"); + require(_isApprovedOrOwner(msg.sender, tokenId), "sender is not owner nor is approved"); _burn(tokenId); } } From 9f92066fed33851a4d91b162e9642c8437e9cf6a Mon Sep 17 00:00:00 2001 From: prince Date: Wed, 10 Apr 2019 22:18:45 +0530 Subject: [PATCH 06/20] Changes in require statement --- contracts/token/ERC20/ERC20.sol | 10 +++++----- contracts/token/ERC721/ERC721.sol | 7 +++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 408c76397bf..3f807a71a7d 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0), "empty or zero transaction recipient"); + require(to != address(0), "zero transfer recipient"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0), "empty or zero transaction recipient"); + require(account != address(0), "zero mint recipient"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0), "empty or zero transaction recipient"); + require(account != address(0), "zero burn recipient"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0), "empty or zero transaction recipient"); - require(owner != address(0), "empty or zero transaction recipient"); + require(spender != address(0), "spender address can't be zero"); + require(owner != address(0), "owner address can't be zero"); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index efd2f0cb9b2..576dd6e8b96 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0), "empty or zero transaction recipient"); + require(owner != address(0), "balance query for zero address"); return _ownedTokensCount[owner].current(); } @@ -68,7 +68,7 @@ contract ERC721 is ERC165, IERC721 { */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; - require(owner != address(0), "empty or zero transaction recipient"); + require(owner != address(0), "owner doesn't exist"); return owner; } @@ -81,7 +81,6 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be approved */ function approve(address to, uint256 tokenId) public { - require(_exists(tokenId), "tokenId to approve doesn't exist"); address owner = ownerOf(tokenId); require(to != owner, "transfer recipient must not be current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "sender is not owner nor is approved"); @@ -149,7 +148,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function safeTransferFrom(address from, address to, uint256 tokenId) public { - safeTransferFrom(from, to, tokenId); + safeTransferFrom(from, to, tokenId, ""); } /** From 1d6c2cb847c3415fd74451c00957d88168fceadb Mon Sep 17 00:00:00 2001 From: prince Date: Wed, 10 Apr 2019 22:23:46 +0530 Subject: [PATCH 07/20] Changes in require statement --- contracts/token/ERC20/ERC20.sol | 6 +++--- contracts/token/ERC721/ERC721.sol | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 3f807a71a7d..b61284cbf89 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0), "zero transfer recipient"); + require(to != address(0), "transfer recipient is zero"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0), "zero mint recipient"); + require(account != address(0), "mint recipient is zero"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0), "zero burn recipient"); + require(account != address(0), "burn recipient is zero"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 576dd6e8b96..1b8bc2c9122 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -198,7 +198,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0), "empty or zero transaction recipient"); + require(to != address(0), "mint recipient is zero"); require(!_exists(tokenId), "tokenId to mint already exist"); _tokenOwner[tokenId] = to; @@ -245,7 +245,7 @@ contract ERC721 is ERC165, IERC721 { function _transferFrom(address from, address to, uint256 tokenId) internal { require(_exists(tokenId), "tokenId to transfer doesn't exist"); require(ownerOf(tokenId) == from, "can only performed by owner"); - require(to != address(0), "empty or zero transaction recipient"); + require(to != address(0), "transfer recipient is zero"); _clearApproval(tokenId); From f6c63600f301bbdece98e3632a3db9fce18e5aba Mon Sep 17 00:00:00 2001 From: prince Date: Wed, 10 Apr 2019 22:32:26 +0530 Subject: [PATCH 08/20] build pipeline fix --- contracts/token/ERC721/ERC721.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 1b8bc2c9122..984e68361fb 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -131,7 +131,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId),"sender is not owner nor is approved"); + require(_isApprovedOrOwner(msg.sender, tokenId), "sender is not owner nor is approved"); _transferFrom(from, to, tokenId); } From 4aafb81c09dc4126a0ad04d20a865eace448ae7e Mon Sep 17 00:00:00 2001 From: balajipachai Date: Sat, 13 Apr 2019 13:14:22 +0530 Subject: [PATCH 09/20] Changes as per @nventuro's comment. --- contracts/access/Roles.sol | 2 +- contracts/access/roles/WhitelistedRole.sol | 2 +- contracts/crowdsale/Crowdsale.sol | 8 ++---- .../distribution/FinalizableCrowdsale.sol | 4 +-- .../distribution/PostDeliveryCrowdsale.sol | 2 +- .../distribution/RefundableCrowdsale.sol | 6 ++-- .../RefundablePostDeliveryCrowdsale.sol | 5 ++-- .../crowdsale/emission/AllowanceCrowdsale.sol | 2 +- .../crowdsale/validation/CappedCrowdsale.sol | 2 +- .../IndividuallyCappedCrowdsale.sol | 2 +- .../crowdsale/validation/TimedCrowdsale.sol | 10 +++---- .../validation/WhitelistCrowdsale.sol | 2 +- contracts/drafts/ERC20Migrator.sol | 14 ++++------ contracts/drafts/ERC20Snapshot.sol | 4 +-- contracts/drafts/SignatureBouncer.sol | 2 +- contracts/drafts/TokenVesting.sol | 10 +++---- contracts/examples/SampleCrowdsale.sol | 2 +- contracts/math/SafeMath.sol | 10 +++---- .../ERC165/ERC165InterfacesSupported.sol | 2 +- contracts/mocks/ERC721ReceiverMock.sol | 2 +- contracts/mocks/ReentrancyAttack.sol | 2 +- contracts/mocks/ReentrancyMock.sol | 2 +- contracts/mocks/SafeERC20Helper.sol | 2 +- contracts/ownership/Ownable.sol | 4 +-- contracts/ownership/Secondary.sol | 4 +-- contracts/payment/PaymentSplitter.sol | 14 +++++----- .../payment/escrow/ConditionalEscrow.sol | 2 +- contracts/payment/escrow/RefundEscrow.sol | 4 +-- contracts/token/ERC20/ERC20.sol | 10 +++---- contracts/token/ERC20/ERC20Capped.sol | 2 +- contracts/token/ERC20/SafeERC20.sol | 2 +- contracts/token/ERC20/TokenTimelock.sol | 4 +-- contracts/token/ERC721/ERC721.sol | 28 ++++++++++--------- contracts/token/ERC721/ERC721Burnable.sol | 2 +- contracts/token/ERC721/ERC721Metadata.sol | 4 +-- 35 files changed, 88 insertions(+), 91 deletions(-) diff --git a/contracts/access/Roles.sol b/contracts/access/Roles.sol index 0beb0518fca..555c1db1a5d 100644 --- a/contracts/access/Roles.sol +++ b/contracts/access/Roles.sol @@ -30,7 +30,7 @@ library Roles { * @return bool */ function has(Role storage role, address account) internal view returns (bool) { - require(account != address(0), "Roles: if an account has this role can be checked for non zero-account."); + require(account != address(0), "Roles: account address is address(0)."); return role.bearer[account]; } } diff --git a/contracts/access/roles/WhitelistedRole.sol b/contracts/access/roles/WhitelistedRole.sol index 95af0373785..47dd85b41d1 100644 --- a/contracts/access/roles/WhitelistedRole.sol +++ b/contracts/access/roles/WhitelistedRole.sol @@ -18,7 +18,7 @@ contract WhitelistedRole is WhitelistAdminRole { Roles.Role private _whitelisteds; modifier onlyWhitelisted() { - require(isWhitelisted(msg.sender), "WhitelistedRole: caller doesn't have the Whitelist role."); + require(isWhitelisted(msg.sender), "WhitelistedRole: caller doesn't have the Whitelisted role."); _; } diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 21e01e1e4bc..8b9f94dc8c9 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -55,9 +55,8 @@ contract Crowdsale is ReentrancyGuard { */ constructor (uint256 rate, address payable wallet, IERC20 token) public { require(rate > 0, "Crowdsale: rate is 0."); - require(wallet != address(0), "Crowdsale: wallet address can only be non-zero address."); - // solhint-disable-next-line max-line-length - require(address(token) != address(0), "Crowdsale: token address can only be non-zero address."); + require(wallet != address(0), "Crowdsale: wallet address is address(0)."); + require(address(token) != address(0), "Crowdsale: token address is address(0)."); _rate = rate; _wallet = wallet; @@ -137,8 +136,7 @@ contract Crowdsale is ReentrancyGuard { * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - // solhint-disable-next-line max-line-length - require(beneficiary != address(0), "Crowdsale: beneficiary address can only be non-zero address."); + require(beneficiary != address(0), "Crowdsale: beneficiary address is address(0)."); require(weiAmount != 0, "Crowdsale: weiAmount is 0."); } diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index 0ff42a80be9..23e87d3d403 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -31,8 +31,8 @@ contract FinalizableCrowdsale is TimedCrowdsale { * work. Calls the contract's finalization function. */ function finalize() public { - require(!_finalized, "FinalizableCrowdsale: crowdsale is already finalized."); - require(hasClosed(), "FinalizableCrowdsale: crowdsale has not been closed yet."); + require(!_finalized, "FinalizableCrowdsale: crowdsale is finalized."); + require(hasClosed(), "FinalizableCrowdsale: crowdsale is not closed."); _finalized = true; diff --git a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol index a2c3d3e1ab7..81c770d5167 100644 --- a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol @@ -17,7 +17,7 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { - require(hasClosed(), "PostDeliveryCrowdsale: crowdsale has not been closed yet."); + require(hasClosed(), "PostDeliveryCrowdsale: crowdsale is not closed."); uint256 amount = _balances[beneficiary]; require(amount > 0, "PostDeliveryCrowdsale: withdrawal amount is 0."); _balances[beneficiary] = 0; diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index f55a95d26e0..459e87a0611 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -28,7 +28,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param goal Funding goal */ constructor (uint256 goal) public { - require(goal > 0, "RefundableCrowdsale: "); + require(goal > 0, "RefundableCrowdsale: funding goal is 0."); _escrow = new RefundEscrow(wallet()); _goal = goal; } @@ -45,8 +45,8 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param refundee Whose refund will be claimed. */ function claimRefund(address payable refundee) public { - require(finalized(), "RefundableCrowdsale: crowdsale has not been finalized yet."); - require(!goalReached(), "RefundableCrowdsale: funding goal has already reached, cannot claim refund."); + require(finalized(), "RefundableCrowdsale: crowdsale is not finalized."); + require(!goalReached(), "RefundableCrowdsale: funding goal reached, cannot claim refund."); _escrow.withdraw(refundee); } diff --git a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol index 0fc70e133fc..607c7fc3c10 100644 --- a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol @@ -12,9 +12,8 @@ import "./PostDeliveryCrowdsale.sol"; */ contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale { function withdrawTokens(address beneficiary) public { - require(finalized(), "RefundablePostDeliveryCrowdsale: crowdsale has not been finalized yet."); - //solhint-disable-next-line max-line-length - require(goalReached(), "RefundablePostDeliveryCrowdsale: funding goal has not reached, cannot withdraw tokens."); + require(finalized(), "RefundablePostDeliveryCrowdsale: crowdsale is not finalized."); + require(goalReached(), "RefundablePostDeliveryCrowdsale: funding goal not reached, cannot withdraw tokens."); super.withdrawTokens(beneficiary); } diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index 35790c38cb3..c060a7256cb 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -21,7 +21,7 @@ contract AllowanceCrowdsale is Crowdsale { * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale. */ constructor (address tokenWallet) public { - require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet address can only be non-zero address."); + require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet address is address(0)."); _tokenWallet = tokenWallet; } diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 70bdc538256..6d59b934221 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -43,6 +43,6 @@ contract CappedCrowdsale is Crowdsale { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); - require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: invalid purchase."); + require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: token cap exceeded."); } } diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index f732916048c..2753bc7854a 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -49,7 +49,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); // solhint-disable-next-line max-line-length - require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: invalid purchase."); + require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: beneficiary's funding cap exceeded."); } /** diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index a0bf8aa0b9e..6d638efc78d 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -24,7 +24,7 @@ contract TimedCrowdsale is Crowdsale { * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { - require(isOpen(), "TimedCrowdsale: "); + require(isOpen(), "TimedCrowdsale: crowdsale is closed."); _; } @@ -35,9 +35,9 @@ contract TimedCrowdsale is Crowdsale { */ constructor (uint256 openingTime, uint256 closingTime) public { // solhint-disable-next-line not-rely-on-time - require(openingTime >= block.timestamp, "TimedCrowdsale: crowdsale opening time is < current time."); + require(openingTime >= block.timestamp, "TimedCrowdsale: crowdsale opening time is less than current time."); // solhint-disable-next-line max-line-length - require(closingTime > openingTime, "TimedCrowdsale: crowdsale closing time is <= crowdsale opening time."); + require(closingTime > openingTime, "TimedCrowdsale: crowdsale closing time is less than or equal to crowdsale opening time."); _openingTime = openingTime; _closingTime = closingTime; @@ -88,9 +88,9 @@ contract TimedCrowdsale is Crowdsale { * @param newClosingTime Crowdsale closing time */ function _extendTime(uint256 newClosingTime) internal { - require(!hasClosed(), "TimedCrowdsale: "); + require(!hasClosed(), "TimedCrowdsale: crowdsale period has elapsed."); // solhint-disable-next-line max-line-length - require(newClosingTime > _closingTime, "TimedCrowdsale: "); + require(newClosingTime > _closingTime, "TimedCrowdsale: crowdsale new closing time is less than or equal to older closing time."); emit TimedCrowdsaleExtended(_closingTime, newClosingTime); _closingTime = newClosingTime; diff --git a/contracts/crowdsale/validation/WhitelistCrowdsale.sol b/contracts/crowdsale/validation/WhitelistCrowdsale.sol index bd7a395728a..df350fcad0e 100644 --- a/contracts/crowdsale/validation/WhitelistCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistCrowdsale.sol @@ -15,7 +15,7 @@ contract WhitelistCrowdsale is WhitelistedRole, Crowdsale { * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { - require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelist role."); + require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role."); super._preValidatePurchase(_beneficiary, _weiAmount); } } diff --git a/contracts/drafts/ERC20Migrator.sol b/contracts/drafts/ERC20Migrator.sol index 921f3879412..2bd7ba9ec8a 100644 --- a/contracts/drafts/ERC20Migrator.sol +++ b/contracts/drafts/ERC20Migrator.sol @@ -44,7 +44,7 @@ contract ERC20Migrator { * @param legacyToken address of the old token contract */ constructor (IERC20 legacyToken) public { - require(address(legacyToken) != address(0), "ERC20Migrator: "); + require(address(legacyToken) != address(0), "ERC20Migrator: legacy token address is address(0)."); _legacyToken = legacyToken; } @@ -68,12 +68,10 @@ contract ERC20Migrator { * @param newToken_ the token that will be minted */ function beginMigration(ERC20Mintable newToken_) public { - // solhint-disable-next-line max-line-length - require(address(_newToken) == address(0), "ERC20Migrator: "); - // solhint-disable-next-line max-line-length - require(address(newToken_) != address(0), "ERC20Migrator: "); - // solhint-disable-next-line max-line-length - require(newToken_.isMinter(address(this)), "ERC20Migrator: "); + require(address(_newToken) == address(0), "ERC20Migrator: previous new token address is address(0)."); + require(address(newToken_) != address(0), "ERC20Migrator: current new token address is address(0)."); + //solhint-disable-next-line max-line-length + require(newToken_.isMinter(address(this)), "ERC20Migrator: this contract is not a minter for current new token."); _newToken = newToken_; } @@ -85,7 +83,7 @@ contract ERC20Migrator { * @param amount amount of tokens to be migrated */ function migrate(address account, uint256 amount) public { - require(address(_newToken) != address(0), "ERC20Migrator: new token address can only be non-zero address."); + require(address(_newToken) != address(0), "ERC20Migrator: current new token address is address(0)."); _legacyToken.safeTransferFrom(account, address(this), amount); _newToken.mint(account, amount); } diff --git a/contracts/drafts/ERC20Snapshot.sol b/contracts/drafts/ERC20Snapshot.sol index 69f907342ab..1a67ed9d0f1 100644 --- a/contracts/drafts/ERC20Snapshot.sol +++ b/contracts/drafts/ERC20Snapshot.sol @@ -101,9 +101,9 @@ contract ERC20Snapshot is ERC20 { function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { - require(snapshotId > 0, "ERC20Snapshot: the snapshot id is 0."); + require(snapshotId > 0, "ERC20Snapshot: snapshot id is 0."); // solhint-disable-next-line max-line-length - require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: the provided snapshot id > current snapshot id."); + require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: provided snapshot id is greater than current snapshot id."); uint256 index = snapshots.ids.findUpperBound(snapshotId); diff --git a/contracts/drafts/SignatureBouncer.sol b/contracts/drafts/SignatureBouncer.sol index ae64bf5312d..76776affd62 100644 --- a/contracts/drafts/SignatureBouncer.sol +++ b/contracts/drafts/SignatureBouncer.sol @@ -99,7 +99,7 @@ contract SignatureBouncer is SignerRole { * @return bool */ function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) { - require(msg.data.length > _SIGNATURE_SIZE, "SignatureBouncer: length of caller data is < 96."); + require(msg.data.length > _SIGNATURE_SIZE, "SignatureBouncer: length of caller data is less than 96."); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index cdfc9f05716..0a6d136a008 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -47,12 +47,12 @@ contract TokenVesting is Ownable { * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { - require(beneficiary != address(0), "TokenVesting: beneficiary can only be non-zero address."); + require(beneficiary != address(0), "TokenVesting: beneficiary address is address(0)."); // solhint-disable-next-line max-line-length - require(cliffDuration <= duration, "TokenVesting: duration when tokens begin to vest > duration in which tokens will vest."); + require(cliffDuration <= duration, "TokenVesting: duration when tokens begin to vest is greater than duration in which tokens will vest."); require(duration > 0, "TokenVesting: duration in which tokens will vest is 0."); // solhint-disable-next-line max-line-length - require(start.add(duration) > block.timestamp, "TokenVesting: time at which vesting starts must be < current block timestamp."); + require(start.add(duration) > block.timestamp, "TokenVesting: time at which vesting starts must be less than current block timestamp."); _beneficiary = beneficiary; _revocable = revocable; @@ -132,8 +132,8 @@ contract TokenVesting is Ownable { * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { - require(_revocable, "TokenVesting: can only revoke if revoking is allowed."); - require(!_revoked[address(token)], "TokenVesting: revoked for a token address is set to true."); + require(_revocable, "TokenVesting: revoking is not allowed."); + require(!_revoked[address(token)], "TokenVesting: revoked for token address is true."); uint256 balance = token.balanceOf(address(this)); diff --git a/contracts/examples/SampleCrowdsale.sol b/contracts/examples/SampleCrowdsale.sol index 77a1cc0daed..07c9fe19468 100644 --- a/contracts/examples/SampleCrowdsale.sol +++ b/contracts/examples/SampleCrowdsale.sol @@ -48,6 +48,6 @@ contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsal { //As goal needs to be met for a successful crowdsale //the value needs to less or equal than a cap which is limit for accepted funds - require(goal <= cap, "from OpenZeppelin's:SampleCrowdsale.sol:constructor()."); + require(goal <= cap, "SampleCrowdSale: funding goal is greater than token cap."); } } diff --git a/contracts/math/SafeMath.sol b/contracts/math/SafeMath.sol index 64c6fb1154f..8cea6068ffc 100644 --- a/contracts/math/SafeMath.sol +++ b/contracts/math/SafeMath.sol @@ -17,7 +17,7 @@ library SafeMath { } uint256 c = a * b; - require(c / a == b, "from OpenZeppelin's:SafeMath.sol:mul()."); + require(c / a == b, "SafeMath: c / a == b."); return c; } @@ -27,7 +27,7 @@ library SafeMath { */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 - require(b > 0, "from OpenZeppelin's:SafeMath.sol:div()."); + require(b > 0, "SafeMath: division by zero in div()."); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold @@ -38,7 +38,7 @@ library SafeMath { * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { - require(b <= a, "from OpenZeppelin's:SafeMath.sol:sub()."); + require(b <= a, "SafeMath: b <= a."); uint256 c = a - b; return c; @@ -49,7 +49,7 @@ library SafeMath { */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; - require(c >= a, "from OpenZeppelin's:SafeMath.sol:add()."); + require(c >= a, "SafeMath: c >= a."); return c; } @@ -59,7 +59,7 @@ library SafeMath { * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { - require(b != 0, "from OpenZeppelin's:SafeMath.sol:mod()."); + require(b != 0, "SafeMath: division by zero in mod()."); return a % b; } } diff --git a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol index ec2ae48ab9d..b3c06f98e96 100644 --- a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +++ b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol @@ -43,7 +43,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { * @dev Private method for registering an interface. */ function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff, "from OpenZeppelin's:ERC165InterfacesSupported.sol:_registerInterface()."); + require(interfaceId != 0xffffffff, "ERC165InterfacesSupported: invalid interface id."); _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/mocks/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index fa91e0e1d2f..5ed5811256f 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -16,7 +16,7 @@ contract ERC721ReceiverMock is IERC721Receiver { function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4) { - require(!_reverts, "from OpenZeppelin's:ERC721ReceiverMock.sol:onERC721Received()."); + require(!_reverts, "ERC721ReceiverMock: !_reverts."); emit Received(operator, from, tokenId, data, gasleft()); return _retval; } diff --git a/contracts/mocks/ReentrancyAttack.sol b/contracts/mocks/ReentrancyAttack.sol index d0bc76c1182..dd0427fe241 100644 --- a/contracts/mocks/ReentrancyAttack.sol +++ b/contracts/mocks/ReentrancyAttack.sol @@ -4,6 +4,6 @@ contract ReentrancyAttack { function callSender(bytes4 data) public { // solhint-disable-next-line avoid-low-level-calls (bool success,) = msg.sender.call(abi.encodeWithSelector(data)); - require(success, "from OpenZeppelin's:ReentrancyAttack.sol:callSender()."); + require(success, "ReentrancyAttack: previous low-level call returned false."); } } diff --git a/contracts/mocks/ReentrancyMock.sol b/contracts/mocks/ReentrancyMock.sol index a8dbf6fe357..84d10fc6838 100644 --- a/contracts/mocks/ReentrancyMock.sol +++ b/contracts/mocks/ReentrancyMock.sol @@ -26,7 +26,7 @@ contract ReentrancyMock is ReentrancyGuard { count(); // solhint-disable-next-line avoid-low-level-calls (bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); - require(success, "from OpenZeppelin's:ReentrancyMock.sol:countThisRecursive()."); + require(success, "ReentrancyMock: previous low-level call returned false."); } } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index fd7c483fa09..3c72bdebf77 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -26,7 +26,7 @@ contract ERC20ReturnFalseMock { } function allowance(address, address) public view returns (uint256) { - require(_dummy == 0, "from OpenZeppelin's:SafeERC20Helper.sol:allowance()."); + require(_dummy == 0, "SafeERC20Helper: _dummy == 0."); return 0; } } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 5472e5d1a4f..e370046136d 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -30,7 +30,7 @@ contract Ownable { * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { - require(isOwner(), "Ownable: "); + require(isOwner(), "Ownable: caller is not the owner."); _; } @@ -66,7 +66,7 @@ contract Ownable { * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { - require(newOwner != address(0), "Ownable: new owner can only be non-zero address."); + require(newOwner != address(0), "Ownable: new owner address is address(0)."); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } diff --git a/contracts/ownership/Secondary.sol b/contracts/ownership/Secondary.sol index d88a62178a9..1f563cd41d4 100644 --- a/contracts/ownership/Secondary.sol +++ b/contracts/ownership/Secondary.sol @@ -23,7 +23,7 @@ contract Secondary { * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { - require(msg.sender == _primary, "Secondary: "); + require(msg.sender == _primary, "Secondary: caller is not the primary account."); _; } @@ -39,7 +39,7 @@ contract Secondary { * @param recipient The address of new primary. */ function transferPrimary(address recipient) public onlyPrimary { - require(recipient != address(0), "Secondary: recipient address can only be non-zero address."); + require(recipient != address(0), "Secondary: recipient address is address(0)."); _primary = recipient; emit PrimaryTransferred(_primary); } diff --git a/contracts/payment/PaymentSplitter.sol b/contracts/payment/PaymentSplitter.sol index ad6e607b2a1..f6bb5bea969 100644 --- a/contracts/payment/PaymentSplitter.sol +++ b/contracts/payment/PaymentSplitter.sol @@ -38,8 +38,8 @@ contract PaymentSplitter { */ constructor (address[] memory payees, uint256[] memory shares) public payable { // solhint-disable-next-line max-line-length - require(payees.length == shares.length, "PaymentSplitter: "); - require(payees.length > 0, "PaymentSplitter: "); + require(payees.length == shares.length, "PaymentSplitter: payees length is not equal to shares length."); + require(payees.length > 0, "PaymentSplitter: payees length is 0."); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares[i]); @@ -99,12 +99,12 @@ contract PaymentSplitter { * total shares and their previous withdrawals. */ function release(address payable account) public { - require(_shares[account] > 0, "PaymentSplitter: "); + require(_shares[account] > 0, "PaymentSplitter: shares of account is 0."); uint256 totalReceived = address(this).balance.add(_totalReleased); uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); - require(payment != 0, "PaymentSplitter: "); + require(payment != 0, "PaymentSplitter: payment is 0."); _released[account] = _released[account].add(payment); _totalReleased = _totalReleased.add(payment); @@ -119,9 +119,9 @@ contract PaymentSplitter { * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { - require(account != address(0), "PaymentSplitter: account can only be non-zero address."); - require(shares_ > 0, "PaymentSplitter: the shares must be > 0."); - require(_shares[account] == 0, "PaymentSplitter: _shares[account] == 0."); + require(account != address(0), "PaymentSplitter: account address is address(0)."); + require(shares_ > 0, "PaymentSplitter: shares are 0."); + require(_shares[account] == 0, "PaymentSplitter: shares of account is greater than 0."); _payees.push(account); _shares[account] = shares_; diff --git a/contracts/payment/escrow/ConditionalEscrow.sol b/contracts/payment/escrow/ConditionalEscrow.sol index 031de5957b8..b35c0a2d89a 100644 --- a/contracts/payment/escrow/ConditionalEscrow.sol +++ b/contracts/payment/escrow/ConditionalEscrow.sol @@ -16,7 +16,7 @@ contract ConditionalEscrow is Escrow { function withdrawalAllowed(address payee) public view returns (bool); function withdraw(address payable payee) public { - require(withdrawalAllowed(payee), "ConditionalEscrow: payee should have been allowed to withdraw."); + require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw."); super.withdraw(payee); } } diff --git a/contracts/payment/escrow/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol index 54da26cf1ae..5058c11b6ab 100644 --- a/contracts/payment/escrow/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -27,7 +27,7 @@ contract RefundEscrow is ConditionalEscrow { * @param beneficiary The beneficiary of the deposits. */ constructor (address payable beneficiary) public { - require(beneficiary != address(0), "RefundEscrow: beneficiary can only be non-zero address."); + require(beneficiary != address(0), "RefundEscrow: beneficiary address is address(0)."); _beneficiary = beneficiary; _state = State.Active; } @@ -78,7 +78,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Withdraws the beneficiary's funds. */ function beneficiaryWithdraw() public { - require(_state == State.Closed, "RefundEscrow: _state == State.Closed."); + require(_state == State.Closed, "RefundEscrow: _state == State.Closed in beneficiaryWithdraw()."); _beneficiary.transfer(address(this).balance); } diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 9158601e1f2..127e72a3cf3 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0), "ERC20: "); + require(to != address(0), "ERC20: to address is address(0)."); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0), "ERC20: "); + require(account != address(0), "ERC20: account address is address(0) in _mint()."); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0), "ERC20: "); + require(account != address(0), "ERC20: account address is address(0) in _burn()."); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0), "ERC20: spender can only be non-zero address."); - require(owner != address(0), "ERC20: owner can only be non-zero address."); + require(spender != address(0), "ERC20: spender address is address(0)."); + require(owner != address(0), "ERC20: owner address is address(0)."); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index ada543bf000..48e2fad1e4c 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -10,7 +10,7 @@ contract ERC20Capped is ERC20Mintable { uint256 private _cap; constructor (uint256 cap) public { - require(cap > 0, "ERC20Capped: capacity must be > 0."); + require(cap > 0, "ERC20Capped: token cap is 0."); _cap = cap; } diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 40ad997a8f5..620ef1998a7 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -63,7 +63,7 @@ library SafeERC20 { // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); - require(success, "SafeERC20: the previous call should have succeeded."); + require(success, "SafeERC20: the previous low-level call returned false."); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index d313c6afa8b..9106a8d00c6 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -21,7 +21,7 @@ contract TokenTimelock { constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { // solhint-disable-next-line not-rely-on-time - require(releaseTime > block.timestamp, "TokenTimelock: release time < current block time."); + require(releaseTime > block.timestamp, "TokenTimelock: release time is less than current block time."); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime; @@ -53,7 +53,7 @@ contract TokenTimelock { */ function release() public { // solhint-disable-next-line not-rely-on-time - require(block.timestamp >= _releaseTime, "TokenTimelock: current block time < release time."); + require(block.timestamp >= _releaseTime, "TokenTimelock: current block time is less than release time."); uint256 amount = _token.balanceOf(address(this)); require(amount > 0, "TokenTimelock: amount to release is 0."); diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index f4f409a5611..56b0d0897c3 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0), "ERC721: owner can only be non-zero address in balanceOf()."); + require(owner != address(0), "ERC721: owner address is address(0) in balanceOf()."); return _ownedTokensCount[owner].current(); } @@ -68,7 +68,7 @@ contract ERC721 is ERC165, IERC721 { */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; - require(owner != address(0), "ERC721: owner can only be non-zero address in ownerOf()."); + require(owner != address(0), "ERC721: owner address is address(0) in ownerOf()."); return owner; } @@ -82,9 +82,9 @@ contract ERC721 is ERC165, IERC721 { */ function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); - require(to != owner, "ERC721: to address must not be owner address."); + require(to != owner, "ERC721: to address is equal to the owner address."); // solhint-disable-next-line max-line-length - require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: caller should either be the owner or an operator."); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: caller is neither the owner nor an operator in approve()."); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); @@ -97,7 +97,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "ERC721: the tokenId should be in existence."); + require(_exists(tokenId), "ERC721: the tokenId does not exist."); return _tokenApprovals[tokenId]; } @@ -108,7 +108,7 @@ contract ERC721 is ERC165, IERC721 { * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { - require(to != msg.sender, "ERC721: to address must not be the caller."); + require(to != msg.sender, "ERC721: to address is equal to the caller."); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } @@ -132,7 +132,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function transferFrom(address from, address to, uint256 tokenId) public { - require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: "); + //solhint-disable-next-line max-line-length + require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: caller is neither the owner nor an operator in transferFrom()."); _transferFrom(from, to, tokenId); } @@ -166,7 +167,8 @@ contract ERC721 is ERC165, IERC721 { */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); - require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: "); + //solhint-disable-next-line max-line-length + require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: to address does not implement ERC721Receiver."); } /** @@ -198,8 +200,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0), "ERC721: to address can only be non-zero address."); - require(!_exists(tokenId), "ERC721: !_exists(tokenId)"); + require(to != address(0), "ERC721: to address is address(0) in _mint()."); + require(!_exists(tokenId), "ERC721: token id exists."); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); @@ -215,7 +217,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner, "ERC721: ownerOf(tokenId) == owner"); + require(ownerOf(tokenId) == owner, "ERC721: owner is not the owner of tokenId in _burn()."); _clearApproval(tokenId); @@ -242,8 +244,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from, "ERC721: ownerOf(tokenId) == from"); - require(to != address(0), "ERC721: to can only be a non-zero address."); + require(ownerOf(tokenId) == from, "ERC721: from is not the owner of tokenId."); + require(to != address(0), "ERC721: to address is address(0) in _transferFrom()."); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index 58be8660129..0e8dde42c8f 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -13,7 +13,7 @@ contract ERC721Burnable is ERC721 { */ function burn(uint256 tokenId) public { //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721Burnable: caller can either be the owner or an approved address."); + require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721Burnable: caller is neither the owner nor an approved address."); _burn(tokenId); } } diff --git a/contracts/token/ERC721/ERC721Metadata.sol b/contracts/token/ERC721/ERC721Metadata.sol index a4ecd47a7ef..796ce8e9b13 100644 --- a/contracts/token/ERC721/ERC721Metadata.sol +++ b/contracts/token/ERC721/ERC721Metadata.sol @@ -55,7 +55,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId), "ERC721Metadata: the tokenId should be in existence in tokenURI()."); + require(_exists(tokenId), "ERC721Metadata: the tokenId does not exist in tokenURI()."); return _tokenURIs[tokenId]; } @@ -66,7 +66,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { - require(_exists(tokenId), "ERC721Metadata: the tokenId should be in existence in _setTokenURI()"); + require(_exists(tokenId), "ERC721Metadata: the tokenId does not exist in _setTokenURI()"); _tokenURIs[tokenId] = uri; } From 04ce66d0df6ba45c561df517be991b222775187e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Mon, 15 Apr 2019 18:28:04 -0300 Subject: [PATCH 10/20] Update revert reason strings. --- contracts/access/Roles.sol | 6 ++--- contracts/access/roles/CapperRole.sol | 2 +- contracts/access/roles/MinterRole.sol | 2 +- contracts/access/roles/PauserRole.sol | 2 +- contracts/access/roles/SignerRole.sol | 2 +- contracts/access/roles/WhitelistAdminRole.sol | 2 +- contracts/access/roles/WhitelistedRole.sol | 2 +- contracts/crowdsale/Crowdsale.sol | 10 +++---- .../distribution/FinalizableCrowdsale.sol | 4 +-- .../distribution/PostDeliveryCrowdsale.sol | 4 +-- .../distribution/RefundableCrowdsale.sol | 6 ++--- .../RefundablePostDeliveryCrowdsale.sol | 4 +-- .../crowdsale/emission/AllowanceCrowdsale.sol | 2 +- .../crowdsale/emission/MintedCrowdsale.sol | 2 +- .../price/IncreasingPriceCrowdsale.sol | 4 +-- .../crowdsale/validation/CappedCrowdsale.sol | 4 +-- .../IndividuallyCappedCrowdsale.sol | 2 +- .../crowdsale/validation/TimedCrowdsale.sol | 10 +++---- .../validation/WhitelistCrowdsale.sol | 2 +- contracts/drafts/ERC20Migrator.sol | 10 +++---- contracts/drafts/ERC20Snapshot.sol | 4 +-- contracts/drafts/SignatureBouncer.sol | 8 +++--- contracts/drafts/SignedSafeMath.sol | 12 ++++----- contracts/drafts/TokenVesting.sol | 14 +++++----- contracts/examples/SampleCrowdsale.sol | 2 +- contracts/introspection/ERC165.sol | 2 +- contracts/lifecycle/Pausable.sol | 4 +-- contracts/math/SafeMath.sol | 10 +++---- .../ERC165/ERC165InterfacesSupported.sol | 2 +- contracts/mocks/ERC721ReceiverMock.sol | 2 +- contracts/mocks/ReentrancyAttack.sol | 2 +- contracts/mocks/ReentrancyMock.sol | 2 +- contracts/mocks/SafeERC20Helper.sol | 2 +- contracts/ownership/Ownable.sol | 4 +-- contracts/ownership/Secondary.sol | 4 +-- contracts/payment/PaymentSplitter.sol | 14 +++++----- .../payment/escrow/ConditionalEscrow.sol | 2 +- contracts/payment/escrow/RefundEscrow.sol | 10 +++---- contracts/token/ERC20/ERC20.sol | 10 +++---- contracts/token/ERC20/ERC20Capped.sol | 4 +-- contracts/token/ERC20/SafeERC20.sol | 4 +-- contracts/token/ERC20/TokenTimelock.sol | 6 ++--- contracts/token/ERC721/ERC721.sol | 26 +++++++++---------- contracts/token/ERC721/ERC721Burnable.sol | 2 +- contracts/token/ERC721/ERC721Metadata.sol | 2 +- contracts/utils/ReentrancyGuard.sol | 2 +- 46 files changed, 119 insertions(+), 119 deletions(-) diff --git a/contracts/access/Roles.sol b/contracts/access/Roles.sol index 555c1db1a5d..708391f2a81 100644 --- a/contracts/access/Roles.sol +++ b/contracts/access/Roles.sol @@ -13,7 +13,7 @@ library Roles { * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { - require(!has(role, account), "Roles: account has already given access to this role."); + require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } @@ -21,7 +21,7 @@ library Roles { * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { - require(has(role, account), "Roles: account does not have access to this role to remove."); + require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } @@ -30,7 +30,7 @@ library Roles { * @return bool */ function has(Role storage role, address account) internal view returns (bool) { - require(account != address(0), "Roles: account address is address(0)."); + require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } } diff --git a/contracts/access/roles/CapperRole.sol b/contracts/access/roles/CapperRole.sol index 0e6321d9229..1e7baa9e930 100644 --- a/contracts/access/roles/CapperRole.sol +++ b/contracts/access/roles/CapperRole.sol @@ -15,7 +15,7 @@ contract CapperRole { } modifier onlyCapper() { - require(isCapper(msg.sender), "CapperRole: caller doesn't have the Capper role."); + require(isCapper(msg.sender), "CapperRole: caller does not have the Capper role"); _; } diff --git a/contracts/access/roles/MinterRole.sol b/contracts/access/roles/MinterRole.sol index ba350acb1c6..3dc195eee68 100644 --- a/contracts/access/roles/MinterRole.sol +++ b/contracts/access/roles/MinterRole.sol @@ -15,7 +15,7 @@ contract MinterRole { } modifier onlyMinter() { - require(isMinter(msg.sender), "MinterRole: caller doesn't have the Minter role."); + require(isMinter(msg.sender), "MinterRole: caller does not have the Minter role"); _; } diff --git a/contracts/access/roles/PauserRole.sol b/contracts/access/roles/PauserRole.sol index cc2ca65766c..e9d6da8fcf8 100644 --- a/contracts/access/roles/PauserRole.sol +++ b/contracts/access/roles/PauserRole.sol @@ -15,7 +15,7 @@ contract PauserRole { } modifier onlyPauser() { - require(isPauser(msg.sender), "PauserRole: caller doesn't have the Pauser role."); + require(isPauser(msg.sender), "PauserRole: caller does not have the Pauser role"); _; } diff --git a/contracts/access/roles/SignerRole.sol b/contracts/access/roles/SignerRole.sol index 22a42999dbe..33eebf17edb 100644 --- a/contracts/access/roles/SignerRole.sol +++ b/contracts/access/roles/SignerRole.sol @@ -15,7 +15,7 @@ contract SignerRole { } modifier onlySigner() { - require(isSigner(msg.sender), "SignerRole: caller doesn't have the Signer role."); + require(isSigner(msg.sender), "SignerRole: caller does not have the Signer role"); _; } diff --git a/contracts/access/roles/WhitelistAdminRole.sol b/contracts/access/roles/WhitelistAdminRole.sol index 8a7255fe9df..7b268738f38 100644 --- a/contracts/access/roles/WhitelistAdminRole.sol +++ b/contracts/access/roles/WhitelistAdminRole.sol @@ -19,7 +19,7 @@ contract WhitelistAdminRole { } modifier onlyWhitelistAdmin() { - require(isWhitelistAdmin(msg.sender), "WhitelistAdminRole: caller doesn't have the WhitelistAdmin role."); + require(isWhitelistAdmin(msg.sender), "WhitelistAdminRole: caller does not have the WhitelistAdmin role"); _; } diff --git a/contracts/access/roles/WhitelistedRole.sol b/contracts/access/roles/WhitelistedRole.sol index 47dd85b41d1..4c764348abd 100644 --- a/contracts/access/roles/WhitelistedRole.sol +++ b/contracts/access/roles/WhitelistedRole.sol @@ -18,7 +18,7 @@ contract WhitelistedRole is WhitelistAdminRole { Roles.Role private _whitelisteds; modifier onlyWhitelisted() { - require(isWhitelisted(msg.sender), "WhitelistedRole: caller doesn't have the Whitelisted role."); + require(isWhitelisted(msg.sender), "WhitelistedRole: caller does not have the Whitelisted role"); _; } diff --git a/contracts/crowdsale/Crowdsale.sol b/contracts/crowdsale/Crowdsale.sol index 8b9f94dc8c9..7f824bc48f0 100644 --- a/contracts/crowdsale/Crowdsale.sol +++ b/contracts/crowdsale/Crowdsale.sol @@ -54,9 +54,9 @@ contract Crowdsale is ReentrancyGuard { * @param token Address of the token being sold */ constructor (uint256 rate, address payable wallet, IERC20 token) public { - require(rate > 0, "Crowdsale: rate is 0."); - require(wallet != address(0), "Crowdsale: wallet address is address(0)."); - require(address(token) != address(0), "Crowdsale: token address is address(0)."); + require(rate > 0, "Crowdsale: rate is 0"); + require(wallet != address(0), "Crowdsale: wallet is the zero address"); + require(address(token) != address(0), "Crowdsale: token is the zero address"); _rate = rate; _wallet = wallet; @@ -136,8 +136,8 @@ contract Crowdsale is ReentrancyGuard { * @param weiAmount Value in wei involved in the purchase */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - require(beneficiary != address(0), "Crowdsale: beneficiary address is address(0)."); - require(weiAmount != 0, "Crowdsale: weiAmount is 0."); + require(beneficiary != address(0), "Crowdsale: beneficiary is the zero address"); + require(weiAmount != 0, "Crowdsale: weiAmount is 0"); } /** diff --git a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol index 23e87d3d403..6910d187c3f 100644 --- a/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ b/contracts/crowdsale/distribution/FinalizableCrowdsale.sol @@ -31,8 +31,8 @@ contract FinalizableCrowdsale is TimedCrowdsale { * work. Calls the contract's finalization function. */ function finalize() public { - require(!_finalized, "FinalizableCrowdsale: crowdsale is finalized."); - require(hasClosed(), "FinalizableCrowdsale: crowdsale is not closed."); + require(!_finalized, "FinalizableCrowdsale: already finalized"); + require(hasClosed(), "FinalizableCrowdsale: not closed"); _finalized = true; diff --git a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol index 81c770d5167..7ccebd62788 100644 --- a/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol @@ -17,9 +17,9 @@ contract PostDeliveryCrowdsale is TimedCrowdsale { * @param beneficiary Whose tokens will be withdrawn. */ function withdrawTokens(address beneficiary) public { - require(hasClosed(), "PostDeliveryCrowdsale: crowdsale is not closed."); + require(hasClosed(), "PostDeliveryCrowdsale: not closed"); uint256 amount = _balances[beneficiary]; - require(amount > 0, "PostDeliveryCrowdsale: withdrawal amount is 0."); + require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens"); _balances[beneficiary] = 0; _deliverTokens(beneficiary, amount); } diff --git a/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/contracts/crowdsale/distribution/RefundableCrowdsale.sol index 459e87a0611..a16609e69db 100644 --- a/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundableCrowdsale.sol @@ -28,7 +28,7 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param goal Funding goal */ constructor (uint256 goal) public { - require(goal > 0, "RefundableCrowdsale: funding goal is 0."); + require(goal > 0, "RefundableCrowdsale: goal is 0"); _escrow = new RefundEscrow(wallet()); _goal = goal; } @@ -45,8 +45,8 @@ contract RefundableCrowdsale is FinalizableCrowdsale { * @param refundee Whose refund will be claimed. */ function claimRefund(address payable refundee) public { - require(finalized(), "RefundableCrowdsale: crowdsale is not finalized."); - require(!goalReached(), "RefundableCrowdsale: funding goal reached, cannot claim refund."); + require(finalized(), "RefundableCrowdsale: not finalized"); + require(!goalReached(), "RefundableCrowdsale: goal reached"); _escrow.withdraw(refundee); } diff --git a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol index 607c7fc3c10..c713e80b212 100644 --- a/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol +++ b/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol @@ -12,8 +12,8 @@ import "./PostDeliveryCrowdsale.sol"; */ contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale { function withdrawTokens(address beneficiary) public { - require(finalized(), "RefundablePostDeliveryCrowdsale: crowdsale is not finalized."); - require(goalReached(), "RefundablePostDeliveryCrowdsale: funding goal not reached, cannot withdraw tokens."); + require(finalized(), "RefundablePostDeliveryCrowdsale: not finalized"); + require(goalReached(), "RefundablePostDeliveryCrowdsale: goal not reached"); super.withdrawTokens(beneficiary); } diff --git a/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/contracts/crowdsale/emission/AllowanceCrowdsale.sol index c060a7256cb..1d319357605 100644 --- a/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ b/contracts/crowdsale/emission/AllowanceCrowdsale.sol @@ -21,7 +21,7 @@ contract AllowanceCrowdsale is Crowdsale { * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale. */ constructor (address tokenWallet) public { - require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet address is address(0)."); + require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address"); _tokenWallet = tokenWallet; } diff --git a/contracts/crowdsale/emission/MintedCrowdsale.sol b/contracts/crowdsale/emission/MintedCrowdsale.sol index 45720d85350..69c5fbf6f0b 100644 --- a/contracts/crowdsale/emission/MintedCrowdsale.sol +++ b/contracts/crowdsale/emission/MintedCrowdsale.sol @@ -18,7 +18,7 @@ contract MintedCrowdsale is Crowdsale { // Potentially dangerous assumption about the type of the token. require( ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), - "MintedCrowdsale: assumption about the type of the token failed." + "MintedCrowdsale: minting failed" ); } } diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 654c2159343..345d3cc733a 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -21,9 +21,9 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale */ constructor (uint256 initialRate, uint256 finalRate) public { - require(finalRate > 0, "IncreasingPriceCrowdsale: final rate of token is 0."); + require(finalRate > 0, "IncreasingPriceCrowdsale: final rate is 0"); // solhint-disable-next-line max-line-length - require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate of token is less than final rate of token."); + require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate is less than final rate"); _initialRate = initialRate; _finalRate = finalRate; } diff --git a/contracts/crowdsale/validation/CappedCrowdsale.sol b/contracts/crowdsale/validation/CappedCrowdsale.sol index 6d59b934221..867a355433a 100644 --- a/contracts/crowdsale/validation/CappedCrowdsale.sol +++ b/contracts/crowdsale/validation/CappedCrowdsale.sol @@ -17,7 +17,7 @@ contract CappedCrowdsale is Crowdsale { * @param cap Max amount of wei to be contributed */ constructor (uint256 cap) public { - require(cap > 0, "CappedCrowdsale: max amount of wei to be contributed is 0."); + require(cap > 0, "CappedCrowdsale: cap is 0"); _cap = cap; } @@ -43,6 +43,6 @@ contract CappedCrowdsale is Crowdsale { */ function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); - require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: token cap exceeded."); + require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded"); } } diff --git a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol index 2753bc7854a..b76f9844cd4 100644 --- a/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ b/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol @@ -49,7 +49,7 @@ contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { super._preValidatePurchase(beneficiary, weiAmount); // solhint-disable-next-line max-line-length - require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: beneficiary's funding cap exceeded."); + require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); } /** diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index 6d638efc78d..a655f5abeec 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -24,7 +24,7 @@ contract TimedCrowdsale is Crowdsale { * @dev Reverts if not in crowdsale time range. */ modifier onlyWhileOpen { - require(isOpen(), "TimedCrowdsale: crowdsale is closed."); + require(isOpen(), "TimedCrowdsale: not open"); _; } @@ -35,9 +35,9 @@ contract TimedCrowdsale is Crowdsale { */ constructor (uint256 openingTime, uint256 closingTime) public { // solhint-disable-next-line not-rely-on-time - require(openingTime >= block.timestamp, "TimedCrowdsale: crowdsale opening time is less than current time."); + require(openingTime >= block.timestamp, "TimedCrowdsale: opening time is before current time"); // solhint-disable-next-line max-line-length - require(closingTime > openingTime, "TimedCrowdsale: crowdsale closing time is less than or equal to crowdsale opening time."); + require(closingTime > openingTime, "TimedCrowdsale: closing time is before opening time"); _openingTime = openingTime; _closingTime = closingTime; @@ -88,9 +88,9 @@ contract TimedCrowdsale is Crowdsale { * @param newClosingTime Crowdsale closing time */ function _extendTime(uint256 newClosingTime) internal { - require(!hasClosed(), "TimedCrowdsale: crowdsale period has elapsed."); + require(!hasClosed(), "TimedCrowdsale: already closed"); // solhint-disable-next-line max-line-length - require(newClosingTime > _closingTime, "TimedCrowdsale: crowdsale new closing time is less than or equal to older closing time."); + require(newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time"); emit TimedCrowdsaleExtended(_closingTime, newClosingTime); _closingTime = newClosingTime; diff --git a/contracts/crowdsale/validation/WhitelistCrowdsale.sol b/contracts/crowdsale/validation/WhitelistCrowdsale.sol index df350fcad0e..1f9ae34bb9c 100644 --- a/contracts/crowdsale/validation/WhitelistCrowdsale.sol +++ b/contracts/crowdsale/validation/WhitelistCrowdsale.sol @@ -15,7 +15,7 @@ contract WhitelistCrowdsale is WhitelistedRole, Crowdsale { * @param _weiAmount Amount of wei contributed */ function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { - require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role."); + require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role"); super._preValidatePurchase(_beneficiary, _weiAmount); } } diff --git a/contracts/drafts/ERC20Migrator.sol b/contracts/drafts/ERC20Migrator.sol index 2bd7ba9ec8a..4835c1ff2fe 100644 --- a/contracts/drafts/ERC20Migrator.sol +++ b/contracts/drafts/ERC20Migrator.sol @@ -44,7 +44,7 @@ contract ERC20Migrator { * @param legacyToken address of the old token contract */ constructor (IERC20 legacyToken) public { - require(address(legacyToken) != address(0), "ERC20Migrator: legacy token address is address(0)."); + require(address(legacyToken) != address(0), "ERC20Migrator: legacy token is the zero address"); _legacyToken = legacyToken; } @@ -68,10 +68,10 @@ contract ERC20Migrator { * @param newToken_ the token that will be minted */ function beginMigration(ERC20Mintable newToken_) public { - require(address(_newToken) == address(0), "ERC20Migrator: previous new token address is address(0)."); - require(address(newToken_) != address(0), "ERC20Migrator: current new token address is address(0)."); + require(address(_newToken) == address(0), "ERC20Migrator: migration already started"); + require(address(newToken_) != address(0), "ERC20Migrator: new token is the zero address"); //solhint-disable-next-line max-line-length - require(newToken_.isMinter(address(this)), "ERC20Migrator: this contract is not a minter for current new token."); + require(newToken_.isMinter(address(this)), "ERC20Migrator: not a minter for new token"); _newToken = newToken_; } @@ -83,7 +83,7 @@ contract ERC20Migrator { * @param amount amount of tokens to be migrated */ function migrate(address account, uint256 amount) public { - require(address(_newToken) != address(0), "ERC20Migrator: current new token address is address(0)."); + require(address(_newToken) != address(0), "ERC20Migrator: migration not started"); _legacyToken.safeTransferFrom(account, address(this), amount); _newToken.mint(account, amount); } diff --git a/contracts/drafts/ERC20Snapshot.sol b/contracts/drafts/ERC20Snapshot.sol index 1a67ed9d0f1..869a46fe3e7 100644 --- a/contracts/drafts/ERC20Snapshot.sol +++ b/contracts/drafts/ERC20Snapshot.sol @@ -101,9 +101,9 @@ contract ERC20Snapshot is ERC20 { function _valueAt(uint256 snapshotId, Snapshots storage snapshots) private view returns (bool, uint256) { - require(snapshotId > 0, "ERC20Snapshot: snapshot id is 0."); + require(snapshotId > 0, "ERC20Snapshot: id is 0"); // solhint-disable-next-line max-line-length - require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: provided snapshot id is greater than current snapshot id."); + require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id"); uint256 index = snapshots.ids.findUpperBound(snapshotId); diff --git a/contracts/drafts/SignatureBouncer.sol b/contracts/drafts/SignatureBouncer.sol index 76776affd62..f6fcbcd5af0 100644 --- a/contracts/drafts/SignatureBouncer.sol +++ b/contracts/drafts/SignatureBouncer.sol @@ -51,7 +51,7 @@ contract SignatureBouncer is SignerRole { * @dev Requires that a valid signature of a signer was provided. */ modifier onlyValidSignature(bytes memory signature) { - require(_isValidSignature(msg.sender, signature), "SignatureBouncer: invalid caller signature."); + require(_isValidSignature(msg.sender, signature), "SignatureBouncer: invalid signature for caller"); _; } @@ -60,7 +60,7 @@ contract SignatureBouncer is SignerRole { */ modifier onlyValidSignatureAndMethod(bytes memory signature) { // solhint-disable-next-line max-line-length - require(_isValidSignatureAndMethod(msg.sender, signature), "SignatureBouncer: invalid caller signature for method."); + require(_isValidSignatureAndMethod(msg.sender, signature), "SignatureBouncer: invalid signature for caller and method"); _; } @@ -69,7 +69,7 @@ contract SignatureBouncer is SignerRole { */ modifier onlyValidSignatureAndData(bytes memory signature) { // solhint-disable-next-line max-line-length - require(_isValidSignatureAndData(msg.sender, signature), "SignatureBouncer: invalid caller signature for data."); + require(_isValidSignatureAndData(msg.sender, signature), "SignatureBouncer: invalid signature for caller and data"); _; } @@ -99,7 +99,7 @@ contract SignatureBouncer is SignerRole { * @return bool */ function _isValidSignatureAndData(address account, bytes memory signature) internal view returns (bool) { - require(msg.data.length > _SIGNATURE_SIZE, "SignatureBouncer: length of caller data is less than 96."); + require(msg.data.length > _SIGNATURE_SIZE, "SignatureBouncer: data is too short"); bytes memory data = new bytes(msg.data.length - _SIGNATURE_SIZE); for (uint i = 0; i < data.length; i++) { diff --git a/contracts/drafts/SignedSafeMath.sol b/contracts/drafts/SignedSafeMath.sol index 18ab9f7e69b..b9647679293 100644 --- a/contracts/drafts/SignedSafeMath.sol +++ b/contracts/drafts/SignedSafeMath.sol @@ -18,10 +18,10 @@ library SignedSafeMath { return 0; } - require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: (a == -1 && b == -2**255)"); + require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: multiplication overflow"); int256 c = a * b; - require(c / a == b, "SignedSafeMath: c / a == b"); + require(c / a == b, "SignedSafeMath: multiplication overflow"); return c; } @@ -30,8 +30,8 @@ library SignedSafeMath { * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. */ function div(int256 a, int256 b) internal pure returns (int256) { - require(b != 0, "SignedSafeMath: division by zero."); - require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: (b == -1 && a == -2**255)"); + require(b != 0, "SignedSafeMath: division by zero"); + require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: division overflow"); int256 c = a / b; @@ -43,7 +43,7 @@ library SignedSafeMath { */ function sub(int256 a, int256 b) internal pure returns (int256) { int256 c = a - b; - require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: (b >= 0 && c <= a) || (b < 0 && c > a)"); + require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); return c; } @@ -53,7 +53,7 @@ library SignedSafeMath { */ function add(int256 a, int256 b) internal pure returns (int256) { int256 c = a + b; - require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: (b >= 0 && c >= a) || (b < 0 && c < a)"); + require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); return c; } diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index 0a6d136a008..631f3477407 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -47,12 +47,12 @@ contract TokenVesting is Ownable { * @param revocable whether the vesting is revocable or not */ constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { - require(beneficiary != address(0), "TokenVesting: beneficiary address is address(0)."); + require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); // solhint-disable-next-line max-line-length - require(cliffDuration <= duration, "TokenVesting: duration when tokens begin to vest is greater than duration in which tokens will vest."); - require(duration > 0, "TokenVesting: duration in which tokens will vest is 0."); + require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); + require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length - require(start.add(duration) > block.timestamp, "TokenVesting: time at which vesting starts must be less than current block timestamp."); + require(start.add(duration) > block.timestamp, "TokenVesting: starting time is before current time"); _beneficiary = beneficiary; _revocable = revocable; @@ -117,7 +117,7 @@ contract TokenVesting is Ownable { function release(IERC20 token) public { uint256 unreleased = _releasableAmount(token); - require(unreleased > 0, "TokenVesting: number of vested tokens is 0."); + require(unreleased > 0, "TokenVesting: no tokens are due"); _released[address(token)] = _released[address(token)].add(unreleased); @@ -132,8 +132,8 @@ contract TokenVesting is Ownable { * @param token ERC20 token which is being vested */ function revoke(IERC20 token) public onlyOwner { - require(_revocable, "TokenVesting: revoking is not allowed."); - require(!_revoked[address(token)], "TokenVesting: revoked for token address is true."); + require(_revocable, "TokenVesting: cannot revoke"); + require(!_revoked[address(token)], "TokenVesting: token already revoked"); uint256 balance = token.balanceOf(address(this)); diff --git a/contracts/examples/SampleCrowdsale.sol b/contracts/examples/SampleCrowdsale.sol index 07c9fe19468..e784861bfe2 100644 --- a/contracts/examples/SampleCrowdsale.sol +++ b/contracts/examples/SampleCrowdsale.sol @@ -48,6 +48,6 @@ contract SampleCrowdsale is CappedCrowdsale, RefundableCrowdsale, MintedCrowdsal { //As goal needs to be met for a successful crowdsale //the value needs to less or equal than a cap which is limit for accepted funds - require(goal <= cap, "SampleCrowdSale: funding goal is greater than token cap."); + require(goal <= cap, "SampleCrowdSale: goal is greater than cap"); } } diff --git a/contracts/introspection/ERC165.sol b/contracts/introspection/ERC165.sol index f89834bd26a..64652b8c9da 100644 --- a/contracts/introspection/ERC165.sol +++ b/contracts/introspection/ERC165.sol @@ -38,7 +38,7 @@ contract ERC165 is IERC165 { * @dev Internal method for registering an interface. */ function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff, "ERC165: invalid interface id."); + require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index f773ee812e6..81eb5d4c7c7 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -27,7 +27,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is not paused. */ modifier whenNotPaused() { - require(!_paused, "Pausable: !_paused."); + require(!_paused, "Pausable: paused"); _; } @@ -35,7 +35,7 @@ contract Pausable is PauserRole { * @dev Modifier to make a function callable only when the contract is paused. */ modifier whenPaused() { - require(_paused, "Pausable: _paused."); + require(_paused, "Pausable: not paused"); _; } diff --git a/contracts/math/SafeMath.sol b/contracts/math/SafeMath.sol index 8cea6068ffc..704ec5b6963 100644 --- a/contracts/math/SafeMath.sol +++ b/contracts/math/SafeMath.sol @@ -17,7 +17,7 @@ library SafeMath { } uint256 c = a * b; - require(c / a == b, "SafeMath: c / a == b."); + require(c / a == b, "SafeMath: multiplication overflow"); return c; } @@ -27,7 +27,7 @@ library SafeMath { */ function div(uint256 a, uint256 b) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 - require(b > 0, "SafeMath: division by zero in div()."); + require(b > 0, "SafeMath: division by zero"); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold @@ -38,7 +38,7 @@ library SafeMath { * @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { - require(b <= a, "SafeMath: b <= a."); + require(b <= a, "SafeMath: subtraction overflow"); uint256 c = a - b; return c; @@ -49,7 +49,7 @@ library SafeMath { */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; - require(c >= a, "SafeMath: c >= a."); + require(c >= a, "SafeMath: addition overflow"); return c; } @@ -59,7 +59,7 @@ library SafeMath { * reverts when dividing by zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { - require(b != 0, "SafeMath: division by zero in mod()."); + require(b != 0, "SafeMath: modulo by zero"); return a % b; } } diff --git a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol index b3c06f98e96..1c81b4bdc50 100644 --- a/contracts/mocks/ERC165/ERC165InterfacesSupported.sol +++ b/contracts/mocks/ERC165/ERC165InterfacesSupported.sol @@ -43,7 +43,7 @@ contract SupportsInterfaceWithLookupMock is IERC165 { * @dev Private method for registering an interface. */ function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff, "ERC165InterfacesSupported: invalid interface id."); + require(interfaceId != 0xffffffff, "ERC165InterfacesSupported: invalid interface id"); _supportedInterfaces[interfaceId] = true; } } diff --git a/contracts/mocks/ERC721ReceiverMock.sol b/contracts/mocks/ERC721ReceiverMock.sol index 5ed5811256f..01d5f0a76ca 100644 --- a/contracts/mocks/ERC721ReceiverMock.sol +++ b/contracts/mocks/ERC721ReceiverMock.sol @@ -16,7 +16,7 @@ contract ERC721ReceiverMock is IERC721Receiver { function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4) { - require(!_reverts, "ERC721ReceiverMock: !_reverts."); + require(!_reverts, "ERC721ReceiverMock: reverting"); emit Received(operator, from, tokenId, data, gasleft()); return _retval; } diff --git a/contracts/mocks/ReentrancyAttack.sol b/contracts/mocks/ReentrancyAttack.sol index dd0427fe241..3ab8c454fd2 100644 --- a/contracts/mocks/ReentrancyAttack.sol +++ b/contracts/mocks/ReentrancyAttack.sol @@ -4,6 +4,6 @@ contract ReentrancyAttack { function callSender(bytes4 data) public { // solhint-disable-next-line avoid-low-level-calls (bool success,) = msg.sender.call(abi.encodeWithSelector(data)); - require(success, "ReentrancyAttack: previous low-level call returned false."); + require(success, "ReentrancyAttack: failed call"); } } diff --git a/contracts/mocks/ReentrancyMock.sol b/contracts/mocks/ReentrancyMock.sol index 84d10fc6838..3b5a2b51d75 100644 --- a/contracts/mocks/ReentrancyMock.sol +++ b/contracts/mocks/ReentrancyMock.sol @@ -26,7 +26,7 @@ contract ReentrancyMock is ReentrancyGuard { count(); // solhint-disable-next-line avoid-low-level-calls (bool success,) = address(this).call(abi.encodeWithSignature("countThisRecursive(uint256)", n - 1)); - require(success, "ReentrancyMock: previous low-level call returned false."); + require(success, "ReentrancyMock: failed call"); } } diff --git a/contracts/mocks/SafeERC20Helper.sol b/contracts/mocks/SafeERC20Helper.sol index 3c72bdebf77..7142740f580 100644 --- a/contracts/mocks/SafeERC20Helper.sol +++ b/contracts/mocks/SafeERC20Helper.sol @@ -26,7 +26,7 @@ contract ERC20ReturnFalseMock { } function allowance(address, address) public view returns (uint256) { - require(_dummy == 0, "SafeERC20Helper: _dummy == 0."); + require(_dummy == 0); // Duummy read from a state variable so that the function is view return 0; } } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index e370046136d..d8312076401 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -30,7 +30,7 @@ contract Ownable { * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { - require(isOwner(), "Ownable: caller is not the owner."); + require(isOwner(), "Ownable: caller is not the owner"); _; } @@ -66,7 +66,7 @@ contract Ownable { * @param newOwner The address to transfer ownership to. */ function _transferOwnership(address newOwner) internal { - require(newOwner != address(0), "Ownable: new owner address is address(0)."); + require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } diff --git a/contracts/ownership/Secondary.sol b/contracts/ownership/Secondary.sol index 1f563cd41d4..c87906a9568 100644 --- a/contracts/ownership/Secondary.sol +++ b/contracts/ownership/Secondary.sol @@ -23,7 +23,7 @@ contract Secondary { * @dev Reverts if called from any account other than the primary. */ modifier onlyPrimary() { - require(msg.sender == _primary, "Secondary: caller is not the primary account."); + require(msg.sender == _primary, "Secondary: caller is not the primary account"); _; } @@ -39,7 +39,7 @@ contract Secondary { * @param recipient The address of new primary. */ function transferPrimary(address recipient) public onlyPrimary { - require(recipient != address(0), "Secondary: recipient address is address(0)."); + require(recipient != address(0), "Secondary: new primary is the zero address"); _primary = recipient; emit PrimaryTransferred(_primary); } diff --git a/contracts/payment/PaymentSplitter.sol b/contracts/payment/PaymentSplitter.sol index f6bb5bea969..d7d5d1941df 100644 --- a/contracts/payment/PaymentSplitter.sol +++ b/contracts/payment/PaymentSplitter.sol @@ -38,8 +38,8 @@ contract PaymentSplitter { */ constructor (address[] memory payees, uint256[] memory shares) public payable { // solhint-disable-next-line max-line-length - require(payees.length == shares.length, "PaymentSplitter: payees length is not equal to shares length."); - require(payees.length > 0, "PaymentSplitter: payees length is 0."); + require(payees.length == shares.length, "PaymentSplitter: payees and shares length mismatch"); + require(payees.length > 0, "PaymentSplitter: no payees"); for (uint256 i = 0; i < payees.length; i++) { _addPayee(payees[i], shares[i]); @@ -99,12 +99,12 @@ contract PaymentSplitter { * total shares and their previous withdrawals. */ function release(address payable account) public { - require(_shares[account] > 0, "PaymentSplitter: shares of account is 0."); + require(_shares[account] > 0, "PaymentSplitter: account has no shares"); uint256 totalReceived = address(this).balance.add(_totalReleased); uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); - require(payment != 0, "PaymentSplitter: payment is 0."); + require(payment != 0, "PaymentSplitter: account is not due payment"); _released[account] = _released[account].add(payment); _totalReleased = _totalReleased.add(payment); @@ -119,9 +119,9 @@ contract PaymentSplitter { * @param shares_ The number of shares owned by the payee. */ function _addPayee(address account, uint256 shares_) private { - require(account != address(0), "PaymentSplitter: account address is address(0)."); - require(shares_ > 0, "PaymentSplitter: shares are 0."); - require(_shares[account] == 0, "PaymentSplitter: shares of account is greater than 0."); + require(account != address(0), "PaymentSplitter: account is the zero address"); + require(shares_ > 0, "PaymentSplitter: shares are 0"); + require(_shares[account] == 0, "PaymentSplitter: account already has shares"); _payees.push(account); _shares[account] = shares_; diff --git a/contracts/payment/escrow/ConditionalEscrow.sol b/contracts/payment/escrow/ConditionalEscrow.sol index b35c0a2d89a..df497aa9063 100644 --- a/contracts/payment/escrow/ConditionalEscrow.sol +++ b/contracts/payment/escrow/ConditionalEscrow.sol @@ -16,7 +16,7 @@ contract ConditionalEscrow is Escrow { function withdrawalAllowed(address payee) public view returns (bool); function withdraw(address payable payee) public { - require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw."); + require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); super.withdraw(payee); } } diff --git a/contracts/payment/escrow/RefundEscrow.sol b/contracts/payment/escrow/RefundEscrow.sol index 5058c11b6ab..50574b389a1 100644 --- a/contracts/payment/escrow/RefundEscrow.sol +++ b/contracts/payment/escrow/RefundEscrow.sol @@ -27,7 +27,7 @@ contract RefundEscrow is ConditionalEscrow { * @param beneficiary The beneficiary of the deposits. */ constructor (address payable beneficiary) public { - require(beneficiary != address(0), "RefundEscrow: beneficiary address is address(0)."); + require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address"); _beneficiary = beneficiary; _state = State.Active; } @@ -51,7 +51,7 @@ contract RefundEscrow is ConditionalEscrow { * @param refundee The address funds will be sent to if a refund occurs. */ function deposit(address refundee) public payable { - require(_state == State.Active, "RefundEscrow: _state == State.Active in deposit()."); + require(_state == State.Active, "RefundEscrow: can only deposit while active"); super.deposit(refundee); } @@ -60,7 +60,7 @@ contract RefundEscrow is ConditionalEscrow { * further deposits. */ function close() public onlyPrimary { - require(_state == State.Active, "RefundEscrow: _state == State.Active in close()."); + require(_state == State.Active, "RefundEscrow: can only close while active"); _state = State.Closed; emit RefundsClosed(); } @@ -69,7 +69,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Allows for refunds to take place, rejecting further deposits. */ function enableRefunds() public onlyPrimary { - require(_state == State.Active, "RefundEscrow: _state == State.Active in enableRefunds()."); + require(_state == State.Active, "RefundEscrow: can only enable refunds while active"); _state = State.Refunding; emit RefundsEnabled(); } @@ -78,7 +78,7 @@ contract RefundEscrow is ConditionalEscrow { * @dev Withdraws the beneficiary's funds. */ function beneficiaryWithdraw() public { - require(_state == State.Closed, "RefundEscrow: _state == State.Closed in beneficiaryWithdraw()."); + require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed"); _beneficiary.transfer(address(this).balance); } diff --git a/contracts/token/ERC20/ERC20.sol b/contracts/token/ERC20/ERC20.sol index 127e72a3cf3..e59a9c7cffe 100644 --- a/contracts/token/ERC20/ERC20.sol +++ b/contracts/token/ERC20/ERC20.sol @@ -125,7 +125,7 @@ contract ERC20 is IERC20 { * @param value The amount to be transferred. */ function _transfer(address from, address to, uint256 value) internal { - require(to != address(0), "ERC20: to address is address(0)."); + require(to != address(0), "ERC20: to address is address(0)"); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); @@ -140,7 +140,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be created. */ function _mint(address account, uint256 value) internal { - require(account != address(0), "ERC20: account address is address(0) in _mint()."); + require(account != address(0), "ERC20: account address is address(0) in _mint()"); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); @@ -154,7 +154,7 @@ contract ERC20 is IERC20 { * @param value The amount that will be burnt. */ function _burn(address account, uint256 value) internal { - require(account != address(0), "ERC20: account address is address(0) in _burn()."); + require(account != address(0), "ERC20: account address is address(0) in _burn()"); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); @@ -168,8 +168,8 @@ contract ERC20 is IERC20 { * @param value The number of tokens that can be spent. */ function _approve(address owner, address spender, uint256 value) internal { - require(spender != address(0), "ERC20: spender address is address(0)."); - require(owner != address(0), "ERC20: owner address is address(0)."); + require(spender != address(0), "ERC20: spender address is address(0)"); + require(owner != address(0), "ERC20: owner address is address(0)"); _allowed[owner][spender] = value; emit Approval(owner, spender, value); diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index 48e2fad1e4c..cbb27a5d57f 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -10,7 +10,7 @@ contract ERC20Capped is ERC20Mintable { uint256 private _cap; constructor (uint256 cap) public { - require(cap > 0, "ERC20Capped: token cap is 0."); + require(cap > 0, "ERC20Capped: token cap is 0"); _cap = cap; } @@ -22,7 +22,7 @@ contract ERC20Capped is ERC20Mintable { } function _mint(address account, uint256 value) internal { - require(totalSupply().add(value) <= _cap, "ERC20Capped: totalSupply().add(value) <= _cap."); + require(totalSupply().add(value) <= _cap, "ERC20Capped: totalSupply().add(value) <= _cap"); super._mint(account, value); } } diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 620ef1998a7..5c26237723a 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -59,11 +59,11 @@ library SafeERC20 { // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length - require(address(token).isContract(), "SafeERC20: token address is not a contract address."); + require(address(token).isContract(), "SafeERC20: token address is not a contract address"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); - require(success, "SafeERC20: the previous low-level call returned false."); + require(success, "SafeERC20: the previous low-level call returned false"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index 9106a8d00c6..afd7851a79d 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -21,7 +21,7 @@ contract TokenTimelock { constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { // solhint-disable-next-line not-rely-on-time - require(releaseTime > block.timestamp, "TokenTimelock: release time is less than current block time."); + require(releaseTime > block.timestamp, "TokenTimelock: release time is less than current block time"); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime; @@ -53,10 +53,10 @@ contract TokenTimelock { */ function release() public { // solhint-disable-next-line not-rely-on-time - require(block.timestamp >= _releaseTime, "TokenTimelock: current block time is less than release time."); + require(block.timestamp >= _releaseTime, "TokenTimelock: current block time is less than release time"); uint256 amount = _token.balanceOf(address(this)); - require(amount > 0, "TokenTimelock: amount to release is 0."); + require(amount > 0, "TokenTimelock: amount to release is 0"); _token.safeTransfer(_beneficiary, amount); } diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 56b0d0897c3..28c09cd8fdb 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -57,7 +57,7 @@ contract ERC721 is ERC165, IERC721 { * @return uint256 representing the amount owned by the passed address */ function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0), "ERC721: owner address is address(0) in balanceOf()."); + require(owner != address(0), "ERC721: owner address is address(0) in balanceOf()"); return _ownedTokensCount[owner].current(); } @@ -68,7 +68,7 @@ contract ERC721 is ERC165, IERC721 { */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; - require(owner != address(0), "ERC721: owner address is address(0) in ownerOf()."); + require(owner != address(0), "ERC721: owner address is address(0) in ownerOf()"); return owner; } @@ -82,9 +82,9 @@ contract ERC721 is ERC165, IERC721 { */ function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); - require(to != owner, "ERC721: to address is equal to the owner address."); + require(to != owner, "ERC721: to address is equal to the owner address"); // solhint-disable-next-line max-line-length - require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: caller is neither the owner nor an operator in approve()."); + require(msg.sender == owner || isApprovedForAll(owner, msg.sender), "ERC721: caller is neither the owner nor an operator in approve()"); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); @@ -97,7 +97,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "ERC721: the tokenId does not exist."); + require(_exists(tokenId), "ERC721: the tokenId does not exist"); return _tokenApprovals[tokenId]; } @@ -108,7 +108,7 @@ contract ERC721 is ERC165, IERC721 { * @param approved representing the status of the approval to be set */ function setApprovalForAll(address to, bool approved) public { - require(to != msg.sender, "ERC721: to address is equal to the caller."); + require(to != msg.sender, "ERC721: to address is equal to the caller"); _operatorApprovals[msg.sender][to] = approved; emit ApprovalForAll(msg.sender, to, approved); } @@ -133,7 +133,7 @@ contract ERC721 is ERC165, IERC721 { */ function transferFrom(address from, address to, uint256 tokenId) public { //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: caller is neither the owner nor an operator in transferFrom()."); + require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721: caller is neither the owner nor an operator in transferFrom()"); _transferFrom(from, to, tokenId); } @@ -168,7 +168,7 @@ contract ERC721 is ERC165, IERC721 { function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { transferFrom(from, to, tokenId); //solhint-disable-next-line max-line-length - require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: to address does not implement ERC721Receiver."); + require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: to address does not implement ERC721Receiver"); } /** @@ -200,8 +200,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be minted */ function _mint(address to, uint256 tokenId) internal { - require(to != address(0), "ERC721: to address is address(0) in _mint()."); - require(!_exists(tokenId), "ERC721: token id exists."); + require(to != address(0), "ERC721: to address is address(0) in _mint()"); + require(!_exists(tokenId), "ERC721: token id exists"); _tokenOwner[tokenId] = to; _ownedTokensCount[to].increment(); @@ -217,7 +217,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner, "ERC721: owner is not the owner of tokenId in _burn()."); + require(ownerOf(tokenId) == owner, "ERC721: owner is not the owner of tokenId in _burn()"); _clearApproval(tokenId); @@ -244,8 +244,8 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from, "ERC721: from is not the owner of tokenId."); - require(to != address(0), "ERC721: to address is address(0) in _transferFrom()."); + require(ownerOf(tokenId) == from, "ERC721: from is not the owner of tokenId"); + require(to != address(0), "ERC721: to address is address(0) in _transferFrom()"); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Burnable.sol b/contracts/token/ERC721/ERC721Burnable.sol index 0e8dde42c8f..f2778cdf318 100644 --- a/contracts/token/ERC721/ERC721Burnable.sol +++ b/contracts/token/ERC721/ERC721Burnable.sol @@ -13,7 +13,7 @@ contract ERC721Burnable is ERC721 { */ function burn(uint256 tokenId) public { //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721Burnable: caller is neither the owner nor an approved address."); + require(_isApprovedOrOwner(msg.sender, tokenId), "ERC721Burnable: caller is neither the owner nor an approved address"); _burn(tokenId); } } diff --git a/contracts/token/ERC721/ERC721Metadata.sol b/contracts/token/ERC721/ERC721Metadata.sol index 796ce8e9b13..32148256d2d 100644 --- a/contracts/token/ERC721/ERC721Metadata.sol +++ b/contracts/token/ERC721/ERC721Metadata.sol @@ -55,7 +55,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId), "ERC721Metadata: the tokenId does not exist in tokenURI()."); + require(_exists(tokenId), "ERC721Metadata: the tokenId does not exist in tokenURI()"); return _tokenURIs[tokenId]; } diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol index 5b24441c3ef..e4469a1065d 100644 --- a/contracts/utils/ReentrancyGuard.sol +++ b/contracts/utils/ReentrancyGuard.sol @@ -27,6 +27,6 @@ contract ReentrancyGuard { _guardCounter += 1; uint256 localCounter = _guardCounter; _; - require(localCounter == _guardCounter, "ReentrancyGuard: localCounter == _guardCounter."); + require(localCounter == _guardCounter, "ReentrancyGuard: localCounter == _guardCounter"); } } From 9486ebd0267109157713ea98672257c3628d16bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Tue, 16 Apr 2019 19:09:15 -0300 Subject: [PATCH 11/20] Fianal update of revert reason strings. --- contracts/token/ERC20/ERC20Capped.sol | 4 ++-- contracts/token/ERC20/SafeERC20.sol | 10 ++++++---- contracts/token/ERC20/TokenTimelock.sol | 6 +++--- contracts/token/ERC721/ERC721Enumerable.sol | 4 ++-- contracts/token/ERC721/ERC721Metadata.sol | 4 ++-- contracts/utils/ReentrancyGuard.sol | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/contracts/token/ERC20/ERC20Capped.sol b/contracts/token/ERC20/ERC20Capped.sol index cbb27a5d57f..c3a53a8414d 100644 --- a/contracts/token/ERC20/ERC20Capped.sol +++ b/contracts/token/ERC20/ERC20Capped.sol @@ -10,7 +10,7 @@ contract ERC20Capped is ERC20Mintable { uint256 private _cap; constructor (uint256 cap) public { - require(cap > 0, "ERC20Capped: token cap is 0"); + require(cap > 0, "ERC20Capped: cap is 0"); _cap = cap; } @@ -22,7 +22,7 @@ contract ERC20Capped is ERC20Mintable { } function _mint(address account, uint256 value) internal { - require(totalSupply().add(value) <= _cap, "ERC20Capped: totalSupply().add(value) <= _cap"); + require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); super._mint(account, value); } } diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index 5c26237723a..c8ce656049c 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -30,7 +30,9 @@ library SafeERC20 { // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length - require((value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: (value == 0) || (token.allowance(address(this), spender) == 0)"); + require((value == 0) || (token.allowance(address(this), spender) == 0), + "SafeERC20: approve from non-zero to non-zero allowance" + ); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } @@ -59,15 +61,15 @@ library SafeERC20 { // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length - require(address(token).isContract(), "SafeERC20: token address is not a contract address"); + require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); - require(success, "SafeERC20: the previous low-level call returned false"); + require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), "SafeERC20: abi.decode(returndata, (bool))"); + require(abi.decode(returndata, (bool)), "SafeERC20: unknown low-level call return data"); } } } diff --git a/contracts/token/ERC20/TokenTimelock.sol b/contracts/token/ERC20/TokenTimelock.sol index afd7851a79d..b7b1f54eb72 100644 --- a/contracts/token/ERC20/TokenTimelock.sol +++ b/contracts/token/ERC20/TokenTimelock.sol @@ -21,7 +21,7 @@ contract TokenTimelock { constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { // solhint-disable-next-line not-rely-on-time - require(releaseTime > block.timestamp, "TokenTimelock: release time is less than current block time"); + require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time"); _token = token; _beneficiary = beneficiary; _releaseTime = releaseTime; @@ -53,10 +53,10 @@ contract TokenTimelock { */ function release() public { // solhint-disable-next-line not-rely-on-time - require(block.timestamp >= _releaseTime, "TokenTimelock: current block time is less than release time"); + require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); uint256 amount = _token.balanceOf(address(this)); - require(amount > 0, "TokenTimelock: amount to release is 0"); + require(amount > 0, "TokenTimelock: no tokens to release"); _token.safeTransfer(_beneficiary, amount); } diff --git a/contracts/token/ERC721/ERC721Enumerable.sol b/contracts/token/ERC721/ERC721Enumerable.sol index e6c8e98dbf4..4f9ce54cf43 100644 --- a/contracts/token/ERC721/ERC721Enumerable.sol +++ b/contracts/token/ERC721/ERC721Enumerable.sol @@ -44,7 +44,7 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { * @return uint256 token ID at the given index of the tokens list owned by the requested address */ function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { - require(index < balanceOf(owner), "ERC721Enumerable: index < balanceOf(owner)"); + require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } @@ -63,7 +63,7 @@ contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable { * @return uint256 token ID at the given index of the tokens list */ function tokenByIndex(uint256 index) public view returns (uint256) { - require(index < totalSupply(), "ERC721Enumerable: index < totalSupply()"); + require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } diff --git a/contracts/token/ERC721/ERC721Metadata.sol b/contracts/token/ERC721/ERC721Metadata.sol index 32148256d2d..26db133c8d8 100644 --- a/contracts/token/ERC721/ERC721Metadata.sol +++ b/contracts/token/ERC721/ERC721Metadata.sol @@ -55,7 +55,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId), "ERC721Metadata: the tokenId does not exist in tokenURI()"); + require(_exists(tokenId), "ERC721Metadata: query of nonexistent token"); return _tokenURIs[tokenId]; } @@ -66,7 +66,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param uri string URI to assign */ function _setTokenURI(uint256 tokenId, string memory uri) internal { - require(_exists(tokenId), "ERC721Metadata: the tokenId does not exist in _setTokenURI()"); + require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = uri; } diff --git a/contracts/utils/ReentrancyGuard.sol b/contracts/utils/ReentrancyGuard.sol index e4469a1065d..2cf1448b6b0 100644 --- a/contracts/utils/ReentrancyGuard.sol +++ b/contracts/utils/ReentrancyGuard.sol @@ -27,6 +27,6 @@ contract ReentrancyGuard { _guardCounter += 1; uint256 localCounter = _guardCounter; _; - require(localCounter == _guardCounter, "ReentrancyGuard: localCounter == _guardCounter"); + require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call"); } } From 488bb62949bfd0c77f7284aa7e92fecd8324893f Mon Sep 17 00:00:00 2001 From: balajipachai Date: Fri, 19 Apr 2019 17:54:11 +0530 Subject: [PATCH 12/20] WIP: Updating reason strings in test cases --- package-lock.json | 149 ++++++++++-------- test/access/Roles.test.js | 10 +- .../access/roles/PublicRole.behavior.js | 15 +- test/crowdsale/AllowanceCrowdsale.test.js | 4 +- test/crowdsale/CappedCrowdsale.test.js | 8 +- test/crowdsale/Crowdsale.test.js | 27 ++-- test/crowdsale/FinalizableCrowdsale.test.js | 6 +- .../IncreasingPriceCrowdsale.test.js | 16 +- .../IndividuallyCappedCrowdsale.test.js | 14 +- test/crowdsale/MintedCrowdsale.test.js | 6 +- test/crowdsale/PausableCrowdsale.test.js | 6 +- test/crowdsale/PostDeliveryCrowdsale.test.js | 6 +- test/crowdsale/RefundableCrowdsale.test.js | 12 +- .../RefundablePostDeliveryCrowdsale.test.js | 10 +- test/crowdsale/TimedCrowdsale.test.js | 30 ++-- test/crowdsale/WhitelistCrowdsale.test.js | 6 +- test/cryptography/ECDSA.test.js | 7 +- test/drafts/Counters.test.js | 4 +- test/drafts/ERC1820Implementer.test.js | 7 +- test/drafts/ERC20Migrator.test.js | 16 +- test/drafts/ERC20Snapshot.test.js | 10 +- test/drafts/SignatureBouncer.test.js | 50 +++--- test/drafts/SignedSafeMath.test.js | 15 +- test/drafts/TokenVesting.test.js | 24 +-- test/examples/SampleCrowdsale.test.js | 16 +- test/introspection/ERC165.test.js | 4 +- test/lifecycle/Pausable.test.js | 16 +- test/math/SafeMath.test.js | 13 +- test/ownership/Ownable.behavior.js | 6 +- test/ownership/Secondary.test.js | 10 +- test/payment/PaymentSplitter.test.js | 18 +-- test/payment/escrow/ConditionalEscrow.test.js | 2 +- test/payment/escrow/Escrow.behavior.js | 4 +- test/payment/escrow/Escrow.test.js | 2 +- test/payment/escrow/RefundEscrow.test.js | 30 ++-- test/token/ERC20/ERC20.test.js | 40 ++--- test/token/ERC20/ERC20Burnable.test.js | 2 +- test/token/ERC20/ERC20Capped.test.js | 6 +- test/token/ERC20/ERC20Detailed.test.js | 2 +- test/token/ERC20/ERC20Mintable.test.js | 2 +- test/token/ERC20/ERC20Pausable.test.js | 20 +-- test/token/ERC20/SafeERC20.test.js | 16 +- test/token/ERC20/TokenTimelock.test.js | 8 +- .../ERC20/behaviors/ERC20Burnable.behavior.js | 6 +- .../ERC20/behaviors/ERC20Capped.behavior.js | 4 +- .../ERC20/behaviors/ERC20Mintable.behavior.js | 2 +- test/token/ERC721/ERC721.behavior.js | 30 ++-- test/token/ERC721/ERC721.test.js | 18 +-- test/token/ERC721/ERC721Full.test.js | 14 +- test/token/ERC721/ERC721MintBurn.behavior.js | 10 +- .../ERC721/ERC721PausedToken.behavior.js | 10 +- test/utils/ReentrancyGuard.test.js | 8 +- 52 files changed, 402 insertions(+), 375 deletions(-) diff --git a/package-lock.json b/package-lock.json index d5ffd9b4ca1..d8f89f972ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2440,9 +2440,9 @@ } }, "esprima": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, "globals": { @@ -2452,9 +2452,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -3537,8 +3537,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "optional": true + "dev": true }, "uuid": { "version": "3.3.2", @@ -4408,7 +4407,7 @@ "requires": { "async": "^2.6.1", "bn.js": "4.11.8", - "ganache-core": "github:agusx1211/ganache-core#coverage", + "ganache-core": "github:agusx1211/ganache-core#d885dd09685f84150db8ef11cd6929785acd0f98", "source-map-support": "^0.5.3", "web3": "^1.0.0-beta.36", "yargs": "^11.0.0" @@ -4490,8 +4489,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", "integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g=", - "dev": true, - "optional": true + "dev": true }, "uuid": { "version": "2.0.1", @@ -4533,7 +4531,6 @@ "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.0.0-beta.35.tgz", "integrity": "sha512-ayGavbgVk4KL9Y88Uv411fBJ0SVgVfKhKEBweKYzmP0zOqneMzWt6YsyD1n6kRvjAbqA0AfUPEOKyMNjcx2tjw==", "dev": true, - "optional": true, "requires": { "web3-core-helpers": "1.0.0-beta.35", "web3-core-method": "1.0.0-beta.35", @@ -4546,7 +4543,6 @@ "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.0.0-beta.35.tgz", "integrity": "sha512-APOu3sEsamyqWt//8o4yq9KF25/uqGm+pQShson/sC4gKzmfJB07fLo2ond0X30E8fIqAPeVCotPXQxGciGUmA==", "dev": true, - "optional": true, "requires": { "underscore": "1.8.3", "web3-eth-iban": "1.0.0-beta.35", @@ -4558,7 +4554,6 @@ "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.0.0-beta.35.tgz", "integrity": "sha512-jidImCide8q0GpfsO4L73qoHrbkeWgwU3uOH5DKtJtv0ccmG086knNMRgryb/o9ZgetDWLmDEsJnHjBSoIwcbA==", "dev": true, - "optional": true, "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.35", @@ -4572,7 +4567,6 @@ "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.0.0-beta.35.tgz", "integrity": "sha512-GvqXqKq07OmHuVi5uNRg6k79a1/CI0ViCC+EtNv4CORHtDRmYEt5Bvdv6z6FJEiaaQkD0lKbFwNhLxutx7HItw==", "dev": true, - "optional": true, "requires": { "any-promise": "1.3.0", "eventemitter3": "1.1.1" @@ -4583,7 +4577,6 @@ "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.0.0-beta.35.tgz", "integrity": "sha512-S+zW2h17ZZQU9oe3yaCJE0E7aJS4C3Kf4kGPDv+nXjW0gKhQQhgVhw1Doq/aYQGqNSWJp7f1VHkz5gQWwg6RRg==", "dev": true, - "optional": true, "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.35", @@ -4597,7 +4590,6 @@ "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.0.0-beta.35.tgz", "integrity": "sha512-gXzLrWvcGkGiWq1y33Z4Y80XI8XMrwowiQJkrPSjQ81K5PBKquOGwcMffLaKcwdmEy/NpsOXDeFo3eLE1Ghvvw==", "dev": true, - "optional": true, "requires": { "eventemitter3": "1.1.1", "underscore": "1.8.3", @@ -4630,7 +4622,6 @@ "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.0.0-beta.35.tgz", "integrity": "sha512-KUDC+EtFFYG8z01ZleKrASdjj327/rtWHzEt6RWsEj7bBa0bGp9nEh+nqdZx/Sdgz1O8tnfFzJlrRcXpfr1vGg==", "dev": true, - "optional": true, "requires": { "bn.js": "4.11.6", "underscore": "1.8.3", @@ -4642,8 +4633,7 @@ "version": "4.11.6", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", - "dev": true, - "optional": true + "dev": true } } }, @@ -4702,7 +4692,6 @@ "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.0.0-beta.35.tgz", "integrity": "sha512-H5wkcNcAIc+h/WoDIKv7ZYmrM2Xqu3O7jBQl1IWo73EDVQji+AoB2i3J8tuwI1yZRInRwrfpI3Zuwuf54hXHmQ==", "dev": true, - "optional": true, "requires": { "bn.js": "4.11.6", "web3-utils": "1.0.0-beta.35" @@ -4712,8 +4701,7 @@ "version": "4.11.6", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", - "dev": true, - "optional": true + "dev": true } } }, @@ -4722,7 +4710,6 @@ "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.0.0-beta.35.tgz", "integrity": "sha512-AcM9nnlxu7ZRRxPvkrFB9eLxMM4A2cPfj2aCg21Wb2EpMnhR+b/O1cT33k7ApRowoMpM+T9M8vx2oPNwXfaCOQ==", "dev": true, - "optional": true, "requires": { "web3-core": "1.0.0-beta.35", "web3-core-helpers": "1.0.0-beta.35", @@ -4736,7 +4723,6 @@ "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.0.0-beta.35.tgz", "integrity": "sha512-bbwaQ/KohGjIJ6HAKbZ6KrklCAaG6/B7hIbAbVLSFLxF+Yz9lmAgQYaDInpidpC/NLb3WOmcbRF+P77J4qMVIA==", "dev": true, - "optional": true, "requires": { "web3-core": "1.0.0-beta.35", "web3-core-method": "1.0.0-beta.35", @@ -4748,7 +4734,6 @@ "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.0.0-beta.35.tgz", "integrity": "sha512-DcIMFq52Fb08UpWyZ3ZlES6NsNqJnco4hBS/Ej6eOcASfuUayPI+GLkYVZsnF3cBYqlH+DOKuArcKSuIxK7jIA==", "dev": true, - "optional": true, "requires": { "web3-core-helpers": "1.0.0-beta.35", "xhr2-cookies": "1.1.0" @@ -4759,7 +4744,6 @@ "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.0.0-beta.35.tgz", "integrity": "sha512-iB0FG0HcpUnayfa8pn4guqEQ4Y1nrroi/jffdtQgFkrNt0sD3fMSwwC0AbmECqj3tDLl0e1slBR0RENll+ZF0g==", "dev": true, - "optional": true, "requires": { "oboe": "2.1.3", "underscore": "1.8.3", @@ -4771,11 +4755,10 @@ "resolved": "https://registry.npmjs.org/web3-providers-ws/-/web3-providers-ws-1.0.0-beta.35.tgz", "integrity": "sha512-Cx64NgDStynKaUGDIIOfaCd0fZusL8h5avKTkdTjUu2aHhFJhZoVBGVLhoDtUaqZGWIZGcBJOoVf2JkGUOjDRQ==", "dev": true, - "optional": true, "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.35", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" }, "dependencies": { "debug": { @@ -4783,7 +4766,6 @@ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", "dev": true, - "optional": true, "requires": { "ms": "2.0.0" } @@ -4792,7 +4774,6 @@ "version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible", "dev": true, - "optional": true, "requires": { "debug": "^2.2.0", "nan": "^2.3.3", @@ -4820,7 +4801,6 @@ "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.35.tgz", "integrity": "sha512-Dq6f0SOKj3BDFRgOPnE6ALbzBDCKVIW8mKWVf7tGVhTDHf+wQaWwQSC3aArFSqdExB75BPBPyDpuMTNszhljpA==", "dev": true, - "optional": true, "requires": { "bn.js": "4.11.6", "eth-lib": "0.1.27", @@ -4835,8 +4815,7 @@ "version": "4.11.6", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", - "dev": true, - "optional": true + "dev": true } } } @@ -4962,12 +4941,12 @@ "dev": true }, "handlebars": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.0.tgz", - "integrity": "sha512-l2jRuU1NAWK6AW5qqcTATWQJvNPEwkM7NEKSiv/gqOsoSQbVoWyqVEY5GS+XPQ88zLNmqASRpzfdm8d79hJS+w==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", + "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", "dev": true, "requires": { - "async": "^2.5.0", + "neo-async": "^2.6.0", "optimist": "^0.6.1", "source-map": "^0.6.1", "uglify-js": "^3.1.4" @@ -5586,13 +5565,21 @@ "dev": true }, "js-yaml": { - "version": "3.6.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.6.1.tgz", - "integrity": "sha1-bl/mfYsgXOTSL60Ft3geja3MSzA=", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", - "esprima": "^2.6.0" + "esprima": "^4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + } } }, "jsbn": { @@ -6481,6 +6468,12 @@ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, + "neo-async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", + "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", + "dev": true + }, "nice-try": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.4.tgz", @@ -8176,9 +8169,9 @@ "dev": true }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -8283,7 +8276,7 @@ "req-cwd": "^1.0.1", "shelljs": "^0.7.4", "sol-explore": "^1.6.2", - "solidity-parser-sc": "github:maxsam4/solidity-parser#solidity-0.5", + "solidity-parser-sc": "github:maxsam4/solidity-parser#3f0a30b97b460861654771871bcd970e73d47459", "tree-kill": "^1.2.0", "web3": "^0.20.6" }, @@ -8305,7 +8298,7 @@ "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "dev": true, "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", @@ -8954,16 +8947,17 @@ "dev": true }, "truffle-contract": { - "version": "4.0.9", - "resolved": "https://registry.npmjs.org/truffle-contract/-/truffle-contract-4.0.9.tgz", - "integrity": "sha512-416CbvnoR111mMspzyi4lLM5aNdypICiU6FfeSr/OBZekn7zdX432+fwUmFC+T4n+ncMEQuKkmIhxzrg7JR86w==", + "version": "4.0.12", + "resolved": "https://registry.npmjs.org/truffle-contract/-/truffle-contract-4.0.12.tgz", + "integrity": "sha512-/ZfGvBgMB+NcKtJ0gpq803JyhNW0BNiEb29HgEr0FS7rLh4fGXD7gfYzwWwl3neKLeqGtAyhxEPMPBOTqNe+xw==", "dev": true, "requires": { "bignumber.js": "^7.2.1", "ethers": "^4.0.0-beta.1", "truffle-blockchain-utils": "^0.0.8", - "truffle-contract-schema": "^3.0.3", + "truffle-contract-schema": "^3.0.6", "truffle-error": "^0.0.4", + "truffle-interface-adapter": "^0.1.2", "web3": "1.0.0-beta.37", "web3-core-promievent": "1.0.0-beta.37", "web3-eth-abi": "1.0.0-beta.37", @@ -8988,9 +8982,9 @@ } }, "truffle-contract-schema": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-3.0.3.tgz", - "integrity": "sha512-u7glieUcBcj5+o8aOppRLgViiI1CZI1wOWaniZ5eehCa11/HFW8Fow4mZDGeBTYX2xVUJJLCLEz3NsiY9yYWqA==", + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/truffle-contract-schema/-/truffle-contract-schema-3.0.6.tgz", + "integrity": "sha512-oAMPr/ecr06ViJMSatfp1VpbDNul0Q1dSrFkWSF4/6WWK4orhNL90A8uhtEt61doLz5n0Yjf59KWE0p7qToPXw==", "dev": true, "requires": { "ajv": "^5.1.1", @@ -9027,6 +9021,33 @@ "integrity": "sha512-hER0TNR4alBIhUp7SNrZRRiZtM/MBx+xBdM9qXP0tC3YASFmhNAxPuOyB8JDHFRNbDx12K7nvaqmyYGsI5c8BQ==", "dev": true }, + "truffle-interface-adapter": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/truffle-interface-adapter/-/truffle-interface-adapter-0.1.2.tgz", + "integrity": "sha512-1+pZprFU94mN8ydy4wVI2reW4iELDmsUADpa2ti++HwsX/T02yHK5+GxK3wQ9lXglRiI/B694fKFbHcv3t+Vxg==", + "dev": true, + "requires": { + "bn.js": "^4.11.8", + "web3": "1.0.0-beta.37" + }, + "dependencies": { + "web3": { + "version": "1.0.0-beta.37", + "resolved": "https://registry.npmjs.org/web3/-/web3-1.0.0-beta.37.tgz", + "integrity": "sha512-8XLgUspdzicC/xHG82TLrcF/Fxzj2XYNJ1KTYnepOI77bj5rvpsxxwHYBWQ6/JOjk0HkZqoBfnXWgcIHCDhZhQ==", + "dev": true, + "requires": { + "web3-bzz": "1.0.0-beta.37", + "web3-core": "1.0.0-beta.37", + "web3-eth": "1.0.0-beta.37", + "web3-eth-personal": "1.0.0-beta.37", + "web3-net": "1.0.0-beta.37", + "web3-shh": "1.0.0-beta.37", + "web3-utils": "1.0.0-beta.37" + } + } + } + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", @@ -9111,20 +9132,20 @@ "dev": true }, "uglify-js": { - "version": "3.4.10", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", - "integrity": "sha512-Y2VsbPVs0FIshJztycsO2SfPk7/KAF/T72qzv9u5EpQ4kB2hQoHlhNQTsNyy6ul7lQtqJN/AoWeS23OzEiEFxw==", + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.4.tgz", + "integrity": "sha512-GpKo28q/7Bm5BcX9vOu4S46FwisbPbAmkkqPnGIpKvKTM96I85N6XHQV+k4I6FA2wxgLhcsSyHoNhzucwCflvA==", "dev": true, "optional": true, "requires": { - "commander": "~2.19.0", + "commander": "~2.20.0", "source-map": "~0.6.1" }, "dependencies": { "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "dev": true, "optional": true }, @@ -10030,7 +10051,7 @@ "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "dev": true, "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git", + "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#d8d7fc9cc1fd781186c25676af100d1ec727013e", "ethereumjs-util": "^5.1.1" } }, @@ -10224,7 +10245,7 @@ "lodash": "^4.17.11", "oboe": "2.1.4", "url-parse": "1.4.4", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible", + "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "xhr2-cookies": "1.1.0" }, "dependencies": { @@ -10285,7 +10306,7 @@ "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.37", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" }, "dependencies": { "websocket": { diff --git a/test/access/Roles.test.js b/test/access/Roles.test.js index 6e3e931501e..8b31f500089 100644 --- a/test/access/Roles.test.js +++ b/test/access/Roles.test.js @@ -9,7 +9,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { }); it('reverts when querying roles for the zero account', async function () { - await shouldFail.reverting(this.roles.has(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(this.roles.has(ZERO_ADDRESS), "Roles: account is the zero address"); }); context('initially', function () { @@ -28,11 +28,11 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { it('reverts when adding roles to an already assigned account', async function () { await this.roles.add(authorized); - await shouldFail.reverting(this.roles.add(authorized)); + await shouldFail.reverting.withMessage(this.roles.add(authorized), "Roles: account already has role"); }); it('reverts when adding roles to the zero account', async function () { - await shouldFail.reverting(this.roles.add(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(this.roles.add(ZERO_ADDRESS), "Roles: account is the zero address"); }); }); }); @@ -51,11 +51,11 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { }); it('reverts when removing unassigned roles', async function () { - await shouldFail.reverting(this.roles.remove(other)); + await shouldFail.reverting.withMessage(this.roles.remove(other), "Roles: account does not have role"); }); it('reverts when removing roles from the zero account', async function () { - await shouldFail.reverting(this.roles.remove(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(this.roles.remove(ZERO_ADDRESS), "Roles: account is the zero address"); }); }); }); diff --git a/test/behaviors/access/roles/PublicRole.behavior.js b/test/behaviors/access/roles/PublicRole.behavior.js index c7eb04adff6..885673a3048 100644 --- a/test/behaviors/access/roles/PublicRole.behavior.js +++ b/test/behaviors/access/roles/PublicRole.behavior.js @@ -39,7 +39,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen } it('reverts when querying roles for the null account', async function () { - await shouldFail.reverting(this.contract[`is${rolename}`](ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(this.contract[`is${rolename}`](ZERO_ADDRESS), "Roles: account is the zero address"); }); describe('access control', function () { @@ -54,8 +54,9 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen context('from unauthorized account', function () { const from = other; + //, "CapperRole: caller does not have the Capper role" it('reverts', async function () { - await shouldFail.reverting(this.contract[`only${rolename}Mock`]({ from })); + await shouldFail.reverting.withMessage(this.contract[`only${rolename}Mock`]({ from }), `${rolename}Role: caller does not have the ${rolename} role`); }); }); }); @@ -75,11 +76,11 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen }); it('reverts when adding role to an already assigned account', async function () { - await shouldFail.reverting(this.contract[`add${rolename}`](authorized, { from })); + await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](authorized, { from }), "Roles: account already has role"); }); it('reverts when adding role to the null account', async function () { - await shouldFail.reverting(this.contract[`add${rolename}`](ZERO_ADDRESS, { from })); + await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](ZERO_ADDRESS, { from }), "Roles: account is the zero address"); }); }); }); @@ -101,11 +102,11 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen }); it('reverts when removing from an unassigned account', async function () { - await shouldFail.reverting(this.contract[`remove${rolename}`](other, { from })); + await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](other, { from }), "Roles: account does not have role"); }); it('reverts when removing role from the null account', async function () { - await shouldFail.reverting(this.contract[`remove${rolename}`](ZERO_ADDRESS, { from })); + await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](ZERO_ADDRESS, { from }), "Roles: account is the zero address"); }); }); }); @@ -122,7 +123,7 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen }); it('reverts when renouncing unassigned role', async function () { - await shouldFail.reverting(this.contract[`renounce${rolename}`]({ from: other })); + await shouldFail.reverting.withMessage(this.contract[`renounce${rolename}`]({ from: other }), "Roles: account does not have role"); }); }); }); diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index 10d0d6a49ee..df4dcf5fbbc 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) { +contract.only('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) { const rate = new BN('1'); const value = ether('0.42'); const expectedTokenAmount = rate.mul(value); @@ -75,7 +75,7 @@ contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenW describe('when token wallet is the zero address', function () { it('creation reverts', async function () { this.token = await SimpleToken.new({ from: tokenWallet }); - await shouldFail.reverting(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS), "AllowanceCrowdsale: token wallet is the zero address"); }); }); }); diff --git a/test/crowdsale/CappedCrowdsale.test.js b/test/crowdsale/CappedCrowdsale.test.js index 37bfaedb3fe..26ae8c4a17a 100644 --- a/test/crowdsale/CappedCrowdsale.test.js +++ b/test/crowdsale/CappedCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail } = require('openzeppelin-test-helpers'); const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('CappedCrowdsale', function ([_, wallet]) { +contract.only('CappedCrowdsale', function ([_, wallet]) { const rate = new BN('1'); const cap = ether('100'); const lessThanCap = ether('60'); @@ -14,7 +14,7 @@ contract('CappedCrowdsale', function ([_, wallet]) { }); it('rejects a cap of zero', async function () { - await shouldFail.reverting(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0)); + await shouldFail.reverting.withMessage(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0), "CappedCrowdsale: cap is 0"); }); context('with crowdsale', function () { @@ -31,11 +31,11 @@ contract('CappedCrowdsale', function ([_, wallet]) { it('should reject payments outside cap', async function () { await this.crowdsale.send(cap); - await shouldFail.reverting(this.crowdsale.send(1)); + await shouldFail.reverting.withMessage(this.crowdsale.send(1), "CappedCrowdsale: cap exceeded"); }); it('should reject payments that exceed cap', async function () { - await shouldFail.reverting(this.crowdsale.send(cap.addn(1))); + await shouldFail.reverting.withMessage(this.crowdsale.send(cap.addn(1)), "CappedCrowdsale: cap exceeded"); }); }); diff --git a/test/crowdsale/Crowdsale.test.js b/test/crowdsale/Crowdsale.test.js index 76eef628444..eed22edb939 100644 --- a/test/crowdsale/Crowdsale.test.js +++ b/test/crowdsale/Crowdsale.test.js @@ -4,15 +4,16 @@ const { ZERO_ADDRESS } = constants; const Crowdsale = artifacts.require('CrowdsaleMock'); const SimpleToken = artifacts.require('SimpleToken'); -contract('Crowdsale', function ([_, investor, wallet, purchaser]) { +contract.only('Crowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const value = ether('42'); const tokenSupply = new BN('10').pow(new BN('22')); const expectedTokenAmount = rate.mul(value); it('requires a non-null token', async function () { - await shouldFail.reverting( - Crowdsale.new(rate, wallet, ZERO_ADDRESS) + await shouldFail.reverting.withMessage( + Crowdsale.new(rate, wallet, ZERO_ADDRESS), + "Crowdsale: token is the zero address" ); }); @@ -22,14 +23,14 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { }); it('requires a non-zero rate', async function () { - await shouldFail.reverting( - Crowdsale.new(0, wallet, this.token.address) + await shouldFail.reverting.withMessage( + Crowdsale.new(0, wallet, this.token.address), "Crowdsale: rate is 0" ); }); it('requires a non-null wallet', async function () { - await shouldFail.reverting( - Crowdsale.new(rate, ZERO_ADDRESS, this.token.address) + await shouldFail.reverting.withMessage( + Crowdsale.new(rate, ZERO_ADDRESS, this.token.address), "Crowdsale: wallet is the zero address" ); }); @@ -46,8 +47,8 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { }); it('reverts on zero-valued payments', async function () { - await shouldFail.reverting( - this.crowdsale.send(0, { from: purchaser }) + await shouldFail.reverting.withMessage( + this.crowdsale.send(0, { from: purchaser }), "Crowdsale: weiAmount is 0" ); }); }); @@ -58,14 +59,14 @@ contract('Crowdsale', function ([_, investor, wallet, purchaser]) { }); it('reverts on zero-valued payments', async function () { - await shouldFail.reverting( - this.crowdsale.buyTokens(investor, { value: 0, from: purchaser }) + await shouldFail.reverting.withMessage( + this.crowdsale.buyTokens(investor, { value: 0, from: purchaser }), "Crowdsale: weiAmount is 0" ); }); it('requires a non-null beneficiary', async function () { - await shouldFail.reverting( - this.crowdsale.buyTokens(ZERO_ADDRESS, { value: value, from: purchaser }) + await shouldFail.reverting.withMessage( + this.crowdsale.buyTokens(ZERO_ADDRESS, { value: value, from: purchaser }), "Crowdsale: beneficiary is the zero address" ); }); }); diff --git a/test/crowdsale/FinalizableCrowdsale.test.js b/test/crowdsale/FinalizableCrowdsale.test.js index 77724e3e3b7..61a26607253 100644 --- a/test/crowdsale/FinalizableCrowdsale.test.js +++ b/test/crowdsale/FinalizableCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, expectEvent, shouldFail, time } = require('openzeppelin-test-helpers const FinalizableCrowdsaleImpl = artifacts.require('FinalizableCrowdsaleImpl'); const ERC20 = artifacts.require('ERC20'); -contract('FinalizableCrowdsale', function ([_, wallet, other]) { +contract.only('FinalizableCrowdsale', function ([_, wallet, other]) { const rate = new BN('1000'); before(async function () { @@ -23,7 +23,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, other]) { }); it('cannot be finalized before ending', async function () { - await shouldFail.reverting(this.crowdsale.finalize({ from: other })); + await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }), "FinalizableCrowdsale: not closed"); }); it('can be finalized by anyone after ending', async function () { @@ -34,7 +34,7 @@ contract('FinalizableCrowdsale', function ([_, wallet, other]) { it('cannot be finalized twice', async function () { await time.increaseTo(this.afterClosingTime); await this.crowdsale.finalize({ from: other }); - await shouldFail.reverting(this.crowdsale.finalize({ from: other })); + await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }), "FinalizableCrowdsale: already finalized"); }); it('logs finalized', async function () { diff --git a/test/crowdsale/IncreasingPriceCrowdsale.test.js b/test/crowdsale/IncreasingPriceCrowdsale.test.js index 387e3ff6fb0..44d785f76d2 100644 --- a/test/crowdsale/IncreasingPriceCrowdsale.test.js +++ b/test/crowdsale/IncreasingPriceCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers'); const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) { +contract.only('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) { const value = ether('1'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -26,21 +26,21 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) }); it('reverts with a final rate larger than the initial rate', async function () { - await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new( + await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.addn(1) - )); + ), "IncreasingPriceCrowdsale: initial rate is less than final rate"); }); it('reverts with a final rate equal to the initial rate', async function () { - await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new( + await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate - )); + ), "IncreasingPriceCrowdsale: initial rate is less than final rate"); }); it('reverts with a final rate of zero', async function () { - await shouldFail.reverting(IncreasingPriceCrowdsaleImpl.new( + await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, 0 - )); + ), "IncreasingPriceCrowdsale: final rate is 0"); }); context('with crowdsale', function () { @@ -57,7 +57,7 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) }); it('reverts when the base Crowdsale\'s rate function is called', async function () { - await shouldFail.reverting(this.crowdsale.rate()); + await shouldFail.reverting.withMessage(this.crowdsale.rate(), "VM Exception while processing transaction: revert"); }); it('returns a rate of 0 before the crowdsale starts', async function () { diff --git a/test/crowdsale/IndividuallyCappedCrowdsale.test.js b/test/crowdsale/IndividuallyCappedCrowdsale.test.js index 2465888fa65..b34e4f35248 100644 --- a/test/crowdsale/IndividuallyCappedCrowdsale.test.js +++ b/test/crowdsale/IndividuallyCappedCrowdsale.test.js @@ -4,7 +4,7 @@ const IndividuallyCappedCrowdsaleImpl = artifacts.require('IndividuallyCappedCro const SimpleToken = artifacts.require('SimpleToken'); const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior'); -contract('IndividuallyCappedCrowdsale', function ( +contract.only('IndividuallyCappedCrowdsale', function ( [_, capper, otherCapper, wallet, alice, bob, charlie, other, ...otherAccounts]) { const rate = new BN(1); const capAlice = ether('10'); @@ -34,7 +34,7 @@ contract('IndividuallyCappedCrowdsale', function ( }); it('reverts when a non-capper sets a cap', async function () { - await shouldFail.reverting(this.crowdsale.setCap(alice, capAlice, { from: other })); + await shouldFail.reverting.withMessage(this.crowdsale.setCap(alice, capAlice, { from: other }), "CapperRole: caller does not have the Capper role"); }); context('with individual caps', function () { @@ -52,21 +52,21 @@ contract('IndividuallyCappedCrowdsale', function ( it('should reject payments outside cap', async function () { await this.crowdsale.buyTokens(alice, { value: capAlice }); - await shouldFail.reverting(this.crowdsale.buyTokens(alice, { value: 1 })); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(alice, { value: 1 }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); }); it('should reject payments that exceed cap', async function () { - await shouldFail.reverting(this.crowdsale.buyTokens(alice, { value: capAlice.addn(1) })); - await shouldFail.reverting(this.crowdsale.buyTokens(bob, { value: capBob.addn(1) })); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(alice, { value: capAlice.addn(1) }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(bob, { value: capBob.addn(1) }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); }); it('should manage independent caps', async function () { await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice }); - await shouldFail.reverting(this.crowdsale.buyTokens(bob, { value: lessThanCapAlice })); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(bob, { value: lessThanCapAlice }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); }); it('should default to a cap of zero', async function () { - await shouldFail.reverting(this.crowdsale.buyTokens(charlie, { value: lessThanCapBoth })); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(charlie, { value: lessThanCapBoth }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); }); }); diff --git a/test/crowdsale/MintedCrowdsale.test.js b/test/crowdsale/MintedCrowdsale.test.js index 2928f0142dc..d41856d9879 100644 --- a/test/crowdsale/MintedCrowdsale.test.js +++ b/test/crowdsale/MintedCrowdsale.test.js @@ -5,7 +5,7 @@ const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20 = artifacts.require('ERC20'); -contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]) { +contract.only('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]) { const rate = new BN('1000'); const value = ether('5'); @@ -32,11 +32,11 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser] }); it('rejects bare payments', async function () { - await shouldFail.reverting(this.crowdsale.send(value)); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), "VM Exception while processing transaction: revert"); }); it('rejects token purchases', async function () { - await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: value, from: purchaser })); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), "VM Exception while processing transaction: revert"); }); }); }); diff --git a/test/crowdsale/PausableCrowdsale.test.js b/test/crowdsale/PausableCrowdsale.test.js index bd16972174d..9b68004824e 100644 --- a/test/crowdsale/PausableCrowdsale.test.js +++ b/test/crowdsale/PausableCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, shouldFail } = require('openzeppelin-test-helpers'); const PausableCrowdsale = artifacts.require('PausableCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('PausableCrowdsale', function ([_, pauser, wallet, other]) { +contract.only('PausableCrowdsale', function ([_, pauser, wallet, other]) { const rate = new BN(1); const value = new BN(1); @@ -26,8 +26,8 @@ contract('PausableCrowdsale', function ([_, pauser, wallet, other]) { }); it('purchases do not work', async function () { - await shouldFail.reverting(this.crowdsale.sendTransaction({ from: other, value })); - await shouldFail.reverting(this.crowdsale.buyTokens(other, { from: other, value })); + await shouldFail.reverting.withMessage(this.crowdsale.sendTransaction({ from: other, value }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(other, { from: other, value }), "Pausable: paused"); }); context('after unpause', function () { diff --git a/test/crowdsale/PostDeliveryCrowdsale.test.js b/test/crowdsale/PostDeliveryCrowdsale.test.js index 1417a1c76e5..abfb69b97d7 100644 --- a/test/crowdsale/PostDeliveryCrowdsale.test.js +++ b/test/crowdsale/PostDeliveryCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers'); const PostDeliveryCrowdsaleImpl = artifacts.require('PostDeliveryCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { +contract.only('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const tokenSupply = new BN('10').pow(new BN('22')); @@ -41,7 +41,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { - await shouldFail.reverting(this.crowdsale.withdrawTokens(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "PostDeliveryCrowdsale: not closed"); }); context('after closing time', function () { @@ -57,7 +57,7 @@ contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { it('rejects multiple withdrawals', async function () { await this.crowdsale.withdrawTokens(investor); - await shouldFail.reverting(this.crowdsale.withdrawTokens(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "PostDeliveryCrowdsale: beneficiary is not due any tokens"); }); }); }); diff --git a/test/crowdsale/RefundableCrowdsale.test.js b/test/crowdsale/RefundableCrowdsale.test.js index 3a14f24c1ca..af2ae197d5a 100644 --- a/test/crowdsale/RefundableCrowdsale.test.js +++ b/test/crowdsale/RefundableCrowdsale.test.js @@ -3,7 +3,7 @@ const { balance, BN, ether, shouldFail, time } = require('openzeppelin-test-help const RefundableCrowdsaleImpl = artifacts.require('RefundableCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other]) { +contract.only('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other]) { const rate = new BN(1); const goal = ether('50'); const lessThanGoal = ether('45'); @@ -24,8 +24,8 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other }); it('rejects a goal of zero', async function () { - await shouldFail.reverting( - RefundableCrowdsaleImpl.new(this.openingTime, this.closingTime, rate, wallet, this.token.address, 0) + await shouldFail.reverting.withMessage( + RefundableCrowdsaleImpl.new(this.openingTime, this.closingTime, rate, wallet, this.token.address, 0), "RefundableCrowdsale: goal is 0" ); }); @@ -40,7 +40,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other context('before opening time', function () { it('denies refunds', async function () { - await shouldFail.reverting(this.crowdsale.claimRefund(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), "RefundableCrowdsale: not finalized"); }); }); @@ -50,7 +50,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other }); it('denies refunds', async function () { - await shouldFail.reverting(this.crowdsale.claimRefund(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), "RefundableCrowdsale: not finalized"); }); context('with unreached goal', function () { @@ -84,7 +84,7 @@ contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other }); it('denies refunds', async function () { - await shouldFail.reverting(this.crowdsale.claimRefund(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), "RefundableCrowdsale: goal reached"); }); it('forwards funds to wallet', async function () { diff --git a/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js b/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js index 775bcc0a815..2d3042fc701 100644 --- a/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js +++ b/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers'); const RefundablePostDeliveryCrowdsaleImpl = artifacts.require('RefundablePostDeliveryCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { +contract.only('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const tokenSupply = new BN('10').pow(new BN('22')); const goal = ether('100'); @@ -42,7 +42,7 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { - await shouldFail.reverting(this.crowdsale.withdrawTokens(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "RefundablePostDeliveryCrowdsale: not finalized"); }); context('after closing time and finalization', function () { @@ -52,7 +52,7 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc }); it('rejects token withdrawals', async function () { - await shouldFail.reverting(this.crowdsale.withdrawTokens(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "RefundablePostDeliveryCrowdsale: goal not reached"); }); }); }); @@ -70,7 +70,7 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { - await shouldFail.reverting(this.crowdsale.withdrawTokens(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "RefundablePostDeliveryCrowdsale: not finalized"); }); context('after closing time and finalization', function () { @@ -87,7 +87,7 @@ contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purc it('rejects multiple withdrawals', async function () { await this.crowdsale.withdrawTokens(investor); - await shouldFail.reverting(this.crowdsale.withdrawTokens(investor)); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "PostDeliveryCrowdsale: beneficiary is not due any tokens"); }); }); }); diff --git a/test/crowdsale/TimedCrowdsale.test.js b/test/crowdsale/TimedCrowdsale.test.js index be42ba0ff26..e588a0caaad 100644 --- a/test/crowdsale/TimedCrowdsale.test.js +++ b/test/crowdsale/TimedCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, expectEvent, shouldFail, time } = require('openzeppelin-test- const TimedCrowdsaleImpl = artifacts.require('TimedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { +contract.only('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const value = ether('42'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -21,21 +21,21 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { }); it('reverts if the opening time is in the past', async function () { - await shouldFail.reverting(TimedCrowdsaleImpl.new( + await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( (await time.latest()).sub(time.duration.days(1)), this.closingTime, rate, wallet, this.token.address - )); + ), "TimedCrowdsale: opening time is before current time"); }); it('reverts if the closing time is before the opening time', async function () { - await shouldFail.reverting(TimedCrowdsaleImpl.new( + await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime.sub(time.duration.seconds(1)), rate, wallet, this.token.address - )); + ), "TimedCrowdsale: closing time is before opening time"); }); it('reverts if the closing time equals the opening time', async function () { - await shouldFail.reverting(TimedCrowdsaleImpl.new( + await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime, rate, wallet, this.token.address - )); + ), "TimedCrowdsale: closing time is before opening time"); }); context('with crowdsale', function () { @@ -56,8 +56,8 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { describe('accepting payments', function () { it('should reject payments before start', async function () { (await this.crowdsale.isOpen()).should.equal(false); - await shouldFail.reverting(this.crowdsale.send(value)); - await shouldFail.reverting(this.crowdsale.buyTokens(investor, { from: purchaser, value: value })); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: purchaser, value: value }), "TimedCrowdsale: not open"); }); it('should accept payments after start', async function () { @@ -69,25 +69,25 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('should reject payments after end', async function () { await time.increaseTo(this.afterClosingTime); - await shouldFail.reverting(this.crowdsale.send(value)); - await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: value, from: purchaser })); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), "TimedCrowdsale: not open"); }); }); describe('extending closing time', function () { it('should not reduce duration', async function () { // Same date - await shouldFail.reverting(this.crowdsale.extendTime(this.closingTime)); + await shouldFail.reverting.withMessage(this.crowdsale.extendTime(this.closingTime), "TimedCrowdsale: new closing time is before current closing time"); // Prescending date const newClosingTime = this.closingTime.sub(time.duration.seconds(1)); - await shouldFail.reverting(this.crowdsale.extendTime(newClosingTime)); + await shouldFail.reverting.withMessage(this.crowdsale.extendTime(newClosingTime), "TimedCrowdsale: new closing time is before current closing time"); }); context('before crowdsale start', function () { beforeEach(async function () { (await this.crowdsale.isOpen()).should.equal(false); - await shouldFail.reverting(this.crowdsale.send(value)); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), "TimedCrowdsale: not open"); }); it('it extends end time', async function () { @@ -126,7 +126,7 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('it reverts', async function () { const newClosingTime = await time.latest(); - await shouldFail.reverting(this.crowdsale.extendTime(newClosingTime)); + await shouldFail.reverting.withMessage(this.crowdsale.extendTime(newClosingTime), "TimedCrowdsale: already closed"); }); }); }); diff --git a/test/crowdsale/WhitelistCrowdsale.test.js b/test/crowdsale/WhitelistCrowdsale.test.js index f0d4a42d77d..8a894a5909d 100644 --- a/test/crowdsale/WhitelistCrowdsale.test.js +++ b/test/crowdsale/WhitelistCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail } = require('openzeppelin-test-helpers'); const WhitelistCrowdsale = artifacts.require('WhitelistCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, other]) { +contract.only('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, other]) { const rate = new BN(1); const value = ether('42'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -20,8 +20,8 @@ contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, o } async function purchaseShouldFail (crowdsale, beneficiary, value) { - await shouldFail.reverting(crowdsale.buyTokens(beneficiary, { from: beneficiary, value })); - await shouldFail.reverting(crowdsale.sendTransaction({ from: beneficiary, value })); + await shouldFail.reverting.withMessage(crowdsale.buyTokens(beneficiary, { from: beneficiary, value }), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role"); + await shouldFail.reverting.withMessage(crowdsale.sendTransaction({ from: beneficiary, value }), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role"); } context('with no whitelisted addresses', function () { diff --git a/test/cryptography/ECDSA.test.js b/test/cryptography/ECDSA.test.js index 046096af43e..9036785d9ae 100644 --- a/test/cryptography/ECDSA.test.js +++ b/test/cryptography/ECDSA.test.js @@ -7,7 +7,7 @@ const ECDSAMock = artifacts.require('ECDSAMock'); const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin'); const WRONG_MESSAGE = web3.utils.sha3('Nope'); -contract('ECDSA', function ([_, other]) { +contract.only('ECDSA', function ([_, other]) { beforeEach(async function () { this.ecdsa = await ECDSAMock.new(); }); @@ -118,8 +118,9 @@ contract('ECDSA', function ([_, other]) { it.skip('reverts', async function () { // Create the signature const signature = await web3.eth.sign(TEST_MESSAGE, other); - await shouldFail.reverting( - this.ecdsa.recover(TEST_MESSAGE.substring(2), signature) + await shouldFail.reverting.withMessage( + this.ecdsa.recover(TEST_MESSAGE.substring(2), signature), + "Failure message" ); }); }); diff --git a/test/drafts/Counters.test.js b/test/drafts/Counters.test.js index ad10d51c633..da29492621b 100644 --- a/test/drafts/Counters.test.js +++ b/test/drafts/Counters.test.js @@ -2,7 +2,7 @@ const { shouldFail } = require('openzeppelin-test-helpers'); const CountersImpl = artifacts.require('CountersImpl'); -contract('Counters', function () { +contract.only('Counters', function () { beforeEach(async function () { this.counter = await CountersImpl.new(); }); @@ -39,7 +39,7 @@ contract('Counters', function () { it('reverts if the current value is 0', async function () { await this.counter.decrement(); - await shouldFail.reverting(this.counter.decrement()); + await shouldFail.reverting.withMessage(this.counter.decrement(), "SafeMath: subtraction overflow"); }); it('can be called multiple times', async function () { diff --git a/test/drafts/ERC1820Implementer.test.js b/test/drafts/ERC1820Implementer.test.js index 083e8760abc..95ffb22ca61 100644 --- a/test/drafts/ERC1820Implementer.test.js +++ b/test/drafts/ERC1820Implementer.test.js @@ -3,7 +3,7 @@ const { bufferToHex, keccak256 } = require('ethereumjs-util'); const ERC1820ImplementerMock = artifacts.require('ERC1820ImplementerMock'); -contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]) { +contract.only('ERC1820Implementer', function ([_, registryFunder, implementee, other]) { const ERC1820_ACCEPT_MAGIC = bufferToHex(keccak256('ERC1820_ACCEPT_MAGIC')); beforeEach(async function () { @@ -21,10 +21,11 @@ contract('ERC1820Implementer', function ([_, registryFunder, implementee, other] }); it('reverts when attempting to set as implementer in the registry', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.registry.setInterfaceImplementer( implementee, this.interfaceA, this.implementer.address, { from: implementee } - ) + ), + "Does not implement the interface" ); }); }); diff --git a/test/drafts/ERC20Migrator.test.js b/test/drafts/ERC20Migrator.test.js index 6e8fd451d40..c9472ecaec2 100644 --- a/test/drafts/ERC20Migrator.test.js +++ b/test/drafts/ERC20Migrator.test.js @@ -5,11 +5,11 @@ const ERC20Mock = artifacts.require('ERC20Mock'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20Migrator = artifacts.require('ERC20Migrator'); -contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { +contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { const totalSupply = new BN('200'); it('reverts with a null legacy token address', async function () { - await shouldFail.reverting(ERC20Migrator.new(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(ERC20Migrator.new(ZERO_ADDRESS), "ERC20Migrator: legacy token is the zero address"); }); describe('with tokens and migrator', function () { @@ -25,11 +25,11 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { describe('beginMigration', function () { it('reverts with a null new token address', async function () { - await shouldFail.reverting(this.migrator.beginMigration(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(this.migrator.beginMigration(ZERO_ADDRESS), "ERC20Migrator: new token is the zero address"); }); it('reverts if not a minter of the token', async function () { - await shouldFail.reverting(this.migrator.beginMigration(this.newToken.address)); + await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address), "ERC20Migrator: not a minter for new token"); }); it('succeeds if it is a minter of the token', async function () { @@ -40,7 +40,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { it('reverts the second time it is called', async function () { await this.newToken.addMinter(this.migrator.address); await this.migrator.beginMigration(this.newToken.address); - await shouldFail.reverting(this.migrator.beginMigration(this.newToken.address)); + await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address), "ERC20Migrator: migration already started"); }); }); @@ -58,7 +58,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); it('reverts', async function () { - await shouldFail.reverting(this.migrator.migrateAll(owner)); + await shouldFail.reverting.withMessage(this.migrator.migrateAll(owner), "ERC20Migrator: migration not started"); }); }); }); @@ -72,7 +72,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { }); it('reverts', async function () { - await shouldFail.reverting(this.migrator.migrate(owner, amount)); + await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount), "ERC20Migrator: migration not started"); }); }); }); @@ -174,7 +174,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { const amount = baseAmount.addn(1); it('reverts', async function () { - await shouldFail.reverting(this.migrator.migrate(owner, amount)); + await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount), "SafeERC20: low-level call failed"); }); }); }); diff --git a/test/drafts/ERC20Snapshot.test.js b/test/drafts/ERC20Snapshot.test.js index 0a3e4de3dff..f70a61ab491 100644 --- a/test/drafts/ERC20Snapshot.test.js +++ b/test/drafts/ERC20Snapshot.test.js @@ -1,7 +1,7 @@ const { BN, expectEvent, shouldFail } = require('openzeppelin-test-helpers'); const ERC20SnapshotMock = artifacts.require('ERC20SnapshotMock'); -contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { +contract.only('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { const initialSupply = new BN(100); beforeEach(async function () { @@ -24,11 +24,11 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { describe('totalSupplyAt', function () { it('reverts with a snapshot id of 0', async function () { - await shouldFail.reverting(this.token.totalSupplyAt(0)); + await shouldFail.reverting.withMessage(this.token.totalSupplyAt(0), "ERC20Snapshot: id is 0"); }); it('reverts with a not-yet-created snapshot id', async function () { - await shouldFail.reverting(this.token.totalSupplyAt(1)); + await shouldFail.reverting.withMessage(this.token.totalSupplyAt(1), "ERC20Snapshot: nonexistent id"); }); context('with initial snapshot', function () { @@ -98,11 +98,11 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { describe('balanceOfAt', function () { it('reverts with a snapshot id of 0', async function () { - await shouldFail.reverting(this.token.balanceOfAt(other, 0)); + await shouldFail.reverting.withMessage(this.token.balanceOfAt(other, 0), "ERC20Snapshot: id is 0"); }); it('reverts with a not-yet-created snapshot id', async function () { - await shouldFail.reverting(this.token.balanceOfAt(other, 1)); + await shouldFail.reverting.withMessage(this.token.balanceOfAt(other, 1), "ERC20Snapshot: nonexistent id"); }); context('with initial snapshot', function () { diff --git a/test/drafts/SignatureBouncer.test.js b/test/drafts/SignatureBouncer.test.js index 3d84eeff550..d23fe4c144f 100644 --- a/test/drafts/SignatureBouncer.test.js +++ b/test/drafts/SignatureBouncer.test.js @@ -8,7 +8,7 @@ const UINT_VALUE = 23; const BYTES_VALUE = web3.utils.toHex('test'); const INVALID_SIGNATURE = '0xabcd'; -contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorizedUser, ...otherAccounts]) { +contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, authorizedUser, ...otherAccounts]) { beforeEach(async function () { this.sigBouncer = await SignatureBouncerMock.new({ from: signer }); this.signFor = getSignFor(this.sigBouncer, signer); @@ -30,21 +30,21 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorize }); it('does not allow invalid signature for sender', async function () { - await shouldFail.reverting( - this.sigBouncer.onlyWithValidSignature(INVALID_SIGNATURE, { from: authorizedUser }) + await shouldFail.reverting.withMessage( + this.sigBouncer.onlyWithValidSignature(INVALID_SIGNATURE, { from: authorizedUser }), "SignatureBouncer: invalid signature for caller" ); }); it('does not allow valid signature for other sender', async function () { - await shouldFail.reverting( - this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser), { from: other }) + await shouldFail.reverting.withMessage( + this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser), { from: other }), "SignatureBouncer: invalid signature for caller" ); }); it('does not allow valid signature for method for sender', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser, 'onlyWithValidSignature'), - { from: authorizedUser }) + { from: authorizedUser }), "SignatureBouncer: invalid signature for caller" ); }); }); @@ -57,29 +57,29 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorize }); it('does not allow invalid signature with correct method for sender', async function () { - await shouldFail.reverting( - this.sigBouncer.onlyWithValidSignatureAndMethod(INVALID_SIGNATURE, { from: authorizedUser }) + await shouldFail.reverting.withMessage( + this.sigBouncer.onlyWithValidSignatureAndMethod(INVALID_SIGNATURE, { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and method" ); }); it('does not allow valid signature with correct method for other sender', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndMethod( await this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: other } - ) + ), "SignatureBouncer: invalid signature for caller and method" ); }); it('does not allow valid method signature with incorrect method for sender', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser, 'theWrongMethod'), - { from: authorizedUser }) + { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and method" ); }); it('does not allow valid non-method signature method for sender', async function () { - await shouldFail.reverting( - this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser), { from: authorizedUser }) + await shouldFail.reverting.withMessage( + this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser), { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and method" ); }); }); @@ -92,40 +92,40 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorize }); it('does not allow invalid signature with correct method and data for sender', async function () { - await shouldFail.reverting( - this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, INVALID_SIGNATURE, { from: authorizedUser }) + await shouldFail.reverting.withMessage( + this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, INVALID_SIGNATURE, { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and data" ); }); it('does not allow valid signature with correct method and incorrect data for sender', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE + 10, await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]), { from: authorizedUser } - ) + ), "SignatureBouncer: invalid signature for caller and data" ); }); it('does not allow valid signature with correct method and data for other sender', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]), { from: other } - ) + ), "SignatureBouncer: invalid signature for caller and data" ); }); it('does not allow valid non-method signature for sender', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, await this.signFor(authorizedUser), { from: authorizedUser } - ) + ), "SignatureBouncer: invalid signature for caller and data" ); }); it('does not allow msg.data shorter than SIGNATURE_SIZE', async function () { - await shouldFail.reverting( - this.sigBouncer.tooShortMsgData({ from: authorizedUser }) + await shouldFail.reverting.withMessage( + this.sigBouncer.tooShortMsgData({ from: authorizedUser }), "SignatureBouncer: data is too short" ); }); }); diff --git a/test/drafts/SignedSafeMath.test.js b/test/drafts/SignedSafeMath.test.js index b40adf6e6a6..b23a00ee3b8 100644 --- a/test/drafts/SignedSafeMath.test.js +++ b/test/drafts/SignedSafeMath.test.js @@ -3,7 +3,7 @@ const { MAX_INT256, MIN_INT256 } = constants; const SignedSafeMathMock = artifacts.require('SignedSafeMathMock'); -contract('SignedSafeMath', function () { +contract.only('SignedSafeMath', function () { beforeEach(async function () { this.safeMath = await SignedSafeMathMock.new(); }); @@ -14,8 +14,9 @@ contract('SignedSafeMath', function () { } async function testFailsCommutative (fn, lhs, rhs) { - await shouldFail.reverting(fn(lhs, rhs)); - await shouldFail.reverting(fn(rhs, lhs)); + //TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages + await shouldFail.reverting.withMessage(fn(lhs, rhs)); + await shouldFail.reverting.withMessage(fn(rhs, lhs)); } describe('add', function () { @@ -69,14 +70,14 @@ contract('SignedSafeMath', function () { const a = MAX_INT256; const b = new BN('-1'); - await shouldFail.reverting(this.safeMath.sub(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), "SignedSafeMath: subtraction overflow"); }); it('reverts on negative subtraction overflow', async function () { const a = MIN_INT256; const b = new BN('1'); - await shouldFail.reverting(this.safeMath.sub(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), "SignedSafeMath: subtraction overflow"); }); }); @@ -137,14 +138,14 @@ contract('SignedSafeMath', function () { const a = new BN('-5678'); const b = new BN('0'); - await shouldFail.reverting(this.safeMath.div(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.div(a, b), "SignedSafeMath: division by zero"); }); it('reverts on overflow, negative second', async function () { const a = new BN(MIN_INT256); const b = new BN('-1'); - await shouldFail.reverting(this.safeMath.div(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.div(a, b), "SignedSafeMath: division overflow"); }); }); }); diff --git a/test/drafts/TokenVesting.test.js b/test/drafts/TokenVesting.test.js index d9474a1878f..f4107fdabbb 100644 --- a/test/drafts/TokenVesting.test.js +++ b/test/drafts/TokenVesting.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const ERC20Mintable = artifacts.require('ERC20Mintable'); const TokenVesting = artifacts.require('TokenVesting'); -contract('TokenVesting', function ([_, owner, beneficiary]) { +contract.only('TokenVesting', function ([_, owner, beneficiary]) { const amount = new BN('1000'); beforeEach(async function () { @@ -20,21 +20,21 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { cliffDuration.should.be.bignumber.that.is.at.least(duration); - await shouldFail.reverting( - TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }) + await shouldFail.reverting.withMessage( + TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }), "TokenVesting: cliff is longer than duration" ); }); it('reverts with a null beneficiary', async function () { - await shouldFail.reverting( - TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }) + await shouldFail.reverting.withMessage( + TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }), "TokenVesting: beneficiary is the zero address" ); }); it('reverts with a null duration', async function () { // cliffDuration should also be 0, since the duration must be larger than the cliff - await shouldFail.reverting( - TokenVesting.new(beneficiary, this.start, 0, 0, true, { from: owner }) + await shouldFail.reverting.withMessage( + TokenVesting.new(beneficiary, this.start, 0, 0, true, { from: owner }), "TokenVesting: duration is 0" ); }); @@ -42,8 +42,8 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { const now = await time.latest(); this.start = now.sub(this.duration).sub(time.duration.minutes(1)); - await shouldFail.reverting( - TokenVesting.new(beneficiary, this.start, this.cliffDuration, this.duration, true, { from: owner }) + await shouldFail.reverting.withMessage( + TokenVesting.new(beneficiary, this.start, this.cliffDuration, this.duration, true, { from: owner }), "TokenVesting: starting time is before current time" ); }); @@ -65,7 +65,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { }); it('cannot be released before cliff', async function () { - await shouldFail.reverting(this.vesting.release(this.token.address)); + await shouldFail.reverting.withMessage(this.vesting.release(this.token.address), "TokenVesting: no tokens are due"); }); it('can be released after cliff', async function () { @@ -121,7 +121,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { beneficiary, this.start, this.cliffDuration, this.duration, false, { from: owner } ); - await shouldFail.reverting(vesting.revoke(this.token.address, { from: owner })); + await shouldFail.reverting.withMessage(vesting.revoke(this.token.address, { from: owner }), "TokenVesting: cannot revoke"); }); it('should return the non-vested tokens when revoked by owner', async function () { @@ -148,7 +148,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { it('should fail to be revoked a second time', async function () { await this.vesting.revoke(this.token.address, { from: owner }); - await shouldFail.reverting(this.vesting.revoke(this.token.address, { from: owner })); + await shouldFail.reverting.withMessage(this.vesting.revoke(this.token.address, { from: owner }), "TokenVesting: token already revoked"); }); function vestedAmount (total, now, start, cliffDuration, duration) { diff --git a/test/examples/SampleCrowdsale.test.js b/test/examples/SampleCrowdsale.test.js index cd3061f1acc..327fde9c3f2 100644 --- a/test/examples/SampleCrowdsale.test.js +++ b/test/examples/SampleCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, balance, ether, shouldFail, time } = require('openzeppelin-test-help const SampleCrowdsale = artifacts.require('SampleCrowdsale'); const SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken'); -contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { +contract.only('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { const RATE = new BN(10); const GOAL = ether('10'); const CAP = ether('20'); @@ -38,8 +38,8 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { }); it('should not accept payments before start', async function () { - await shouldFail.reverting(this.crowdsale.send(ether('1'))); - await shouldFail.reverting(this.crowdsale.buyTokens(investor, { from: investor, value: ether('1') })); + await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: investor, value: ether('1') }), "TimedCrowdsale: not open"); }); it('should accept payments during the sale', async function () { @@ -55,14 +55,14 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { it('should reject payments after end', async function () { await time.increaseTo(this.afterClosingTime); - await shouldFail.reverting(this.crowdsale.send(ether('1'))); - await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: ether('1'), from: investor })); + await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: ether('1'), from: investor }),"TimedCrowdsale: not open"); }); it('should reject payments over cap', async function () { await time.increaseTo(this.openingTime); await this.crowdsale.send(CAP); - await shouldFail.reverting(this.crowdsale.send(1)); + await shouldFail.reverting.withMessage(this.crowdsale.send(1),"CappedCrowdsale: cap exceeded"); }); it('should allow finalization and transfer funds to wallet if the goal is reached', async function () { @@ -93,9 +93,9 @@ contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { const HIGH_GOAL = ether('30'); it('creation reverts', async function () { - await shouldFail.reverting(SampleCrowdsale.new( + await shouldFail.reverting.withMessage(SampleCrowdsale.new( this.openingTime, this.closingTime, RATE, wallet, CAP, this.token.address, HIGH_GOAL - )); + ), "SampleCrowdSale: goal is greater than cap"); }); }); }); diff --git a/test/introspection/ERC165.test.js b/test/introspection/ERC165.test.js index 64ca89eb718..3cb85b6a993 100644 --- a/test/introspection/ERC165.test.js +++ b/test/introspection/ERC165.test.js @@ -3,13 +3,13 @@ const { shouldSupportInterfaces } = require('./SupportsInterface.behavior'); const ERC165Mock = artifacts.require('ERC165Mock'); -contract('ERC165', function () { +contract.only('ERC165', function () { beforeEach(async function () { this.mock = await ERC165Mock.new(); }); it('does not allow 0xffffffff', async function () { - await shouldFail.reverting(this.mock.registerInterface('0xffffffff')); + await shouldFail.reverting.withMessage(this.mock.registerInterface('0xffffffff'), "ERC165: invalid interface id"); }); shouldSupportInterfaces([ diff --git a/test/lifecycle/Pausable.test.js b/test/lifecycle/Pausable.test.js index d5698943eaf..49da097abc6 100644 --- a/test/lifecycle/Pausable.test.js +++ b/test/lifecycle/Pausable.test.js @@ -3,7 +3,7 @@ const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/Public const PausableMock = artifacts.require('PausableMock'); -contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]) { +contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]) { beforeEach(async function () { this.pausable = await PausableMock.new({ from: pauser }); }); @@ -30,7 +30,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('cannot take drastic measure in non-pause', async function () { - await shouldFail.reverting(this.pausable.drasticMeasure({ from: other })); + await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }), "Pausable: not paused"); (await this.pausable.drasticMeasureTaken()).should.equal(false); }); @@ -41,7 +41,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('reverts when pausing from non-pauser', async function () { - await shouldFail.reverting(this.pausable.pause({ from: other })); + await shouldFail.reverting.withMessage(this.pausable.pause({ from: other }), "PauserRole: caller does not have the Pauser role"); }); context('when paused', function () { @@ -54,7 +54,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('cannot perform normal process in pause', async function () { - await shouldFail.reverting(this.pausable.normalProcess({ from: other })); + await shouldFail.reverting.withMessage(this.pausable.normalProcess({ from: other }), "Pausable: paused"); }); it('can take a drastic measure in a pause', async function () { @@ -63,7 +63,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('reverts when re-pausing', async function () { - await shouldFail.reverting(this.pausable.pause({ from: pauser })); + await shouldFail.reverting.withMessage(this.pausable.pause({ from: pauser }), "Pausable: paused"); }); describe('unpausing', function () { @@ -73,7 +73,7 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('reverts when unpausing from non-pauser', async function () { - await shouldFail.reverting(this.pausable.unpause({ from: other })); + await shouldFail.reverting.withMessage(this.pausable.unpause({ from: other }), "PauserRole: caller does not have the Pauser role"); }); context('when unpaused', function () { @@ -92,11 +92,11 @@ contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts] }); it('should prevent drastic measure', async function () { - await shouldFail.reverting(this.pausable.drasticMeasure({ from: other })); + await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }), "Pausable: not paused"); }); it('reverts when re-unpausing', async function () { - await shouldFail.reverting(this.pausable.unpause({ from: pauser })); + await shouldFail.reverting.withMessage(this.pausable.unpause({ from: pauser }), "Pausable: not paused"); }); }); }); diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index 78654465a85..c4395c73226 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -3,7 +3,7 @@ const { MAX_UINT256 } = constants; const SafeMathMock = artifacts.require('SafeMathMock'); -contract('SafeMath', function () { +contract.only('SafeMath', function () { beforeEach(async function () { this.safeMath = await SafeMathMock.new(); }); @@ -14,8 +14,9 @@ contract('SafeMath', function () { } async function testFailsCommutative (fn, lhs, rhs) { - await shouldFail.reverting(fn(lhs, rhs)); - await shouldFail.reverting(fn(rhs, lhs)); + //TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages + await shouldFail.reverting.withMessage(fn(lhs, rhs)); + await shouldFail.reverting.withMessage(fn(rhs, lhs)); } describe('add', function () { @@ -46,7 +47,7 @@ contract('SafeMath', function () { const a = new BN('1234'); const b = new BN('5678'); - await shouldFail.reverting(this.safeMath.sub(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), "SafeMath: subtraction overflow"); }); }); @@ -99,7 +100,7 @@ contract('SafeMath', function () { const a = new BN('5678'); const b = new BN('0'); - await shouldFail.reverting(this.safeMath.div(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.div(a, b), "SafeMath: division by zero"); }); }); @@ -138,7 +139,7 @@ contract('SafeMath', function () { const a = new BN('5678'); const b = new BN('0'); - await shouldFail.reverting(this.safeMath.mod(a, b)); + await shouldFail.reverting.withMessage(this.safeMath.mod(a, b), "SafeMath: modulo by zero"); }); }); }); diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index 29a1218c45d..be956e06f72 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -17,11 +17,11 @@ function shouldBehaveLikeOwnable (owner, [other]) { }); it('should prevent non-owners from transferring', async function () { - await shouldFail.reverting(this.ownable.transferOwnership(other, { from: other })); + await shouldFail.reverting.withMessage(this.ownable.transferOwnership(other, { from: other })); }); it('should guard ownership against stuck state', async function () { - await shouldFail.reverting(this.ownable.transferOwnership(ZERO_ADDRESS, { from: owner })); + await shouldFail.reverting.withMessage(this.ownable.transferOwnership(ZERO_ADDRESS, { from: owner })); }); it('loses owner after renouncement', async function () { @@ -32,7 +32,7 @@ function shouldBehaveLikeOwnable (owner, [other]) { }); it('should prevent non-owners from renouncement', async function () { - await shouldFail.reverting(this.ownable.renounceOwnership({ from: other })); + await shouldFail.reverting.withMessage(this.ownable.renounceOwnership({ from: other })); }); }); } diff --git a/test/ownership/Secondary.test.js b/test/ownership/Secondary.test.js index 7763e3a8fd5..f7a1695a6bc 100644 --- a/test/ownership/Secondary.test.js +++ b/test/ownership/Secondary.test.js @@ -3,7 +3,7 @@ const { ZERO_ADDRESS } = constants; const SecondaryMock = artifacts.require('SecondaryMock'); -contract('Secondary', function ([_, primary, newPrimary, other]) { +contract.only('Secondary', function ([_, primary, newPrimary, other]) { beforeEach(async function () { this.secondary = await SecondaryMock.new({ from: primary }); }); @@ -18,7 +18,7 @@ contract('Secondary', function ([_, primary, newPrimary, other]) { }); it('reverts when anyone calls onlyPrimary functions', async function () { - await shouldFail.reverting(this.secondary.onlyPrimaryMock({ from: other })); + await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: other }), "Secondary: caller is not the primary account"); }); }); @@ -30,11 +30,11 @@ contract('Secondary', function ([_, primary, newPrimary, other]) { }); it('reverts when transferring to the null address', async function () { - await shouldFail.reverting(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary })); + await shouldFail.reverting.withMessage(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }), "Secondary: new primary is the zero address"); }); it('reverts when called by anyone', async function () { - await shouldFail.reverting(this.secondary.transferPrimary(newPrimary, { from: other })); + await shouldFail.reverting.withMessage(this.secondary.transferPrimary(newPrimary, { from: other }), "Secondary: caller is not the primary account"); }); context('with new primary', function () { @@ -47,7 +47,7 @@ contract('Secondary', function ([_, primary, newPrimary, other]) { }); it('reverts when the old primary account calls onlyPrimary functions', async function () { - await shouldFail.reverting(this.secondary.onlyPrimaryMock({ from: primary })); + await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: primary }), "Secondary: caller is not the primary account"); }); }); }); diff --git a/test/payment/PaymentSplitter.test.js b/test/payment/PaymentSplitter.test.js index b9f097e7679..d958447900b 100644 --- a/test/payment/PaymentSplitter.test.js +++ b/test/payment/PaymentSplitter.test.js @@ -3,31 +3,31 @@ const { ZERO_ADDRESS } = constants; const PaymentSplitter = artifacts.require('PaymentSplitter'); -contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { +contract.only('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { const amount = ether('1'); it('rejects an empty set of payees', async function () { - await shouldFail.reverting(PaymentSplitter.new([], [])); + await shouldFail.reverting.withMessage(PaymentSplitter.new([], []), "PaymentSplitter: no payees"); }); it('rejects more payees than shares', async function () { - await shouldFail.reverting(PaymentSplitter.new([payee1, payee2, payee3], [20, 30])); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2, payee3], [20, 30]), "PaymentSplitter: payees and shares length mismatch"); }); it('rejects more shares than payees', async function () { - await shouldFail.reverting(PaymentSplitter.new([payee1, payee2], [20, 30, 40])); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 30, 40]), "PaymentSplitter: payees and shares length mismatch"); }); it('rejects null payees', async function () { - await shouldFail.reverting(PaymentSplitter.new([payee1, ZERO_ADDRESS], [20, 30])); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, ZERO_ADDRESS], [20, 30]), "PaymentSplitter: account is the zero address"); }); it('rejects zero-valued shares', async function () { - await shouldFail.reverting(PaymentSplitter.new([payee1, payee2], [20, 0])); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 0]), "PaymentSplitter: shares are 0"); }); it('rejects repeated payees', async function () { - await shouldFail.reverting(PaymentSplitter.new([payee1, payee1], [20, 30])); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee1], [20, 30]), "PaymentSplitter: account already has shares"); }); context('once deployed', function () { @@ -64,12 +64,12 @@ contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpaye }); it('should throw if no funds to claim', async function () { - await shouldFail.reverting(this.contract.release(payee1)); + await shouldFail.reverting.withMessage(this.contract.release(payee1), "PaymentSplitter: account is not due payment"); }); it('should throw if non-payee want to claim', async function () { await send.ether(payer1, this.contract.address, amount); - await shouldFail.reverting(this.contract.release(nonpayee1)); + await shouldFail.reverting.withMessage(this.contract.release(nonpayee1), "PaymentSplitter: account has no shares"); }); it('should distribute funds to payees', async function () { diff --git a/test/payment/escrow/ConditionalEscrow.test.js b/test/payment/escrow/ConditionalEscrow.test.js index eeb39e5ff95..40e418e2ff7 100644 --- a/test/payment/escrow/ConditionalEscrow.test.js +++ b/test/payment/escrow/ConditionalEscrow.test.js @@ -26,7 +26,7 @@ contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) { it('reverts on withdrawals', async function () { await this.escrow.deposit(payee, { from: owner, value: amount }); - await shouldFail.reverting(this.escrow.withdraw(payee, { from: owner })); + await shouldFail.reverting.withMessage(this.escrow.withdraw(payee, { from: owner }), "Failure message"); }); }); }); diff --git a/test/payment/escrow/Escrow.behavior.js b/test/payment/escrow/Escrow.behavior.js index 5789fd1ef32..53bad8a2d9f 100644 --- a/test/payment/escrow/Escrow.behavior.js +++ b/test/payment/escrow/Escrow.behavior.js @@ -18,7 +18,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { }); it('only the primary account can deposit', async function () { - await shouldFail.reverting(this.escrow.deposit(payee1, { from: payee2 })); + await shouldFail.reverting.withMessage(this.escrow.deposit(payee1, { from: payee2 }), "Secondary: caller is not the primary account"); }); it('emits a deposited event', async function () { @@ -68,7 +68,7 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { }); it('only the primary account can withdraw', async function () { - await shouldFail.reverting(this.escrow.withdraw(payee1, { from: payee1 })); + await shouldFail.reverting.withMessage(this.escrow.withdraw(payee1, { from: payee1 }), "Secondary: caller is not the primary account"); }); it('emits a withdrawn event', async function () { diff --git a/test/payment/escrow/Escrow.test.js b/test/payment/escrow/Escrow.test.js index b7b9a29c018..33e10b2d852 100644 --- a/test/payment/escrow/Escrow.test.js +++ b/test/payment/escrow/Escrow.test.js @@ -3,7 +3,7 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); const Escrow = artifacts.require('Escrow'); -contract('Escrow', function ([_, primary, ...otherAccounts]) { +contract.only('Escrow', function ([_, primary, ...otherAccounts]) { beforeEach(async function () { this.escrow = await Escrow.new({ from: primary }); }); diff --git a/test/payment/escrow/RefundEscrow.test.js b/test/payment/escrow/RefundEscrow.test.js index 0e9a78f4c98..664995eb1ab 100644 --- a/test/payment/escrow/RefundEscrow.test.js +++ b/test/payment/escrow/RefundEscrow.test.js @@ -3,13 +3,13 @@ const { ZERO_ADDRESS } = constants; const RefundEscrow = artifacts.require('RefundEscrow'); -contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) { +contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) { const amount = ether('54'); const refundees = [refundee1, refundee2]; it('requires a non-null beneficiary', async function () { - await shouldFail.reverting( - RefundEscrow.new(ZERO_ADDRESS, { from: primary }) + await shouldFail.reverting.withMessage( + RefundEscrow.new(ZERO_ADDRESS, { from: primary }), "RefundEscrow: beneficiary is the zero address" ); }); @@ -32,17 +32,17 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee it('does not refund refundees', async function () { await this.escrow.deposit(refundee1, { from: primary, value: amount }); - await shouldFail.reverting(this.escrow.withdraw(refundee1)); + await shouldFail.reverting.withMessage(this.escrow.withdraw(refundee1), "ConditionalEscrow: payee is not allowed to withdraw"); }); it('does not allow beneficiary withdrawal', async function () { await this.escrow.deposit(refundee1, { from: primary, value: amount }); - await shouldFail.reverting(this.escrow.beneficiaryWithdraw()); + await shouldFail.reverting.withMessage(this.escrow.beneficiaryWithdraw(), "RefundEscrow: beneficiary can only withdraw while closed"); }); }); it('only the primary account can enter closed state', async function () { - await shouldFail.reverting(this.escrow.close({ from: beneficiary })); + await shouldFail.reverting.withMessage(this.escrow.close({ from: beneficiary }), "Secondary: caller is not the primary account"); const { logs } = await this.escrow.close({ from: primary }); expectEvent.inLogs(logs, 'RefundsClosed'); @@ -56,11 +56,11 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee }); it('rejects deposits', async function () { - await shouldFail.reverting(this.escrow.deposit(refundee1, { from: primary, value: amount })); + await shouldFail.reverting.withMessage(this.escrow.deposit(refundee1, { from: primary, value: amount }), "RefundEscrow: can only deposit while active"); }); it('does not refund refundees', async function () { - await shouldFail.reverting(this.escrow.withdraw(refundee1)); + await shouldFail.reverting.withMessage(this.escrow.withdraw(refundee1),"ConditionalEscrow: payee is not allowed to withdraw"); }); it('allows beneficiary withdrawal', async function () { @@ -70,16 +70,16 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee }); it('prevents entering the refund state', async function () { - await shouldFail.reverting(this.escrow.enableRefunds({ from: primary })); + await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: primary }),"RefundEscrow: can only enable refunds while active"); }); it('prevents re-entering the closed state', async function () { - await shouldFail.reverting(this.escrow.close({ from: primary })); + await shouldFail.reverting.withMessage(this.escrow.close({ from: primary }),"RefundEscrow: can only close while active"); }); }); it('only the primary account can enter refund state', async function () { - await shouldFail.reverting(this.escrow.enableRefunds({ from: beneficiary })); + await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: beneficiary }),"Secondary: caller is not the primary account"); const { logs } = await this.escrow.enableRefunds({ from: primary }); expectEvent.inLogs(logs, 'RefundsEnabled'); @@ -93,7 +93,7 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee }); it('rejects deposits', async function () { - await shouldFail.reverting(this.escrow.deposit(refundee1, { from: primary, value: amount })); + await shouldFail.reverting.withMessage(this.escrow.deposit(refundee1, { from: primary, value: amount }),"RefundEscrow: can only deposit while active"); }); it('refunds refundees', async function () { @@ -105,15 +105,15 @@ contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee }); it('does not allow beneficiary withdrawal', async function () { - await shouldFail.reverting(this.escrow.beneficiaryWithdraw()); + await shouldFail.reverting.withMessage(this.escrow.beneficiaryWithdraw(),"RefundEscrow: beneficiary can only withdraw while closed"); }); it('prevents entering the closed state', async function () { - await shouldFail.reverting(this.escrow.close({ from: primary })); + await shouldFail.reverting.withMessage(this.escrow.close({ from: primary }),"RefundEscrow: can only close while active"); }); it('prevents re-entering the refund state', async function () { - await shouldFail.reverting(this.escrow.enableRefunds({ from: primary })); + await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: primary }),"RefundEscrow: can only enable refunds while active"); }); }); }); diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index ac82c8dccd6..64556807e02 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -3,7 +3,7 @@ const { ZERO_ADDRESS } = constants; const ERC20Mock = artifacts.require('ERC20Mock'); -contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { +contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const initialSupply = new BN(100); beforeEach(async function () { this.token = await ERC20Mock.new(initialHolder, initialSupply); @@ -37,7 +37,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const amount = initialSupply.addn(1); it('reverts', async function () { - await shouldFail.reverting(this.token.transfer(to, amount, { from: initialHolder })); + await shouldFail.reverting.withMessage(this.token.transfer(to, amount, { from: initialHolder }),"SafeMath: subtraction overflow"); }); }); @@ -68,7 +68,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const to = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting(this.token.transfer(to, initialSupply, { from: initialHolder })); + await shouldFail.reverting.withMessage(this.token.transfer(to, initialSupply, { from: initialHolder }), "ERC20: transfer to the zero address"); }); }); }); @@ -126,7 +126,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const amount = initialSupply.addn(1); it('reverts', async function () { - await shouldFail.reverting(this.token.transferFrom(initialHolder, to, amount, { from: spender })); + await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }), "SafeMath: subtraction overflow"); }); }); }); @@ -140,7 +140,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const amount = initialSupply; it('reverts', async function () { - await shouldFail.reverting(this.token.transferFrom(initialHolder, to, amount, { from: spender })); + await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }), "SafeMath: subtraction overflow"); }); }); @@ -148,7 +148,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const amount = initialSupply.addn(1); it('reverts', async function () { - await shouldFail.reverting(this.token.transferFrom(initialHolder, to, amount, { from: spender })); + await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }), "SafeMath: subtraction overflow"); }); }); }); @@ -163,7 +163,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { }); it('reverts', async function () { - await shouldFail.reverting(this.token.transferFrom(initialHolder, to, amount, { from: spender })); + await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }, "ERC20: transfer to the zero address")); }); }); }); @@ -175,7 +175,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { function shouldDecreaseApproval (amount) { describe('when there was no approved amount before', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.decreaseAllowance(spender, amount, { from: initialHolder })); + await shouldFail.reverting.withMessage(this.token.decreaseAllowance(spender, amount, { from: initialHolder }), "SafeMath: subtraction overflow"); }); }); @@ -208,8 +208,8 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { }); it('reverts when more than the full allowance is removed', async function () { - await shouldFail.reverting( - this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }) + await shouldFail.reverting.withMessage( + this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }, "no idea") ); }); }); @@ -233,7 +233,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const spender = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting(this.token.decreaseAllowance(spender, amount, { from: initialHolder })); + await shouldFail.reverting.withMessage(this.token.decreaseAllowance(spender, amount, { from: initialHolder }, "ERC20: approve to the zero address")); }); }); }); @@ -315,7 +315,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const spender = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting(this.token.increaseAllowance(spender, amount, { from: initialHolder })); + await shouldFail.reverting.withMessage(this.token.increaseAllowance(spender, amount, { from: initialHolder }), "ERC20: approve from the zero address"); }); }); }); @@ -324,7 +324,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const amount = new BN(50); it('rejects a null account', async function () { - await shouldFail.reverting(this.token.mint(ZERO_ADDRESS, amount)); + await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, amount), "ERC20: mint to the zero address"); }); describe('for a non null account', function () { @@ -355,12 +355,12 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { describe('_burn', function () { it('rejects a null account', async function () { - await shouldFail.reverting(this.token.burn(ZERO_ADDRESS, new BN(1))); + await shouldFail.reverting.withMessage(this.token.burn(ZERO_ADDRESS, new BN(1)), "ERC20: burn from the zero address"); }); describe('for a non null account', function () { it('rejects burning more than balance', async function () { - await shouldFail.reverting(this.token.burn(initialHolder, initialSupply.addn(1))); + await shouldFail.reverting.withMessage(this.token.burn(initialHolder, initialSupply.addn(1)), "SafeMath: subtraction overflow"); }); const describeBurn = function (description, amount) { @@ -406,16 +406,16 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { }); it('rejects a null account', async function () { - await shouldFail.reverting(this.token.burnFrom(ZERO_ADDRESS, new BN(1))); + await shouldFail.reverting.withMessage(this.token.burnFrom(ZERO_ADDRESS, new BN(1)), "ERC20: burn from the zero address"); }); describe('for a non null account', function () { it('rejects burning more than allowance', async function () { - await shouldFail.reverting(this.token.burnFrom(initialHolder, allowance.addn(1))); + await shouldFail.reverting.withMessage(this.token.burnFrom(initialHolder, allowance.addn(1)), "SafeMath: subtraction overflow"); }); it('rejects burning more than balance', async function () { - await shouldFail.reverting(this.token.burnFrom(initialHolder, initialSupply.addn(1))); + await shouldFail.reverting.withMessage(this.token.burnFrom(initialHolder, initialSupply.addn(1)), "SafeMath: subtraction overflow"); }); const describeBurnFrom = function (description, amount) { @@ -477,7 +477,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { describe('when the owner is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.approveInternal(ZERO_ADDRESS, recipient, initialSupply)); + await shouldFail.reverting.withMessage(this.token.approveInternal(ZERO_ADDRESS, recipient, initialSupply), "ERC20: approve from the zero address"); }); }); }); @@ -555,7 +555,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { describe('when the spender is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting(approve.call(this, owner, ZERO_ADDRESS, supply)); + await shouldFail.reverting.withMessage(approve.call(this, owner, ZERO_ADDRESS, supply), "ERC20: approve to the zero address"); }); }); } diff --git a/test/token/ERC20/ERC20Burnable.test.js b/test/token/ERC20/ERC20Burnable.test.js index 62499183868..24b0f83d050 100644 --- a/test/token/ERC20/ERC20Burnable.test.js +++ b/test/token/ERC20/ERC20Burnable.test.js @@ -3,7 +3,7 @@ const { BN } = require('openzeppelin-test-helpers'); const { shouldBehaveLikeERC20Burnable } = require('./behaviors/ERC20Burnable.behavior'); const ERC20BurnableMock = artifacts.require('ERC20BurnableMock'); -contract('ERC20Burnable', function ([_, owner, ...otherAccounts]) { +contract.only('ERC20Burnable', function ([_, owner, ...otherAccounts]) { const initialBalance = new BN(1000); beforeEach(async function () { diff --git a/test/token/ERC20/ERC20Capped.test.js b/test/token/ERC20/ERC20Capped.test.js index 9986be6e4e3..214783c312a 100644 --- a/test/token/ERC20/ERC20Capped.test.js +++ b/test/token/ERC20/ERC20Capped.test.js @@ -4,12 +4,12 @@ const { shouldBehaveLikeERC20Capped } = require('./behaviors/ERC20Capped.behavio const ERC20Capped = artifacts.require('ERC20Capped'); -contract('ERC20Capped', function ([_, minter, ...otherAccounts]) { +contract.only('ERC20Capped', function ([_, minter, ...otherAccounts]) { const cap = ether('1000'); it('requires a non-zero cap', async function () { - await shouldFail.reverting( - ERC20Capped.new(new BN(0), { from: minter }) + await shouldFail.reverting.withMessage( + ERC20Capped.new(new BN(0), { from: minter }), "ERC20Capped: cap is 0" ); }); diff --git a/test/token/ERC20/ERC20Detailed.test.js b/test/token/ERC20/ERC20Detailed.test.js index 1978350b266..02655e70fc1 100644 --- a/test/token/ERC20/ERC20Detailed.test.js +++ b/test/token/ERC20/ERC20Detailed.test.js @@ -2,7 +2,7 @@ const { BN } = require('openzeppelin-test-helpers'); const ERC20DetailedMock = artifacts.require('ERC20DetailedMock'); -contract('ERC20Detailed', function () { +contract.only('ERC20Detailed', function () { const _name = 'My Detailed ERC20'; const _symbol = 'MDT'; const _decimals = new BN(18); diff --git a/test/token/ERC20/ERC20Mintable.test.js b/test/token/ERC20/ERC20Mintable.test.js index 659276ddd23..8168bd90cfc 100644 --- a/test/token/ERC20/ERC20Mintable.test.js +++ b/test/token/ERC20/ERC20Mintable.test.js @@ -2,7 +2,7 @@ const { shouldBehaveLikeERC20Mintable } = require('./behaviors/ERC20Mintable.beh const ERC20MintableMock = artifacts.require('ERC20MintableMock'); const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior'); -contract('ERC20Mintable', function ([_, minter, otherMinter, ...otherAccounts]) { +contract.only('ERC20Mintable', function ([_, minter, otherMinter, ...otherAccounts]) { beforeEach(async function () { this.token = await ERC20MintableMock.new({ from: minter }); }); diff --git a/test/token/ERC20/ERC20Pausable.test.js b/test/token/ERC20/ERC20Pausable.test.js index cee627ab301..707cbe1941b 100644 --- a/test/token/ERC20/ERC20Pausable.test.js +++ b/test/token/ERC20/ERC20Pausable.test.js @@ -3,7 +3,7 @@ const { BN, expectEvent, shouldFail } = require('openzeppelin-test-helpers'); const ERC20PausableMock = artifacts.require('ERC20PausableMock'); const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior'); -contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherAccount, ...otherAccounts]) { +contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherAccount, ...otherAccounts]) { const initialSupply = new BN(100); beforeEach(async function () { @@ -42,7 +42,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA }); it('reverts', async function () { - await shouldFail.reverting(this.token.pause({ from })); + await shouldFail.reverting.withMessage(this.token.pause({ from }), "Pausable: paused"); }); }); }); @@ -51,7 +51,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA const from = anotherAccount; it('reverts', async function () { - await shouldFail.reverting(this.token.pause({ from })); + await shouldFail.reverting.withMessage(this.token.pause({ from }), "PauserRole: caller does not have the Pauser role"); }); }); }); @@ -79,7 +79,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA describe('when the token is unpaused', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.unpause({ from })); + await shouldFail.reverting.withMessage(this.token.unpause({ from }), "Pausable: not paused"); }); }); }); @@ -88,7 +88,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA const from = anotherAccount; it('reverts', async function () { - await shouldFail.reverting(this.token.unpause({ from })); + await shouldFail.reverting.withMessage(this.token.unpause({ from }), "PauserRole: caller does not have the Pauser role"); }); }); }); @@ -134,7 +134,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('reverts when trying to transfer when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting(this.token.transfer(recipient, initialSupply, { from: pauser })); + await shouldFail.reverting.withMessage(this.token.transfer(recipient, initialSupply, { from: pauser }), "Pausable: paused"); }); }); @@ -159,7 +159,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('reverts when trying to approve when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting(this.token.approve(anotherAccount, allowance, { from: pauser })); + await shouldFail.reverting.withMessage(this.token.approve(anotherAccount, allowance, { from: pauser }), "Pausable: paused"); }); }); @@ -190,7 +190,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('reverts when trying to transfer from when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting(this.token.transferFrom(pauser, recipient, allowance, { from: anotherAccount })); + await shouldFail.reverting.withMessage(this.token.transferFrom(pauser, recipient, allowance, { from: anotherAccount }), "Pausable: paused"); }); }); @@ -220,7 +220,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('reverts when trying to transfer when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting(this.token.decreaseAllowance(anotherAccount, decrement, { from: pauser })); + await shouldFail.reverting.withMessage(this.token.decreaseAllowance(anotherAccount, decrement, { from: pauser }), "Pausable: paused"); }); }); @@ -250,7 +250,7 @@ contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherA it('reverts when trying to increase approval when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting(this.token.increaseAllowance(anotherAccount, increment, { from: pauser })); + await shouldFail.reverting.withMessage(this.token.increaseAllowance(anotherAccount, increment, { from: pauser }), "Pausable: paused"); }); }); }); diff --git a/test/token/ERC20/SafeERC20.test.js b/test/token/ERC20/SafeERC20.test.js index fee236801bd..e514808f7fa 100644 --- a/test/token/ERC20/SafeERC20.test.js +++ b/test/token/ERC20/SafeERC20.test.js @@ -41,23 +41,23 @@ contract('SafeERC20', function ([_, hasNoCode]) { function shouldRevertOnAllCalls () { it('reverts on transfer', async function () { - await shouldFail.reverting(this.wrapper.transfer()); + await shouldFail.reverting.withMessage(this.wrapper.transfer()); }); it('reverts on transferFrom', async function () { - await shouldFail.reverting(this.wrapper.transferFrom()); + await shouldFail.reverting.withMessage(this.wrapper.transferFrom()); }); it('reverts on approve', async function () { - await shouldFail.reverting(this.wrapper.approve(0)); + await shouldFail.reverting.withMessage(this.wrapper.approve(0)); }); it('reverts on increaseAllowance', async function () { - await shouldFail.reverting(this.wrapper.increaseAllowance(0)); + await shouldFail.reverting.withMessage(this.wrapper.increaseAllowance(0)); }); it('reverts on decreaseAllowance', async function () { - await shouldFail.reverting(this.wrapper.decreaseAllowance(0)); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(0)); }); } @@ -89,7 +89,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance', async function () { - await shouldFail.reverting(this.wrapper.decreaseAllowance(10)); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(10)); }); }); @@ -99,7 +99,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when approving a non-zero allowance', async function () { - await shouldFail.reverting(this.wrapper.approve(20)); + await shouldFail.reverting.withMessage(this.wrapper.approve(20)); }); it('doesn\'t revert when approving a zero allowance', async function () { @@ -115,7 +115,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance to a negative value', async function () { - await shouldFail.reverting(this.wrapper.decreaseAllowance(200)); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(200)); }); }); }); diff --git a/test/token/ERC20/TokenTimelock.test.js b/test/token/ERC20/TokenTimelock.test.js index eee78f78752..e88e2545536 100644 --- a/test/token/ERC20/TokenTimelock.test.js +++ b/test/token/ERC20/TokenTimelock.test.js @@ -13,7 +13,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) { it('rejects a release time in the past', async function () { const pastReleaseTime = (await time.latest()).sub(time.duration.years(1)); - await shouldFail.reverting( + await shouldFail.reverting.withMessage( TokenTimelock.new(this.token.address, beneficiary, pastReleaseTime) ); }); @@ -32,12 +32,12 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) { }); it('cannot be released before time limit', async function () { - await shouldFail.reverting(this.timelock.release()); + await shouldFail.reverting.withMessage(this.timelock.release()); }); it('cannot be released just before time limit', async function () { await time.increaseTo(this.releaseTime.sub(time.duration.seconds(3))); - await shouldFail.reverting(this.timelock.release()); + await shouldFail.reverting.withMessage(this.timelock.release()); }); it('can be released just after limit', async function () { @@ -55,7 +55,7 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) { it('cannot be released twice', async function () { await time.increaseTo(this.releaseTime.add(time.duration.years(1))); await this.timelock.release(); - await shouldFail.reverting(this.timelock.release()); + await shouldFail.reverting.withMessage(this.timelock.release()); (await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount); }); }); diff --git a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js index 1c60d81edee..8afd52359e3 100644 --- a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js @@ -35,7 +35,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { const amount = initialBalance.addn(1); it('reverts', async function () { - await shouldFail.reverting(this.token.burn(amount, { from: owner })); + await shouldFail.reverting.withMessage(this.token.burn(amount, { from: owner }), "SafeMath: subtraction overflow"); }); }); }); @@ -82,7 +82,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { it('reverts', async function () { await this.token.approve(burner, amount, { from: owner }); - await shouldFail.reverting(this.token.burnFrom(owner, amount, { from: burner })); + await shouldFail.reverting.withMessage(this.token.burnFrom(owner, amount, { from: burner }), "SafeMath: subtraction overflow"); }); }); @@ -91,7 +91,7 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { it('reverts', async function () { await this.token.approve(burner, allowance, { from: owner }); - await shouldFail.reverting(this.token.burnFrom(owner, allowance.addn(1), { from: burner })); + await shouldFail.reverting.withMessage(this.token.burnFrom(owner, allowance.addn(1), { from: burner }), "SafeMath: subtraction overflow"); }); }); }); diff --git a/test/token/ERC20/behaviors/ERC20Capped.behavior.js b/test/token/ERC20/behaviors/ERC20Capped.behavior.js index bf35e27ba9c..e3efff11c64 100644 --- a/test/token/ERC20/behaviors/ERC20Capped.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Capped.behavior.js @@ -15,12 +15,12 @@ function shouldBehaveLikeERC20Capped (minter, [other], cap) { it('should fail to mint if the amount exceeds the cap', async function () { await this.token.mint(other, cap.subn(1), { from }); - await shouldFail.reverting(this.token.mint(other, 2, { from })); + await shouldFail.reverting.withMessage(this.token.mint(other, 2, { from })); }); it('should fail to mint after cap is reached', async function () { await this.token.mint(other, cap, { from }); - await shouldFail.reverting(this.token.mint(other, 1, { from })); + await shouldFail.reverting.withMessage(this.token.mint(other, 1, { from })); }); }); } diff --git a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js index 994e636ff63..f3f470c4d83 100644 --- a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js @@ -40,7 +40,7 @@ function shouldBehaveLikeERC20Mintable (minter, [other]) { const from = other; it('reverts', async function () { - await shouldFail.reverting(this.token.mint(other, amount, { from })); + await shouldFail.reverting.withMessage(this.token.mint(other, amount, { from }), "MinterRole: caller does not have the Minter role"); }); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 1cf68c47812..29421947409 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -36,7 +36,7 @@ function shouldBehaveLikeERC721 ( context('when querying the zero address', function () { it('throws', async function () { - await shouldFail.reverting(this.token.balanceOf(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage(this.token.balanceOf(ZERO_ADDRESS)); }); }); }); @@ -54,7 +54,7 @@ function shouldBehaveLikeERC721 ( const tokenId = unknownTokenId; it('reverts', async function () { - await shouldFail.reverting(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); }); }); }); @@ -178,28 +178,28 @@ function shouldBehaveLikeERC721 ( context('when the address of the previous owner is incorrect', function () { it('reverts', async function () { - await shouldFail.reverting(transferFunction.call(this, other, other, tokenId, { from: owner }) + await shouldFail.reverting.withMessage(transferFunction.call(this, other, other, tokenId, { from: owner }) ); }); }); context('when the sender is not authorized for the token id', function () { it('reverts', async function () { - await shouldFail.reverting(transferFunction.call(this, owner, other, tokenId, { from: other }) + await shouldFail.reverting.withMessage(transferFunction.call(this, owner, other, tokenId, { from: other }) ); }); }); context('when the given token ID does not exist', function () { it('reverts', async function () { - await shouldFail.reverting(transferFunction.call(this, owner, other, unknownTokenId, { from: owner }) + await shouldFail.reverting.withMessage(transferFunction.call(this, owner, other, unknownTokenId, { from: owner }) ); }); }); context('when the address to transfer the token to is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( transferFunction.call(this, owner, ZERO_ADDRESS, tokenId, { from: owner }) ); }); @@ -258,7 +258,7 @@ function shouldBehaveLikeERC721 ( describe('with an invalid token id', function () { it('reverts', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( transferFun.call( this, owner, @@ -283,7 +283,7 @@ function shouldBehaveLikeERC721 ( describe('to a receiver contract returning unexpected value', function () { it('reverts', async function () { const invalidReceiver = await ERC721ReceiverMock.new('0x42', false); - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }) ); }); @@ -292,7 +292,7 @@ function shouldBehaveLikeERC721 ( describe('to a receiver contract that throws', function () { it('reverts', async function () { const invalidReceiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, true); - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }) ); }); @@ -301,7 +301,7 @@ function shouldBehaveLikeERC721 ( describe('to a contract that does not implement the required function', function () { it('reverts', async function () { const invalidReceiver = this.token; - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }) ); }); @@ -390,7 +390,7 @@ function shouldBehaveLikeERC721 ( context('when the address that receives the approval is the owner', function () { it('reverts', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.token.approve(owner, tokenId, { from: owner }) ); }); @@ -398,14 +398,14 @@ function shouldBehaveLikeERC721 ( context('when the sender does not own the given token ID', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.approve(approved, tokenId, { from: other })); + await shouldFail.reverting.withMessage(this.token.approve(approved, tokenId, { from: other })); }); }); context('when the sender is approved for the given token ID', function () { it('reverts', async function () { await this.token.approve(approved, tokenId, { from: owner }); - await shouldFail.reverting(this.token.approve(anotherApproved, tokenId, { from: approved })); + await shouldFail.reverting.withMessage(this.token.approve(anotherApproved, tokenId, { from: approved })); }); }); @@ -421,7 +421,7 @@ function shouldBehaveLikeERC721 ( context('when the given token ID does not exist', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.approve(approved, unknownTokenId, { from: operator })); + await shouldFail.reverting.withMessage(this.token.approve(approved, unknownTokenId, { from: operator })); }); }); }); @@ -499,7 +499,7 @@ function shouldBehaveLikeERC721 ( context('when the operator is the owner', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.setApprovalForAll(owner, true, { from: owner })); + await shouldFail.reverting.withMessage(this.token.setApprovalForAll(owner, true, { from: owner })); }); }); }); diff --git a/test/token/ERC721/ERC721.test.js b/test/token/ERC721/ERC721.test.js index 52cc80ceadf..cd559e07393 100644 --- a/test/token/ERC721/ERC721.test.js +++ b/test/token/ERC721/ERC721.test.js @@ -16,7 +16,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { describe('_mint(address, uint256)', function () { it('reverts with a null destination address', async function () { - await shouldFail.reverting(this.token.mint(ZERO_ADDRESS, tokenId)); + await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, tokenId)); }); context('with minted token', async function () { @@ -34,14 +34,14 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('reverts when adding a token id that already exists', async function () { - await shouldFail.reverting(this.token.mint(tokenOwner, tokenId)); + await shouldFail.reverting.withMessage(this.token.mint(tokenOwner, tokenId)); }); }); }); describe('_burn(address, uint256)', function () { it('reverts when burning a non-existent token id', async function () { - await shouldFail.reverting(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId)); }); context('with minted token', function () { @@ -50,7 +50,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('reverts when the account is not the owner', async function () { - await shouldFail.reverting(this.token.methods['burn(address,uint256)'](other, tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](other, tokenId)); }); context('with burnt token', function () { @@ -64,11 +64,11 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); - await shouldFail.reverting(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); }); it('reverts when burning a token id that has been deleted', async function () { - await shouldFail.reverting(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId)); }); }); }); @@ -76,7 +76,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { describe('_burn(uint256)', function () { it('reverts when burning a non-existent token id', async function () { - await shouldFail.reverting(this.token.methods['burn(uint256)'](tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId)); }); context('with minted token', function () { @@ -95,11 +95,11 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); - await shouldFail.reverting(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); }); it('reverts when burning a token id that has been deleted', async function () { - await shouldFail.reverting(this.token.methods['burn(uint256)'](tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId)); }); }); }); diff --git a/test/token/ERC721/ERC721Full.test.js b/test/token/ERC721/ERC721Full.test.js index 975d1c0a56a..d5e1087c59f 100644 --- a/test/token/ERC721/ERC721Full.test.js +++ b/test/token/ERC721/ERC721Full.test.js @@ -64,7 +64,7 @@ contract('ERC721Full', function ([ it('burns all tokens', async function () { await this.token.burn(secondTokenId, { from: owner }); (await this.token.totalSupply()).should.be.bignumber.equal('0'); - await shouldFail.reverting(this.token.tokenByIndex(0)); + await shouldFail.reverting.withMessage(this.token.tokenByIndex(0)); }); }); @@ -85,7 +85,7 @@ contract('ERC721Full', function ([ }); it('reverts when setting metadata for non existent token id', async function () { - await shouldFail.reverting(this.token.setTokenURI(nonExistentTokenId, sampleUri)); + await shouldFail.reverting.withMessage(this.token.setTokenURI(nonExistentTokenId, sampleUri)); }); it('can burn token with metadata', async function () { @@ -99,7 +99,7 @@ contract('ERC721Full', function ([ }); it('reverts when querying metadata for non existent token id', async function () { - await shouldFail.reverting(this.token.tokenURI(nonExistentTokenId)); + await shouldFail.reverting.withMessage(this.token.tokenURI(nonExistentTokenId)); }); }); @@ -127,13 +127,13 @@ contract('ERC721Full', function ([ describe('when the index is greater than or equal to the total tokens owned by the given address', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.tokenOfOwnerByIndex(owner, 2)); + await shouldFail.reverting.withMessage(this.token.tokenOfOwnerByIndex(owner, 2)); }); }); describe('when the given address does not own any token', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.tokenOfOwnerByIndex(another, 0)); + await shouldFail.reverting.withMessage(this.token.tokenOfOwnerByIndex(another, 0)); }); }); @@ -153,7 +153,7 @@ contract('ERC721Full', function ([ it('returns empty collection for original owner', async function () { (await this.token.balanceOf(owner)).should.be.bignumber.equal('0'); - await shouldFail.reverting(this.token.tokenOfOwnerByIndex(owner, 0)); + await shouldFail.reverting.withMessage(this.token.tokenOfOwnerByIndex(owner, 0)); }); }); }); @@ -167,7 +167,7 @@ contract('ERC721Full', function ([ }); it('should revert if index is greater than supply', async function () { - await shouldFail.reverting(this.token.tokenByIndex(2)); + await shouldFail.reverting.withMessage(this.token.tokenByIndex(2)); }); [firstTokenId, secondTokenId].forEach(function (tokenId) { diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index d629bed9ce9..7edb29aace2 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -46,13 +46,13 @@ function shouldBehaveLikeMintAndBurnERC721 ( describe('when the given owner address is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter })); + await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter })); }); }); describe('when the given token ID was already tracked by this contract', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.mint(owner, firstTokenId, { from: minter })); + await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter })); }); }); }); @@ -76,7 +76,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( }); it('burns the given token ID and adjusts the balance of the owner', async function () { - await shouldFail.reverting(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); (await this.token.balanceOf(owner)).should.be.bignumber.equal('1'); }); @@ -98,14 +98,14 @@ function shouldBehaveLikeMintAndBurnERC721 ( context('getApproved', function () { it('reverts', async function () { - await shouldFail.reverting(this.token.getApproved(tokenId)); + await shouldFail.reverting.withMessage(this.token.getApproved(tokenId)); }); }); }); describe('when the given token ID was not tracked by this contract', function () { it('reverts', async function () { - await shouldFail.reverting( + await shouldFail.reverting.withMessage( this.token.burn(unknownTokenId, { from: creator }) ); }); diff --git a/test/token/ERC721/ERC721PausedToken.behavior.js b/test/token/ERC721/ERC721PausedToken.behavior.js index a116c8394ca..02429506428 100644 --- a/test/token/ERC721/ERC721PausedToken.behavior.js +++ b/test/token/ERC721/ERC721PausedToken.behavior.js @@ -12,23 +12,23 @@ function shouldBehaveLikeERC721PausedToken (owner, [recipient, operator]) { }); it('reverts when trying to approve', async function () { - await shouldFail.reverting(this.token.approve(recipient, firstTokenId, { from: owner })); + await shouldFail.reverting.withMessage(this.token.approve(recipient, firstTokenId, { from: owner })); }); it('reverts when trying to setApprovalForAll', async function () { - await shouldFail.reverting(this.token.setApprovalForAll(operator, true, { from: owner })); + await shouldFail.reverting.withMessage(this.token.setApprovalForAll(operator, true, { from: owner })); }); it('reverts when trying to transferFrom', async function () { - await shouldFail.reverting(this.token.transferFrom(owner, recipient, firstTokenId, { from: owner })); + await shouldFail.reverting.withMessage(this.token.transferFrom(owner, recipient, firstTokenId, { from: owner })); }); it('reverts when trying to safeTransferFrom', async function () { - await shouldFail.reverting(this.token.safeTransferFrom(owner, recipient, firstTokenId, { from: owner })); + await shouldFail.reverting.withMessage(this.token.safeTransferFrom(owner, recipient, firstTokenId, { from: owner })); }); it('reverts when trying to safeTransferFrom with data', async function () { - await shouldFail.reverting(this.token.methods['safeTransferFrom(address,address,uint256,bytes)']( + await shouldFail.reverting.withMessage(this.token.methods['safeTransferFrom(address,address,uint256,bytes)']( owner, recipient, firstTokenId, mockData, { from: owner }) ); }); diff --git a/test/utils/ReentrancyGuard.test.js b/test/utils/ReentrancyGuard.test.js index 9870665601b..66632d37f32 100644 --- a/test/utils/ReentrancyGuard.test.js +++ b/test/utils/ReentrancyGuard.test.js @@ -3,7 +3,7 @@ const { shouldFail } = require('openzeppelin-test-helpers'); const ReentrancyMock = artifacts.require('ReentrancyMock'); const ReentrancyAttack = artifacts.require('ReentrancyAttack'); -contract('ReentrancyGuard', function () { +contract.only('ReentrancyGuard', function () { beforeEach(async function () { this.reentrancyMock = await ReentrancyMock.new(); (await this.reentrancyMock.counter()).should.be.bignumber.equal('0'); @@ -11,7 +11,7 @@ contract('ReentrancyGuard', function () { it('should not allow remote callback', async function () { const attacker = await ReentrancyAttack.new(); - await shouldFail.reverting(this.reentrancyMock.countAndCall(attacker.address)); + await shouldFail.reverting.withMessage(this.reentrancyMock.countAndCall(attacker.address), "ReentrancyGuard: reentrant call"); }); // The following are more side-effects than intended behavior: @@ -19,10 +19,10 @@ contract('ReentrancyGuard', function () { // in the side-effects. it('should not allow local recursion', async function () { - await shouldFail.reverting(this.reentrancyMock.countLocalRecursive(10)); + await shouldFail.reverting.withMessage(this.reentrancyMock.countLocalRecursive(10), "ReentrancyGuard: reentrant call"); }); it('should not allow indirect local recursion', async function () { - await shouldFail.reverting(this.reentrancyMock.countThisRecursive(10)); + await shouldFail.reverting.withMessage(this.reentrancyMock.countThisRecursive(10), "ReentrancyMock: failed call"); }); }); From 797bbebe0b213ba25eec7b1937f988cac1fbaed6 Mon Sep 17 00:00:00 2001 From: balajipachai Date: Fri, 19 Apr 2019 18:05:47 +0530 Subject: [PATCH 13/20] WIP: Added changes to ERC20 and ERC721 --- test/token/ERC20/ERC20.test.js | 2 +- test/token/ERC721/ERC721.test.js | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 64556807e02..9cc6641459e 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -315,7 +315,7 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const spender = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.increaseAllowance(spender, amount, { from: initialHolder }), "ERC20: approve from the zero address"); + await shouldFail.reverting.withMessage(this.token.increaseAllowance(spender, amount, { from: initialHolder }), "ERC20: approve to the zero address"); }); }); }); diff --git a/test/token/ERC721/ERC721.test.js b/test/token/ERC721/ERC721.test.js index cd559e07393..50945deddb0 100644 --- a/test/token/ERC721/ERC721.test.js +++ b/test/token/ERC721/ERC721.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const { shouldBehaveLikeERC721 } = require('./ERC721.behavior'); const ERC721Mock = artifacts.require('ERC721Mock.sol'); -contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { +contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { beforeEach(async function () { this.token = await ERC721Mock.new({ from: creator }); }); @@ -16,7 +16,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { describe('_mint(address, uint256)', function () { it('reverts with a null destination address', async function () { - await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, tokenId)); + await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, tokenId), "ERC721: mint to the zero address"); }); context('with minted token', async function () { @@ -34,14 +34,14 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('reverts when adding a token id that already exists', async function () { - await shouldFail.reverting.withMessage(this.token.mint(tokenOwner, tokenId)); + await shouldFail.reverting.withMessage(this.token.mint(tokenOwner, tokenId), "ERC721: token already minted"); }); }); }); describe('_burn(address, uint256)', function () { it('reverts when burning a non-existent token id', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), "ERC721: owner query of nonexistent token"); }); context('with minted token', function () { @@ -50,7 +50,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { }); it('reverts when the account is not the owner', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](other, tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](other, tokenId), "ERC721: burn of unowned token"); }); context('with burnt token', function () { @@ -64,11 +64,11 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); - await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId), "ERC721: owner query of nonexistent token"); }); it('reverts when burning a token id that has been deleted', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), "ERC721: owner query of nonexistent token"); }); }); }); @@ -76,7 +76,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { describe('_burn(uint256)', function () { it('reverts when burning a non-existent token id', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId), "ERC721: owner query of nonexistent token"); }); context('with minted token', function () { @@ -95,11 +95,11 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); - await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId), "ERC721: owner query of nonexistent token"); }); it('reverts when burning a token id that has been deleted', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId)); + await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId), "ERC721: owner query of nonexistent token"); }); }); }); From c804239ba3d8d93d89209dc8328d0ef061ed826e Mon Sep 17 00:00:00 2001 From: balajipachai Date: Sat, 20 Apr 2019 11:37:05 +0530 Subject: [PATCH 14/20] Fixes linting errors in *.tes.js files --- package-lock.json | 12 ++-- package.json | 2 +- test/access/Roles.test.js | 10 +-- .../access/roles/PublicRole.behavior.js | 28 ++++++-- test/crowdsale/AllowanceCrowdsale.test.js | 6 +- test/crowdsale/CappedCrowdsale.test.js | 10 +-- test/crowdsale/Crowdsale.test.js | 15 ++-- test/crowdsale/FinalizableCrowdsale.test.js | 10 ++- .../IncreasingPriceCrowdsale.test.js | 12 ++-- .../IndividuallyCappedCrowdsale.test.js | 26 +++++-- test/crowdsale/MintedCrowdsale.test.js | 10 ++- test/crowdsale/PausableCrowdsale.test.js | 10 ++- test/crowdsale/PostDeliveryCrowdsale.test.js | 10 ++- test/crowdsale/RefundableCrowdsale.test.js | 17 +++-- .../RefundablePostDeliveryCrowdsale.test.js | 18 +++-- test/crowdsale/TimedCrowdsale.test.js | 34 +++++---- test/crowdsale/WhitelistCrowdsale.test.js | 10 ++- test/cryptography/ECDSA.test.js | 4 +- test/drafts/Counters.test.js | 4 +- test/drafts/ERC1820Implementer.test.js | 4 +- test/drafts/ERC20Migrator.test.js | 30 +++++--- test/drafts/ERC20Snapshot.test.js | 10 +-- test/drafts/SignatureBouncer.test.js | 32 +++++---- test/drafts/SignedSafeMath.test.js | 12 ++-- test/drafts/TokenVesting.test.js | 25 ++++--- test/examples/SampleCrowdsale.test.js | 18 +++-- test/introspection/ERC165.test.js | 4 +- test/lifecycle/Pausable.test.js | 24 ++++--- test/math/SafeMath.test.js | 10 +-- test/ownership/Secondary.test.js | 18 +++-- test/payment/PaymentSplitter.test.js | 32 ++++++--- test/payment/escrow/ConditionalEscrow.test.js | 2 +- test/payment/escrow/Escrow.behavior.js | 8 ++- test/payment/escrow/Escrow.test.js | 2 +- test/payment/escrow/RefundEscrow.test.js | 52 ++++++++++---- test/token/ERC20/ERC20.test.js | 71 ++++++++++++++----- test/token/ERC20/ERC20Burnable.test.js | 2 +- test/token/ERC20/ERC20Capped.test.js | 4 +- test/token/ERC20/ERC20Detailed.test.js | 2 +- test/token/ERC20/ERC20Mintable.test.js | 2 +- test/token/ERC20/ERC20Pausable.test.js | 34 ++++++--- .../ERC20/behaviors/ERC20Burnable.behavior.js | 12 +++- .../ERC20/behaviors/ERC20Mintable.behavior.js | 4 +- test/token/ERC721/ERC721.behavior.js | 48 +++++++++---- test/token/ERC721/ERC721.test.js | 37 +++++++--- test/token/ERC721/ERC721Full.test.js | 28 ++++++-- test/token/ERC721/ERC721MintBurn.behavior.js | 18 +++-- .../ERC721/ERC721PausedToken.behavior.js | 22 ++++-- test/utils/ReentrancyGuard.test.js | 13 ++-- 49 files changed, 562 insertions(+), 266 deletions(-) diff --git a/package-lock.json b/package-lock.json index d8f89f972ea..58e7b97cb8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6601,9 +6601,9 @@ } }, "openzeppelin-test-helpers": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/openzeppelin-test-helpers/-/openzeppelin-test-helpers-0.3.0.tgz", - "integrity": "sha512-+UC7/HHCzaBLbVy1Y/IlNFI3hqbiw5PuBGoQXbmduzh5QNrbiNbQOT1WlVTjoSDUCIDnHpFjnY5hJKF0kzitUg==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/openzeppelin-test-helpers/-/openzeppelin-test-helpers-0.3.2.tgz", + "integrity": "sha512-PFTIzyYswBt5IiZu/qayIjnS1HJ+Mr0ekVzLfube/qcUGvoA4Ru5SJdit2FYKljaPdiyvLD1jYJJecA50A2RtA==", "dev": true, "requires": { "ansi-colors": "^3.2.3", @@ -6614,9 +6614,9 @@ }, "dependencies": { "semver": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", + "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==", "dev": true } } diff --git a/package.json b/package.json index a9d0071a3ef..b44f0ace4a2 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "ethereumjs-util": "^6.0.0", "ganache-cli": "^6.4.1", "ganache-cli-coverage": "github:Agusx1211/ganache-cli#c462b3fc48fe9b16756f7799885c0741114d9ed3", - "openzeppelin-test-helpers": "^0.3.0", + "openzeppelin-test-helpers": "^0.3.2", "solhint": "^1.5.0", "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477", "truffle": "^5.0.0" diff --git a/test/access/Roles.test.js b/test/access/Roles.test.js index 8b31f500089..056a2b9a44d 100644 --- a/test/access/Roles.test.js +++ b/test/access/Roles.test.js @@ -9,7 +9,7 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { }); it('reverts when querying roles for the zero account', async function () { - await shouldFail.reverting.withMessage(this.roles.has(ZERO_ADDRESS), "Roles: account is the zero address"); + await shouldFail.reverting.withMessage(this.roles.has(ZERO_ADDRESS), 'Roles: account is the zero address'); }); context('initially', function () { @@ -28,11 +28,11 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { it('reverts when adding roles to an already assigned account', async function () { await this.roles.add(authorized); - await shouldFail.reverting.withMessage(this.roles.add(authorized), "Roles: account already has role"); + await shouldFail.reverting.withMessage(this.roles.add(authorized), 'Roles: account already has role'); }); it('reverts when adding roles to the zero account', async function () { - await shouldFail.reverting.withMessage(this.roles.add(ZERO_ADDRESS), "Roles: account is the zero address"); + await shouldFail.reverting.withMessage(this.roles.add(ZERO_ADDRESS), 'Roles: account is the zero address'); }); }); }); @@ -51,11 +51,11 @@ contract('Roles', function ([_, authorized, otherAuthorized, other]) { }); it('reverts when removing unassigned roles', async function () { - await shouldFail.reverting.withMessage(this.roles.remove(other), "Roles: account does not have role"); + await shouldFail.reverting.withMessage(this.roles.remove(other), 'Roles: account does not have role'); }); it('reverts when removing roles from the zero account', async function () { - await shouldFail.reverting.withMessage(this.roles.remove(ZERO_ADDRESS), "Roles: account is the zero address"); + await shouldFail.reverting.withMessage(this.roles.remove(ZERO_ADDRESS), 'Roles: account is the zero address'); }); }); }); diff --git a/test/behaviors/access/roles/PublicRole.behavior.js b/test/behaviors/access/roles/PublicRole.behavior.js index 885673a3048..286ef2c3c07 100644 --- a/test/behaviors/access/roles/PublicRole.behavior.js +++ b/test/behaviors/access/roles/PublicRole.behavior.js @@ -39,7 +39,9 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen } it('reverts when querying roles for the null account', async function () { - await shouldFail.reverting.withMessage(this.contract[`is${rolename}`](ZERO_ADDRESS), "Roles: account is the zero address"); + await shouldFail.reverting.withMessage(this.contract[`is${rolename}`](ZERO_ADDRESS), + 'Roles: account is the zero address' + ); }); describe('access control', function () { @@ -56,7 +58,9 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen //, "CapperRole: caller does not have the Capper role" it('reverts', async function () { - await shouldFail.reverting.withMessage(this.contract[`only${rolename}Mock`]({ from }), `${rolename}Role: caller does not have the ${rolename} role`); + await shouldFail.reverting.withMessage(this.contract[`only${rolename}Mock`]({ from }), + `${rolename}Role: caller does not have the ${rolename} role` + ); }); }); }); @@ -76,11 +80,15 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen }); it('reverts when adding role to an already assigned account', async function () { - await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](authorized, { from }), "Roles: account already has role"); + await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](authorized, { from }), + 'Roles: account already has role' + ); }); it('reverts when adding role to the null account', async function () { - await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](ZERO_ADDRESS, { from }), "Roles: account is the zero address"); + await shouldFail.reverting.withMessage(this.contract[`add${rolename}`](ZERO_ADDRESS, { from }), + 'Roles: account is the zero address' + ); }); }); }); @@ -102,11 +110,15 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen }); it('reverts when removing from an unassigned account', async function () { - await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](other, { from }), "Roles: account does not have role"); + await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](other, { from }), + 'Roles: account does not have role' + ); }); it('reverts when removing role from the null account', async function () { - await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](ZERO_ADDRESS, { from }), "Roles: account is the zero address"); + await shouldFail.reverting.withMessage(this.contract[`remove${rolename}`](ZERO_ADDRESS, { from }), + 'Roles: account is the zero address' + ); }); }); }); @@ -123,7 +135,9 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen }); it('reverts when renouncing unassigned role', async function () { - await shouldFail.reverting.withMessage(this.contract[`renounce${rolename}`]({ from: other }), "Roles: account does not have role"); + await shouldFail.reverting.withMessage(this.contract[`renounce${rolename}`]({ from: other }), + 'Roles: account does not have role' + ); }); }); }); diff --git a/test/crowdsale/AllowanceCrowdsale.test.js b/test/crowdsale/AllowanceCrowdsale.test.js index df4dcf5fbbc..0a1d40c5baf 100644 --- a/test/crowdsale/AllowanceCrowdsale.test.js +++ b/test/crowdsale/AllowanceCrowdsale.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) { +contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) { const rate = new BN('1'); const value = ether('0.42'); const expectedTokenAmount = rate.mul(value); @@ -75,7 +75,9 @@ contract.only('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, t describe('when token wallet is the zero address', function () { it('creation reverts', async function () { this.token = await SimpleToken.new({ from: tokenWallet }); - await shouldFail.reverting.withMessage(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS), "AllowanceCrowdsale: token wallet is the zero address"); + await shouldFail.reverting.withMessage(AllowanceCrowdsaleImpl.new(rate, wallet, this.token.address, ZERO_ADDRESS), + 'AllowanceCrowdsale: token wallet is the zero address' + ); }); }); }); diff --git a/test/crowdsale/CappedCrowdsale.test.js b/test/crowdsale/CappedCrowdsale.test.js index 26ae8c4a17a..dc0b8fbd421 100644 --- a/test/crowdsale/CappedCrowdsale.test.js +++ b/test/crowdsale/CappedCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail } = require('openzeppelin-test-helpers'); const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('CappedCrowdsale', function ([_, wallet]) { +contract('CappedCrowdsale', function ([_, wallet]) { const rate = new BN('1'); const cap = ether('100'); const lessThanCap = ether('60'); @@ -14,7 +14,9 @@ contract.only('CappedCrowdsale', function ([_, wallet]) { }); it('rejects a cap of zero', async function () { - await shouldFail.reverting.withMessage(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0), "CappedCrowdsale: cap is 0"); + await shouldFail.reverting.withMessage(CappedCrowdsaleImpl.new(rate, wallet, this.token.address, 0), + 'CappedCrowdsale: cap is 0' + ); }); context('with crowdsale', function () { @@ -31,11 +33,11 @@ contract.only('CappedCrowdsale', function ([_, wallet]) { it('should reject payments outside cap', async function () { await this.crowdsale.send(cap); - await shouldFail.reverting.withMessage(this.crowdsale.send(1), "CappedCrowdsale: cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.send(1), 'CappedCrowdsale: cap exceeded'); }); it('should reject payments that exceed cap', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.send(cap.addn(1)), "CappedCrowdsale: cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.send(cap.addn(1)), 'CappedCrowdsale: cap exceeded'); }); }); diff --git a/test/crowdsale/Crowdsale.test.js b/test/crowdsale/Crowdsale.test.js index eed22edb939..b6788d1895f 100644 --- a/test/crowdsale/Crowdsale.test.js +++ b/test/crowdsale/Crowdsale.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const Crowdsale = artifacts.require('CrowdsaleMock'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('Crowdsale', function ([_, investor, wallet, purchaser]) { +contract('Crowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const value = ether('42'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -13,7 +13,7 @@ contract.only('Crowdsale', function ([_, investor, wallet, purchaser]) { it('requires a non-null token', async function () { await shouldFail.reverting.withMessage( Crowdsale.new(rate, wallet, ZERO_ADDRESS), - "Crowdsale: token is the zero address" + 'Crowdsale: token is the zero address' ); }); @@ -24,13 +24,13 @@ contract.only('Crowdsale', function ([_, investor, wallet, purchaser]) { it('requires a non-zero rate', async function () { await shouldFail.reverting.withMessage( - Crowdsale.new(0, wallet, this.token.address), "Crowdsale: rate is 0" + Crowdsale.new(0, wallet, this.token.address), 'Crowdsale: rate is 0' ); }); it('requires a non-null wallet', async function () { await shouldFail.reverting.withMessage( - Crowdsale.new(rate, ZERO_ADDRESS, this.token.address), "Crowdsale: wallet is the zero address" + Crowdsale.new(rate, ZERO_ADDRESS, this.token.address), 'Crowdsale: wallet is the zero address' ); }); @@ -48,7 +48,7 @@ contract.only('Crowdsale', function ([_, investor, wallet, purchaser]) { it('reverts on zero-valued payments', async function () { await shouldFail.reverting.withMessage( - this.crowdsale.send(0, { from: purchaser }), "Crowdsale: weiAmount is 0" + this.crowdsale.send(0, { from: purchaser }), 'Crowdsale: weiAmount is 0' ); }); }); @@ -60,13 +60,14 @@ contract.only('Crowdsale', function ([_, investor, wallet, purchaser]) { it('reverts on zero-valued payments', async function () { await shouldFail.reverting.withMessage( - this.crowdsale.buyTokens(investor, { value: 0, from: purchaser }), "Crowdsale: weiAmount is 0" + this.crowdsale.buyTokens(investor, { value: 0, from: purchaser }), 'Crowdsale: weiAmount is 0' ); }); it('requires a non-null beneficiary', async function () { await shouldFail.reverting.withMessage( - this.crowdsale.buyTokens(ZERO_ADDRESS, { value: value, from: purchaser }), "Crowdsale: beneficiary is the zero address" + this.crowdsale.buyTokens(ZERO_ADDRESS, { value: value, from: purchaser }), + 'Crowdsale: beneficiary is the zero address' ); }); }); diff --git a/test/crowdsale/FinalizableCrowdsale.test.js b/test/crowdsale/FinalizableCrowdsale.test.js index 61a26607253..b63410d625f 100644 --- a/test/crowdsale/FinalizableCrowdsale.test.js +++ b/test/crowdsale/FinalizableCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, expectEvent, shouldFail, time } = require('openzeppelin-test-helpers const FinalizableCrowdsaleImpl = artifacts.require('FinalizableCrowdsaleImpl'); const ERC20 = artifacts.require('ERC20'); -contract.only('FinalizableCrowdsale', function ([_, wallet, other]) { +contract('FinalizableCrowdsale', function ([_, wallet, other]) { const rate = new BN('1000'); before(async function () { @@ -23,7 +23,9 @@ contract.only('FinalizableCrowdsale', function ([_, wallet, other]) { }); it('cannot be finalized before ending', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }), "FinalizableCrowdsale: not closed"); + await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }), + 'FinalizableCrowdsale: not closed' + ); }); it('can be finalized by anyone after ending', async function () { @@ -34,7 +36,9 @@ contract.only('FinalizableCrowdsale', function ([_, wallet, other]) { it('cannot be finalized twice', async function () { await time.increaseTo(this.afterClosingTime); await this.crowdsale.finalize({ from: other }); - await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }), "FinalizableCrowdsale: already finalized"); + await shouldFail.reverting.withMessage(this.crowdsale.finalize({ from: other }), + 'FinalizableCrowdsale: already finalized' + ); }); it('logs finalized', async function () { diff --git a/test/crowdsale/IncreasingPriceCrowdsale.test.js b/test/crowdsale/IncreasingPriceCrowdsale.test.js index 44d785f76d2..e8f041136d7 100644 --- a/test/crowdsale/IncreasingPriceCrowdsale.test.js +++ b/test/crowdsale/IncreasingPriceCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers'); const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) { +contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) { const value = ether('1'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -28,19 +28,19 @@ contract.only('IncreasingPriceCrowdsale', function ([_, investor, wallet, purcha it('reverts with a final rate larger than the initial rate', async function () { await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.addn(1) - ), "IncreasingPriceCrowdsale: initial rate is less than final rate"); + ), 'IncreasingPriceCrowdsale: initial rate is less than final rate'); }); it('reverts with a final rate equal to the initial rate', async function () { await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate - ), "IncreasingPriceCrowdsale: initial rate is less than final rate"); + ), 'IncreasingPriceCrowdsale: initial rate is less than final rate'); }); it('reverts with a final rate of zero', async function () { await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, 0 - ), "IncreasingPriceCrowdsale: final rate is 0"); + ), 'IncreasingPriceCrowdsale: final rate is 0'); }); context('with crowdsale', function () { @@ -57,7 +57,9 @@ contract.only('IncreasingPriceCrowdsale', function ([_, investor, wallet, purcha }); it('reverts when the base Crowdsale\'s rate function is called', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.rate(), "VM Exception while processing transaction: revert"); + await shouldFail.reverting.withMessage(this.crowdsale.rate(), + 'VM Exception while processing transaction: revert' + ); }); it('returns a rate of 0 before the crowdsale starts', async function () { diff --git a/test/crowdsale/IndividuallyCappedCrowdsale.test.js b/test/crowdsale/IndividuallyCappedCrowdsale.test.js index b34e4f35248..a1c4ade2148 100644 --- a/test/crowdsale/IndividuallyCappedCrowdsale.test.js +++ b/test/crowdsale/IndividuallyCappedCrowdsale.test.js @@ -4,7 +4,7 @@ const IndividuallyCappedCrowdsaleImpl = artifacts.require('IndividuallyCappedCro const SimpleToken = artifacts.require('SimpleToken'); const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior'); -contract.only('IndividuallyCappedCrowdsale', function ( +contract('IndividuallyCappedCrowdsale', function ( [_, capper, otherCapper, wallet, alice, bob, charlie, other, ...otherAccounts]) { const rate = new BN(1); const capAlice = ether('10'); @@ -34,7 +34,9 @@ contract.only('IndividuallyCappedCrowdsale', function ( }); it('reverts when a non-capper sets a cap', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.setCap(alice, capAlice, { from: other }), "CapperRole: caller does not have the Capper role"); + await shouldFail.reverting.withMessage(this.crowdsale.setCap(alice, capAlice, { from: other }), + 'CapperRole: caller does not have the Capper role' + ); }); context('with individual caps', function () { @@ -52,21 +54,31 @@ contract.only('IndividuallyCappedCrowdsale', function ( it('should reject payments outside cap', async function () { await this.crowdsale.buyTokens(alice, { value: capAlice }); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(alice, { value: 1 }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(alice, { value: 1 }), + 'IndividuallyCappedCrowdsale: beneficiary\'s cap exceeded' + ); }); it('should reject payments that exceed cap', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(alice, { value: capAlice.addn(1) }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(bob, { value: capBob.addn(1) }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(alice, { value: capAlice.addn(1) }), + 'IndividuallyCappedCrowdsale: beneficiary\'s cap exceeded' + ); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(bob, { value: capBob.addn(1) }), + 'IndividuallyCappedCrowdsale: beneficiary\'s cap exceeded' + ); }); it('should manage independent caps', async function () { await this.crowdsale.buyTokens(alice, { value: lessThanCapAlice }); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(bob, { value: lessThanCapAlice }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(bob, { value: lessThanCapAlice }), + 'IndividuallyCappedCrowdsale: beneficiary\'s cap exceeded' + ); }); it('should default to a cap of zero', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(charlie, { value: lessThanCapBoth }), "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(charlie, { value: lessThanCapBoth }), + 'IndividuallyCappedCrowdsale: beneficiary\'s cap exceeded' + ); }); }); diff --git a/test/crowdsale/MintedCrowdsale.test.js b/test/crowdsale/MintedCrowdsale.test.js index d41856d9879..3351ad8d65f 100644 --- a/test/crowdsale/MintedCrowdsale.test.js +++ b/test/crowdsale/MintedCrowdsale.test.js @@ -5,7 +5,7 @@ const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20 = artifacts.require('ERC20'); -contract.only('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]) { +contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]) { const rate = new BN('1000'); const value = ether('5'); @@ -32,11 +32,15 @@ contract.only('MintedCrowdsale', function ([_, deployer, investor, wallet, purch }); it('rejects bare payments', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.send(value), "VM Exception while processing transaction: revert"); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), + 'VM Exception while processing transaction: revert' + ); }); it('rejects token purchases', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), "VM Exception while processing transaction: revert"); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), + 'VM Exception while processing transaction: revert' + ); }); }); }); diff --git a/test/crowdsale/PausableCrowdsale.test.js b/test/crowdsale/PausableCrowdsale.test.js index 9b68004824e..c5b047bb5f9 100644 --- a/test/crowdsale/PausableCrowdsale.test.js +++ b/test/crowdsale/PausableCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, shouldFail } = require('openzeppelin-test-helpers'); const PausableCrowdsale = artifacts.require('PausableCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('PausableCrowdsale', function ([_, pauser, wallet, other]) { +contract('PausableCrowdsale', function ([_, pauser, wallet, other]) { const rate = new BN(1); const value = new BN(1); @@ -26,8 +26,12 @@ contract.only('PausableCrowdsale', function ([_, pauser, wallet, other]) { }); it('purchases do not work', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.sendTransaction({ from: other, value }), "Pausable: paused"); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(other, { from: other, value }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.crowdsale.sendTransaction({ from: other, value }), + 'Pausable: paused' + ); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(other, { from: other, value }), + 'Pausable: paused' + ); }); context('after unpause', function () { diff --git a/test/crowdsale/PostDeliveryCrowdsale.test.js b/test/crowdsale/PostDeliveryCrowdsale.test.js index abfb69b97d7..daf40aa2001 100644 --- a/test/crowdsale/PostDeliveryCrowdsale.test.js +++ b/test/crowdsale/PostDeliveryCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers'); const PostDeliveryCrowdsaleImpl = artifacts.require('PostDeliveryCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { +contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const tokenSupply = new BN('10').pow(new BN('22')); @@ -41,7 +41,9 @@ contract.only('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "PostDeliveryCrowdsale: not closed"); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), + 'PostDeliveryCrowdsale: not closed' + ); }); context('after closing time', function () { @@ -57,7 +59,9 @@ contract.only('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser it('rejects multiple withdrawals', async function () { await this.crowdsale.withdrawTokens(investor); - await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "PostDeliveryCrowdsale: beneficiary is not due any tokens"); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), + 'PostDeliveryCrowdsale: beneficiary is not due any tokens' + ); }); }); }); diff --git a/test/crowdsale/RefundableCrowdsale.test.js b/test/crowdsale/RefundableCrowdsale.test.js index af2ae197d5a..7092dc78f98 100644 --- a/test/crowdsale/RefundableCrowdsale.test.js +++ b/test/crowdsale/RefundableCrowdsale.test.js @@ -3,7 +3,7 @@ const { balance, BN, ether, shouldFail, time } = require('openzeppelin-test-help const RefundableCrowdsaleImpl = artifacts.require('RefundableCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other]) { +contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other]) { const rate = new BN(1); const goal = ether('50'); const lessThanGoal = ether('45'); @@ -25,7 +25,8 @@ contract.only('RefundableCrowdsale', function ([_, wallet, investor, purchaser, it('rejects a goal of zero', async function () { await shouldFail.reverting.withMessage( - RefundableCrowdsaleImpl.new(this.openingTime, this.closingTime, rate, wallet, this.token.address, 0), "RefundableCrowdsale: goal is 0" + RefundableCrowdsaleImpl.new(this.openingTime, this.closingTime, rate, wallet, this.token.address, 0), + 'RefundableCrowdsale: goal is 0' ); }); @@ -40,7 +41,9 @@ contract.only('RefundableCrowdsale', function ([_, wallet, investor, purchaser, context('before opening time', function () { it('denies refunds', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), "RefundableCrowdsale: not finalized"); + await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), + 'RefundableCrowdsale: not finalized' + ); }); }); @@ -50,7 +53,9 @@ contract.only('RefundableCrowdsale', function ([_, wallet, investor, purchaser, }); it('denies refunds', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), "RefundableCrowdsale: not finalized"); + await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), + 'RefundableCrowdsale: not finalized' + ); }); context('with unreached goal', function () { @@ -84,7 +89,9 @@ contract.only('RefundableCrowdsale', function ([_, wallet, investor, purchaser, }); it('denies refunds', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), "RefundableCrowdsale: goal reached"); + await shouldFail.reverting.withMessage(this.crowdsale.claimRefund(investor), + 'RefundableCrowdsale: goal reached' + ); }); it('forwards funds to wallet', async function () { diff --git a/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js b/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js index 2d3042fc701..f2740d1fdc8 100644 --- a/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js +++ b/test/crowdsale/RefundablePostDeliveryCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail, time } = require('openzeppelin-test-helpers'); const RefundablePostDeliveryCrowdsaleImpl = artifacts.require('RefundablePostDeliveryCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { +contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const tokenSupply = new BN('10').pow(new BN('22')); const goal = ether('100'); @@ -42,7 +42,9 @@ contract.only('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "RefundablePostDeliveryCrowdsale: not finalized"); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), + 'RefundablePostDeliveryCrowdsale: not finalized' + ); }); context('after closing time and finalization', function () { @@ -52,7 +54,9 @@ contract.only('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, }); it('rejects token withdrawals', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "RefundablePostDeliveryCrowdsale: goal not reached"); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), + 'RefundablePostDeliveryCrowdsale: goal not reached' + ); }); }); }); @@ -70,7 +74,9 @@ contract.only('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, }); it('does not allow beneficiaries to withdraw tokens before crowdsale ends', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "RefundablePostDeliveryCrowdsale: not finalized"); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), + 'RefundablePostDeliveryCrowdsale: not finalized' + ); }); context('after closing time and finalization', function () { @@ -87,7 +93,9 @@ contract.only('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, it('rejects multiple withdrawals', async function () { await this.crowdsale.withdrawTokens(investor); - await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), "PostDeliveryCrowdsale: beneficiary is not due any tokens"); + await shouldFail.reverting.withMessage(this.crowdsale.withdrawTokens(investor), + 'PostDeliveryCrowdsale: beneficiary is not due any tokens' + ); }); }); }); diff --git a/test/crowdsale/TimedCrowdsale.test.js b/test/crowdsale/TimedCrowdsale.test.js index e588a0caaad..da082d633b0 100644 --- a/test/crowdsale/TimedCrowdsale.test.js +++ b/test/crowdsale/TimedCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, expectEvent, shouldFail, time } = require('openzeppelin-test- const TimedCrowdsaleImpl = artifacts.require('TimedCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { +contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { const rate = new BN(1); const value = ether('42'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -23,19 +23,19 @@ contract.only('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('reverts if the opening time is in the past', async function () { await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( (await time.latest()).sub(time.duration.days(1)), this.closingTime, rate, wallet, this.token.address - ), "TimedCrowdsale: opening time is before current time"); + ), 'TimedCrowdsale: opening time is before current time'); }); it('reverts if the closing time is before the opening time', async function () { await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime.sub(time.duration.seconds(1)), rate, wallet, this.token.address - ), "TimedCrowdsale: closing time is before opening time"); + ), 'TimedCrowdsale: closing time is before opening time'); }); it('reverts if the closing time equals the opening time', async function () { await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime, rate, wallet, this.token.address - ), "TimedCrowdsale: closing time is before opening time"); + ), 'TimedCrowdsale: closing time is before opening time'); }); context('with crowdsale', function () { @@ -56,8 +56,10 @@ contract.only('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { describe('accepting payments', function () { it('should reject payments before start', async function () { (await this.crowdsale.isOpen()).should.equal(false); - await shouldFail.reverting.withMessage(this.crowdsale.send(value), "TimedCrowdsale: not open"); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: purchaser, value: value }), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), 'TimedCrowdsale: not open'); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: purchaser, value: value }), + 'TimedCrowdsale: not open' + ); }); it('should accept payments after start', async function () { @@ -69,25 +71,31 @@ contract.only('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('should reject payments after end', async function () { await time.increaseTo(this.afterClosingTime); - await shouldFail.reverting.withMessage(this.crowdsale.send(value), "TimedCrowdsale: not open"); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), 'TimedCrowdsale: not open'); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), + 'TimedCrowdsale: not open' + ); }); }); describe('extending closing time', function () { it('should not reduce duration', async function () { // Same date - await shouldFail.reverting.withMessage(this.crowdsale.extendTime(this.closingTime), "TimedCrowdsale: new closing time is before current closing time"); + await shouldFail.reverting.withMessage(this.crowdsale.extendTime(this.closingTime), + 'TimedCrowdsale: new closing time is before current closing time' + ); // Prescending date const newClosingTime = this.closingTime.sub(time.duration.seconds(1)); - await shouldFail.reverting.withMessage(this.crowdsale.extendTime(newClosingTime), "TimedCrowdsale: new closing time is before current closing time"); + await shouldFail.reverting.withMessage(this.crowdsale.extendTime(newClosingTime), + 'TimedCrowdsale: new closing time is before current closing time' + ); }); context('before crowdsale start', function () { beforeEach(async function () { (await this.crowdsale.isOpen()).should.equal(false); - await shouldFail.reverting.withMessage(this.crowdsale.send(value), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.send(value), 'TimedCrowdsale: not open'); }); it('it extends end time', async function () { @@ -126,7 +134,9 @@ contract.only('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('it reverts', async function () { const newClosingTime = await time.latest(); - await shouldFail.reverting.withMessage(this.crowdsale.extendTime(newClosingTime), "TimedCrowdsale: already closed"); + await shouldFail.reverting.withMessage(this.crowdsale.extendTime(newClosingTime), + 'TimedCrowdsale: already closed' + ); }); }); }); diff --git a/test/crowdsale/WhitelistCrowdsale.test.js b/test/crowdsale/WhitelistCrowdsale.test.js index 8a894a5909d..be7b5249f25 100644 --- a/test/crowdsale/WhitelistCrowdsale.test.js +++ b/test/crowdsale/WhitelistCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, ether, shouldFail } = require('openzeppelin-test-helpers'); const WhitelistCrowdsale = artifacts.require('WhitelistCrowdsaleImpl'); const SimpleToken = artifacts.require('SimpleToken'); -contract.only('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, other]) { +contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, other]) { const rate = new BN(1); const value = ether('42'); const tokenSupply = new BN('10').pow(new BN('22')); @@ -20,8 +20,12 @@ contract.only('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelist } async function purchaseShouldFail (crowdsale, beneficiary, value) { - await shouldFail.reverting.withMessage(crowdsale.buyTokens(beneficiary, { from: beneficiary, value }), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role"); - await shouldFail.reverting.withMessage(crowdsale.sendTransaction({ from: beneficiary, value }), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role"); + await shouldFail.reverting.withMessage(crowdsale.buyTokens(beneficiary, { from: beneficiary, value }), + 'WhitelistCrowdsale: beneficiary doesn\'t have the Whitelisted role' + ); + await shouldFail.reverting.withMessage(crowdsale.sendTransaction({ from: beneficiary, value }), + 'WhitelistCrowdsale: beneficiary doesn\'t have the Whitelisted role' + ); } context('with no whitelisted addresses', function () { diff --git a/test/cryptography/ECDSA.test.js b/test/cryptography/ECDSA.test.js index 9036785d9ae..e89f2d84776 100644 --- a/test/cryptography/ECDSA.test.js +++ b/test/cryptography/ECDSA.test.js @@ -7,7 +7,7 @@ const ECDSAMock = artifacts.require('ECDSAMock'); const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin'); const WRONG_MESSAGE = web3.utils.sha3('Nope'); -contract.only('ECDSA', function ([_, other]) { +contract('ECDSA', function ([_, other]) { beforeEach(async function () { this.ecdsa = await ECDSAMock.new(); }); @@ -120,7 +120,7 @@ contract.only('ECDSA', function ([_, other]) { const signature = await web3.eth.sign(TEST_MESSAGE, other); await shouldFail.reverting.withMessage( this.ecdsa.recover(TEST_MESSAGE.substring(2), signature), - "Failure message" + 'Failure message' ); }); }); diff --git a/test/drafts/Counters.test.js b/test/drafts/Counters.test.js index da29492621b..50dbc978ce3 100644 --- a/test/drafts/Counters.test.js +++ b/test/drafts/Counters.test.js @@ -2,7 +2,7 @@ const { shouldFail } = require('openzeppelin-test-helpers'); const CountersImpl = artifacts.require('CountersImpl'); -contract.only('Counters', function () { +contract('Counters', function () { beforeEach(async function () { this.counter = await CountersImpl.new(); }); @@ -39,7 +39,7 @@ contract.only('Counters', function () { it('reverts if the current value is 0', async function () { await this.counter.decrement(); - await shouldFail.reverting.withMessage(this.counter.decrement(), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.counter.decrement(), 'SafeMath: subtraction overflow'); }); it('can be called multiple times', async function () { diff --git a/test/drafts/ERC1820Implementer.test.js b/test/drafts/ERC1820Implementer.test.js index 95ffb22ca61..7f9472ca362 100644 --- a/test/drafts/ERC1820Implementer.test.js +++ b/test/drafts/ERC1820Implementer.test.js @@ -3,7 +3,7 @@ const { bufferToHex, keccak256 } = require('ethereumjs-util'); const ERC1820ImplementerMock = artifacts.require('ERC1820ImplementerMock'); -contract.only('ERC1820Implementer', function ([_, registryFunder, implementee, other]) { +contract('ERC1820Implementer', function ([_, registryFunder, implementee, other]) { const ERC1820_ACCEPT_MAGIC = bufferToHex(keccak256('ERC1820_ACCEPT_MAGIC')); beforeEach(async function () { @@ -25,7 +25,7 @@ contract.only('ERC1820Implementer', function ([_, registryFunder, implementee, o this.registry.setInterfaceImplementer( implementee, this.interfaceA, this.implementer.address, { from: implementee } ), - "Does not implement the interface" + 'Does not implement the interface' ); }); }); diff --git a/test/drafts/ERC20Migrator.test.js b/test/drafts/ERC20Migrator.test.js index c9472ecaec2..558add2616b 100644 --- a/test/drafts/ERC20Migrator.test.js +++ b/test/drafts/ERC20Migrator.test.js @@ -5,11 +5,13 @@ const ERC20Mock = artifacts.require('ERC20Mock'); const ERC20Mintable = artifacts.require('ERC20Mintable'); const ERC20Migrator = artifacts.require('ERC20Migrator'); -contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { +contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) { const totalSupply = new BN('200'); it('reverts with a null legacy token address', async function () { - await shouldFail.reverting.withMessage(ERC20Migrator.new(ZERO_ADDRESS), "ERC20Migrator: legacy token is the zero address"); + await shouldFail.reverting.withMessage(ERC20Migrator.new(ZERO_ADDRESS), + 'ERC20Migrator: legacy token is the zero address' + ); }); describe('with tokens and migrator', function () { @@ -25,11 +27,15 @@ contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) describe('beginMigration', function () { it('reverts with a null new token address', async function () { - await shouldFail.reverting.withMessage(this.migrator.beginMigration(ZERO_ADDRESS), "ERC20Migrator: new token is the zero address"); + await shouldFail.reverting.withMessage(this.migrator.beginMigration(ZERO_ADDRESS), + 'ERC20Migrator: new token is the zero address' + ); }); it('reverts if not a minter of the token', async function () { - await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address), "ERC20Migrator: not a minter for new token"); + await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address), + 'ERC20Migrator: not a minter for new token' + ); }); it('succeeds if it is a minter of the token', async function () { @@ -40,7 +46,9 @@ contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) it('reverts the second time it is called', async function () { await this.newToken.addMinter(this.migrator.address); await this.migrator.beginMigration(this.newToken.address); - await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address), "ERC20Migrator: migration already started"); + await shouldFail.reverting.withMessage(this.migrator.beginMigration(this.newToken.address), + 'ERC20Migrator: migration already started' + ); }); }); @@ -58,7 +66,9 @@ contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) }); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.migrator.migrateAll(owner), "ERC20Migrator: migration not started"); + await shouldFail.reverting.withMessage(this.migrator.migrateAll(owner), + 'ERC20Migrator: migration not started' + ); }); }); }); @@ -72,7 +82,9 @@ contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) }); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount), "ERC20Migrator: migration not started"); + await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount), + 'ERC20Migrator: migration not started' + ); }); }); }); @@ -174,7 +186,9 @@ contract.only('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) const amount = baseAmount.addn(1); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.migrator.migrate(owner, amount), + 'SafeERC20: low-level call failed' + ); }); }); }); diff --git a/test/drafts/ERC20Snapshot.test.js b/test/drafts/ERC20Snapshot.test.js index f70a61ab491..13d525c59da 100644 --- a/test/drafts/ERC20Snapshot.test.js +++ b/test/drafts/ERC20Snapshot.test.js @@ -1,7 +1,7 @@ const { BN, expectEvent, shouldFail } = require('openzeppelin-test-helpers'); const ERC20SnapshotMock = artifacts.require('ERC20SnapshotMock'); -contract.only('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { +contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { const initialSupply = new BN(100); beforeEach(async function () { @@ -24,11 +24,11 @@ contract.only('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { describe('totalSupplyAt', function () { it('reverts with a snapshot id of 0', async function () { - await shouldFail.reverting.withMessage(this.token.totalSupplyAt(0), "ERC20Snapshot: id is 0"); + await shouldFail.reverting.withMessage(this.token.totalSupplyAt(0), 'ERC20Snapshot: id is 0'); }); it('reverts with a not-yet-created snapshot id', async function () { - await shouldFail.reverting.withMessage(this.token.totalSupplyAt(1), "ERC20Snapshot: nonexistent id"); + await shouldFail.reverting.withMessage(this.token.totalSupplyAt(1), 'ERC20Snapshot: nonexistent id'); }); context('with initial snapshot', function () { @@ -98,11 +98,11 @@ contract.only('ERC20Snapshot', function ([_, initialHolder, recipient, other]) { describe('balanceOfAt', function () { it('reverts with a snapshot id of 0', async function () { - await shouldFail.reverting.withMessage(this.token.balanceOfAt(other, 0), "ERC20Snapshot: id is 0"); + await shouldFail.reverting.withMessage(this.token.balanceOfAt(other, 0), 'ERC20Snapshot: id is 0'); }); it('reverts with a not-yet-created snapshot id', async function () { - await shouldFail.reverting.withMessage(this.token.balanceOfAt(other, 1), "ERC20Snapshot: nonexistent id"); + await shouldFail.reverting.withMessage(this.token.balanceOfAt(other, 1), 'ERC20Snapshot: nonexistent id'); }); context('with initial snapshot', function () { diff --git a/test/drafts/SignatureBouncer.test.js b/test/drafts/SignatureBouncer.test.js index d23fe4c144f..a7af33f72f4 100644 --- a/test/drafts/SignatureBouncer.test.js +++ b/test/drafts/SignatureBouncer.test.js @@ -8,7 +8,7 @@ const UINT_VALUE = 23; const BYTES_VALUE = web3.utils.toHex('test'); const INVALID_SIGNATURE = '0xabcd'; -contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, authorizedUser, ...otherAccounts]) { +contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorizedUser, ...otherAccounts]) { beforeEach(async function () { this.sigBouncer = await SignatureBouncerMock.new({ from: signer }); this.signFor = getSignFor(this.sigBouncer, signer); @@ -31,20 +31,22 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth it('does not allow invalid signature for sender', async function () { await shouldFail.reverting.withMessage( - this.sigBouncer.onlyWithValidSignature(INVALID_SIGNATURE, { from: authorizedUser }), "SignatureBouncer: invalid signature for caller" + this.sigBouncer.onlyWithValidSignature(INVALID_SIGNATURE, { from: authorizedUser }), + 'SignatureBouncer: invalid signature for caller' ); }); it('does not allow valid signature for other sender', async function () { await shouldFail.reverting.withMessage( - this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser), { from: other }), "SignatureBouncer: invalid signature for caller" + this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser), { from: other }), + 'SignatureBouncer: invalid signature for caller' ); }); it('does not allow valid signature for method for sender', async function () { await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignature(await this.signFor(authorizedUser, 'onlyWithValidSignature'), - { from: authorizedUser }), "SignatureBouncer: invalid signature for caller" + { from: authorizedUser }), 'SignatureBouncer: invalid signature for caller' ); }); }); @@ -58,7 +60,8 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth it('does not allow invalid signature with correct method for sender', async function () { await shouldFail.reverting.withMessage( - this.sigBouncer.onlyWithValidSignatureAndMethod(INVALID_SIGNATURE, { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and method" + this.sigBouncer.onlyWithValidSignatureAndMethod(INVALID_SIGNATURE, { from: authorizedUser }), + 'SignatureBouncer: invalid signature for caller and method' ); }); @@ -66,20 +69,22 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndMethod( await this.signFor(authorizedUser, 'onlyWithValidSignatureAndMethod'), { from: other } - ), "SignatureBouncer: invalid signature for caller and method" + ), + 'SignatureBouncer: invalid signature for caller and method' ); }); it('does not allow valid method signature with incorrect method for sender', async function () { await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser, 'theWrongMethod'), - { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and method" + { from: authorizedUser }), 'SignatureBouncer: invalid signature for caller and method' ); }); it('does not allow valid non-method signature method for sender', async function () { await shouldFail.reverting.withMessage( - this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser), { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and method" + this.sigBouncer.onlyWithValidSignatureAndMethod(await this.signFor(authorizedUser), { from: authorizedUser }), + 'SignatureBouncer: invalid signature for caller and method' ); }); }); @@ -93,7 +98,8 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth it('does not allow invalid signature with correct method and data for sender', async function () { await shouldFail.reverting.withMessage( - this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, INVALID_SIGNATURE, { from: authorizedUser }), "SignatureBouncer: invalid signature for caller and data" + this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, INVALID_SIGNATURE, { from: authorizedUser }), + 'SignatureBouncer: invalid signature for caller and data' ); }); @@ -102,7 +108,7 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE + 10, await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]), { from: authorizedUser } - ), "SignatureBouncer: invalid signature for caller and data" + ), 'SignatureBouncer: invalid signature for caller and data' ); }); @@ -111,7 +117,7 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, await this.signFor(authorizedUser, 'onlyWithValidSignatureAndData', [UINT_VALUE]), { from: other } - ), "SignatureBouncer: invalid signature for caller and data" + ), 'SignatureBouncer: invalid signature for caller and data' ); }); @@ -119,13 +125,13 @@ contract.only('SignatureBouncer', function ([_, signer, otherSigner, other, auth await shouldFail.reverting.withMessage( this.sigBouncer.onlyWithValidSignatureAndData(UINT_VALUE, await this.signFor(authorizedUser), { from: authorizedUser } - ), "SignatureBouncer: invalid signature for caller and data" + ), 'SignatureBouncer: invalid signature for caller and data' ); }); it('does not allow msg.data shorter than SIGNATURE_SIZE', async function () { await shouldFail.reverting.withMessage( - this.sigBouncer.tooShortMsgData({ from: authorizedUser }), "SignatureBouncer: data is too short" + this.sigBouncer.tooShortMsgData({ from: authorizedUser }), 'SignatureBouncer: data is too short' ); }); }); diff --git a/test/drafts/SignedSafeMath.test.js b/test/drafts/SignedSafeMath.test.js index b23a00ee3b8..01c954853a3 100644 --- a/test/drafts/SignedSafeMath.test.js +++ b/test/drafts/SignedSafeMath.test.js @@ -3,7 +3,7 @@ const { MAX_INT256, MIN_INT256 } = constants; const SignedSafeMathMock = artifacts.require('SignedSafeMathMock'); -contract.only('SignedSafeMath', function () { +contract('SignedSafeMath', function () { beforeEach(async function () { this.safeMath = await SignedSafeMathMock.new(); }); @@ -14,7 +14,7 @@ contract.only('SignedSafeMath', function () { } async function testFailsCommutative (fn, lhs, rhs) { - //TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages + // TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages await shouldFail.reverting.withMessage(fn(lhs, rhs)); await shouldFail.reverting.withMessage(fn(rhs, lhs)); } @@ -70,14 +70,14 @@ contract.only('SignedSafeMath', function () { const a = MAX_INT256; const b = new BN('-1'); - await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), "SignedSafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), 'SignedSafeMath: subtraction overflow'); }); it('reverts on negative subtraction overflow', async function () { const a = MIN_INT256; const b = new BN('1'); - await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), "SignedSafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), 'SignedSafeMath: subtraction overflow'); }); }); @@ -138,14 +138,14 @@ contract.only('SignedSafeMath', function () { const a = new BN('-5678'); const b = new BN('0'); - await shouldFail.reverting.withMessage(this.safeMath.div(a, b), "SignedSafeMath: division by zero"); + await shouldFail.reverting.withMessage(this.safeMath.div(a, b), 'SignedSafeMath: division by zero'); }); it('reverts on overflow, negative second', async function () { const a = new BN(MIN_INT256); const b = new BN('-1'); - await shouldFail.reverting.withMessage(this.safeMath.div(a, b), "SignedSafeMath: division overflow"); + await shouldFail.reverting.withMessage(this.safeMath.div(a, b), 'SignedSafeMath: division overflow'); }); }); }); diff --git a/test/drafts/TokenVesting.test.js b/test/drafts/TokenVesting.test.js index f4107fdabbb..46050b10682 100644 --- a/test/drafts/TokenVesting.test.js +++ b/test/drafts/TokenVesting.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const ERC20Mintable = artifacts.require('ERC20Mintable'); const TokenVesting = artifacts.require('TokenVesting'); -contract.only('TokenVesting', function ([_, owner, beneficiary]) { +contract('TokenVesting', function ([_, owner, beneficiary]) { const amount = new BN('1000'); beforeEach(async function () { @@ -21,20 +21,22 @@ contract.only('TokenVesting', function ([_, owner, beneficiary]) { cliffDuration.should.be.bignumber.that.is.at.least(duration); await shouldFail.reverting.withMessage( - TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }), "TokenVesting: cliff is longer than duration" + TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }), + 'TokenVesting: cliff is longer than duration' ); }); it('reverts with a null beneficiary', async function () { await shouldFail.reverting.withMessage( - TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }), "TokenVesting: beneficiary is the zero address" + TokenVesting.new(ZERO_ADDRESS, this.start, this.cliffDuration, this.duration, true, { from: owner }), + 'TokenVesting: beneficiary is the zero address' ); }); it('reverts with a null duration', async function () { // cliffDuration should also be 0, since the duration must be larger than the cliff await shouldFail.reverting.withMessage( - TokenVesting.new(beneficiary, this.start, 0, 0, true, { from: owner }), "TokenVesting: duration is 0" + TokenVesting.new(beneficiary, this.start, 0, 0, true, { from: owner }), 'TokenVesting: duration is 0' ); }); @@ -43,7 +45,8 @@ contract.only('TokenVesting', function ([_, owner, beneficiary]) { this.start = now.sub(this.duration).sub(time.duration.minutes(1)); await shouldFail.reverting.withMessage( - TokenVesting.new(beneficiary, this.start, this.cliffDuration, this.duration, true, { from: owner }), "TokenVesting: starting time is before current time" + TokenVesting.new(beneficiary, this.start, this.cliffDuration, this.duration, true, { from: owner }), + 'TokenVesting: starting time is before current time' ); }); @@ -65,7 +68,9 @@ contract.only('TokenVesting', function ([_, owner, beneficiary]) { }); it('cannot be released before cliff', async function () { - await shouldFail.reverting.withMessage(this.vesting.release(this.token.address), "TokenVesting: no tokens are due"); + await shouldFail.reverting.withMessage(this.vesting.release(this.token.address), + 'TokenVesting: no tokens are due' + ); }); it('can be released after cliff', async function () { @@ -121,7 +126,9 @@ contract.only('TokenVesting', function ([_, owner, beneficiary]) { beneficiary, this.start, this.cliffDuration, this.duration, false, { from: owner } ); - await shouldFail.reverting.withMessage(vesting.revoke(this.token.address, { from: owner }), "TokenVesting: cannot revoke"); + await shouldFail.reverting.withMessage(vesting.revoke(this.token.address, { from: owner }), + 'TokenVesting: cannot revoke' + ); }); it('should return the non-vested tokens when revoked by owner', async function () { @@ -148,7 +155,9 @@ contract.only('TokenVesting', function ([_, owner, beneficiary]) { it('should fail to be revoked a second time', async function () { await this.vesting.revoke(this.token.address, { from: owner }); - await shouldFail.reverting.withMessage(this.vesting.revoke(this.token.address, { from: owner }), "TokenVesting: token already revoked"); + await shouldFail.reverting.withMessage(this.vesting.revoke(this.token.address, { from: owner }), + 'TokenVesting: token already revoked' + ); }); function vestedAmount (total, now, start, cliffDuration, duration) { diff --git a/test/examples/SampleCrowdsale.test.js b/test/examples/SampleCrowdsale.test.js index 327fde9c3f2..b44347c8052 100644 --- a/test/examples/SampleCrowdsale.test.js +++ b/test/examples/SampleCrowdsale.test.js @@ -3,7 +3,7 @@ const { BN, balance, ether, shouldFail, time } = require('openzeppelin-test-help const SampleCrowdsale = artifacts.require('SampleCrowdsale'); const SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken'); -contract.only('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { +contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) { const RATE = new BN(10); const GOAL = ether('10'); const CAP = ether('20'); @@ -38,8 +38,10 @@ contract.only('SampleCrowdsale', function ([_, deployer, owner, wallet, investor }); it('should not accept payments before start', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), "TimedCrowdsale: not open"); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: investor, value: ether('1') }), "TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), 'TimedCrowdsale: not open'); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { from: investor, value: ether('1') }), + 'TimedCrowdsale: not open' + ); }); it('should accept payments during the sale', async function () { @@ -55,14 +57,16 @@ contract.only('SampleCrowdsale', function ([_, deployer, owner, wallet, investor it('should reject payments after end', async function () { await time.increaseTo(this.afterClosingTime); - await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), "TimedCrowdsale: not open"); - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: ether('1'), from: investor }),"TimedCrowdsale: not open"); + await shouldFail.reverting.withMessage(this.crowdsale.send(ether('1')), 'TimedCrowdsale: not open'); + await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: ether('1'), from: investor }), + 'TimedCrowdsale: not open' + ); }); it('should reject payments over cap', async function () { await time.increaseTo(this.openingTime); await this.crowdsale.send(CAP); - await shouldFail.reverting.withMessage(this.crowdsale.send(1),"CappedCrowdsale: cap exceeded"); + await shouldFail.reverting.withMessage(this.crowdsale.send(1), 'CappedCrowdsale: cap exceeded'); }); it('should allow finalization and transfer funds to wallet if the goal is reached', async function () { @@ -95,7 +99,7 @@ contract.only('SampleCrowdsale', function ([_, deployer, owner, wallet, investor it('creation reverts', async function () { await shouldFail.reverting.withMessage(SampleCrowdsale.new( this.openingTime, this.closingTime, RATE, wallet, CAP, this.token.address, HIGH_GOAL - ), "SampleCrowdSale: goal is greater than cap"); + ), 'SampleCrowdSale: goal is greater than cap'); }); }); }); diff --git a/test/introspection/ERC165.test.js b/test/introspection/ERC165.test.js index 3cb85b6a993..c3f14941a30 100644 --- a/test/introspection/ERC165.test.js +++ b/test/introspection/ERC165.test.js @@ -3,13 +3,13 @@ const { shouldSupportInterfaces } = require('./SupportsInterface.behavior'); const ERC165Mock = artifacts.require('ERC165Mock'); -contract.only('ERC165', function () { +contract('ERC165', function () { beforeEach(async function () { this.mock = await ERC165Mock.new(); }); it('does not allow 0xffffffff', async function () { - await shouldFail.reverting.withMessage(this.mock.registerInterface('0xffffffff'), "ERC165: invalid interface id"); + await shouldFail.reverting.withMessage(this.mock.registerInterface('0xffffffff'), 'ERC165: invalid interface id'); }); shouldSupportInterfaces([ diff --git a/test/lifecycle/Pausable.test.js b/test/lifecycle/Pausable.test.js index 49da097abc6..acd036c2987 100644 --- a/test/lifecycle/Pausable.test.js +++ b/test/lifecycle/Pausable.test.js @@ -3,7 +3,7 @@ const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/Public const PausableMock = artifacts.require('PausableMock'); -contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]) { +contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]) { beforeEach(async function () { this.pausable = await PausableMock.new({ from: pauser }); }); @@ -30,7 +30,9 @@ contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAcco }); it('cannot take drastic measure in non-pause', async function () { - await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }), "Pausable: not paused"); + await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }), + 'Pausable: not paused' + ); (await this.pausable.drasticMeasureTaken()).should.equal(false); }); @@ -41,7 +43,9 @@ contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAcco }); it('reverts when pausing from non-pauser', async function () { - await shouldFail.reverting.withMessage(this.pausable.pause({ from: other }), "PauserRole: caller does not have the Pauser role"); + await shouldFail.reverting.withMessage(this.pausable.pause({ from: other }), + 'PauserRole: caller does not have the Pauser role' + ); }); context('when paused', function () { @@ -54,7 +58,7 @@ contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAcco }); it('cannot perform normal process in pause', async function () { - await shouldFail.reverting.withMessage(this.pausable.normalProcess({ from: other }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.pausable.normalProcess({ from: other }), 'Pausable: paused'); }); it('can take a drastic measure in a pause', async function () { @@ -63,7 +67,7 @@ contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAcco }); it('reverts when re-pausing', async function () { - await shouldFail.reverting.withMessage(this.pausable.pause({ from: pauser }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.pausable.pause({ from: pauser }), 'Pausable: paused'); }); describe('unpausing', function () { @@ -73,7 +77,9 @@ contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAcco }); it('reverts when unpausing from non-pauser', async function () { - await shouldFail.reverting.withMessage(this.pausable.unpause({ from: other }), "PauserRole: caller does not have the Pauser role"); + await shouldFail.reverting.withMessage(this.pausable.unpause({ from: other }), + 'PauserRole: caller does not have the Pauser role' + ); }); context('when unpaused', function () { @@ -92,11 +98,13 @@ contract.only('Pausable', function ([_, pauser, otherPauser, other, ...otherAcco }); it('should prevent drastic measure', async function () { - await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }), "Pausable: not paused"); + await shouldFail.reverting.withMessage(this.pausable.drasticMeasure({ from: other }), + 'Pausable: not paused' + ); }); it('reverts when re-unpausing', async function () { - await shouldFail.reverting.withMessage(this.pausable.unpause({ from: pauser }), "Pausable: not paused"); + await shouldFail.reverting.withMessage(this.pausable.unpause({ from: pauser }), 'Pausable: not paused'); }); }); }); diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index c4395c73226..001900278b0 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -3,7 +3,7 @@ const { MAX_UINT256 } = constants; const SafeMathMock = artifacts.require('SafeMathMock'); -contract.only('SafeMath', function () { +contract('SafeMath', function () { beforeEach(async function () { this.safeMath = await SafeMathMock.new(); }); @@ -14,7 +14,7 @@ contract.only('SafeMath', function () { } async function testFailsCommutative (fn, lhs, rhs) { - //TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages + // TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages await shouldFail.reverting.withMessage(fn(lhs, rhs)); await shouldFail.reverting.withMessage(fn(rhs, lhs)); } @@ -47,7 +47,7 @@ contract.only('SafeMath', function () { const a = new BN('1234'); const b = new BN('5678'); - await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.safeMath.sub(a, b), 'SafeMath: subtraction overflow'); }); }); @@ -100,7 +100,7 @@ contract.only('SafeMath', function () { const a = new BN('5678'); const b = new BN('0'); - await shouldFail.reverting.withMessage(this.safeMath.div(a, b), "SafeMath: division by zero"); + await shouldFail.reverting.withMessage(this.safeMath.div(a, b), 'SafeMath: division by zero'); }); }); @@ -139,7 +139,7 @@ contract.only('SafeMath', function () { const a = new BN('5678'); const b = new BN('0'); - await shouldFail.reverting.withMessage(this.safeMath.mod(a, b), "SafeMath: modulo by zero"); + await shouldFail.reverting.withMessage(this.safeMath.mod(a, b), 'SafeMath: modulo by zero'); }); }); }); diff --git a/test/ownership/Secondary.test.js b/test/ownership/Secondary.test.js index f7a1695a6bc..2039f750e0c 100644 --- a/test/ownership/Secondary.test.js +++ b/test/ownership/Secondary.test.js @@ -3,7 +3,7 @@ const { ZERO_ADDRESS } = constants; const SecondaryMock = artifacts.require('SecondaryMock'); -contract.only('Secondary', function ([_, primary, newPrimary, other]) { +contract('Secondary', function ([_, primary, newPrimary, other]) { beforeEach(async function () { this.secondary = await SecondaryMock.new({ from: primary }); }); @@ -18,7 +18,9 @@ contract.only('Secondary', function ([_, primary, newPrimary, other]) { }); it('reverts when anyone calls onlyPrimary functions', async function () { - await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: other }), "Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: other }), + 'Secondary: caller is not the primary account' + ); }); }); @@ -30,11 +32,15 @@ contract.only('Secondary', function ([_, primary, newPrimary, other]) { }); it('reverts when transferring to the null address', async function () { - await shouldFail.reverting.withMessage(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }), "Secondary: new primary is the zero address"); + await shouldFail.reverting.withMessage(this.secondary.transferPrimary(ZERO_ADDRESS, { from: primary }), + 'Secondary: new primary is the zero address' + ); }); it('reverts when called by anyone', async function () { - await shouldFail.reverting.withMessage(this.secondary.transferPrimary(newPrimary, { from: other }), "Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.secondary.transferPrimary(newPrimary, { from: other }), + 'Secondary: caller is not the primary account' + ); }); context('with new primary', function () { @@ -47,7 +53,9 @@ contract.only('Secondary', function ([_, primary, newPrimary, other]) { }); it('reverts when the old primary account calls onlyPrimary functions', async function () { - await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: primary }), "Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.secondary.onlyPrimaryMock({ from: primary }), + 'Secondary: caller is not the primary account' + ); }); }); }); diff --git a/test/payment/PaymentSplitter.test.js b/test/payment/PaymentSplitter.test.js index d958447900b..15e458f3af5 100644 --- a/test/payment/PaymentSplitter.test.js +++ b/test/payment/PaymentSplitter.test.js @@ -3,31 +3,41 @@ const { ZERO_ADDRESS } = constants; const PaymentSplitter = artifacts.require('PaymentSplitter'); -contract.only('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { +contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) { const amount = ether('1'); it('rejects an empty set of payees', async function () { - await shouldFail.reverting.withMessage(PaymentSplitter.new([], []), "PaymentSplitter: no payees"); + await shouldFail.reverting.withMessage(PaymentSplitter.new([], []), 'PaymentSplitter: no payees'); }); it('rejects more payees than shares', async function () { - await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2, payee3], [20, 30]), "PaymentSplitter: payees and shares length mismatch"); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2, payee3], [20, 30]), + 'PaymentSplitter: payees and shares length mismatch' + ); }); it('rejects more shares than payees', async function () { - await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 30, 40]), "PaymentSplitter: payees and shares length mismatch"); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 30, 40]), + 'PaymentSplitter: payees and shares length mismatch' + ); }); it('rejects null payees', async function () { - await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, ZERO_ADDRESS], [20, 30]), "PaymentSplitter: account is the zero address"); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, ZERO_ADDRESS], [20, 30]), + 'PaymentSplitter: account is the zero address' + ); }); it('rejects zero-valued shares', async function () { - await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 0]), "PaymentSplitter: shares are 0"); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee2], [20, 0]), + 'PaymentSplitter: shares are 0' + ); }); it('rejects repeated payees', async function () { - await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee1], [20, 30]), "PaymentSplitter: account already has shares"); + await shouldFail.reverting.withMessage(PaymentSplitter.new([payee1, payee1], [20, 30]), + 'PaymentSplitter: account already has shares' + ); }); context('once deployed', function () { @@ -64,12 +74,16 @@ contract.only('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, no }); it('should throw if no funds to claim', async function () { - await shouldFail.reverting.withMessage(this.contract.release(payee1), "PaymentSplitter: account is not due payment"); + await shouldFail.reverting.withMessage(this.contract.release(payee1), + 'PaymentSplitter: account is not due payment' + ); }); it('should throw if non-payee want to claim', async function () { await send.ether(payer1, this.contract.address, amount); - await shouldFail.reverting.withMessage(this.contract.release(nonpayee1), "PaymentSplitter: account has no shares"); + await shouldFail.reverting.withMessage(this.contract.release(nonpayee1), + 'PaymentSplitter: account has no shares' + ); }); it('should distribute funds to payees', async function () { diff --git a/test/payment/escrow/ConditionalEscrow.test.js b/test/payment/escrow/ConditionalEscrow.test.js index 40e418e2ff7..aa27477c72b 100644 --- a/test/payment/escrow/ConditionalEscrow.test.js +++ b/test/payment/escrow/ConditionalEscrow.test.js @@ -26,7 +26,7 @@ contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) { it('reverts on withdrawals', async function () { await this.escrow.deposit(payee, { from: owner, value: amount }); - await shouldFail.reverting.withMessage(this.escrow.withdraw(payee, { from: owner }), "Failure message"); + await shouldFail.reverting.withMessage(this.escrow.withdraw(payee, { from: owner }), 'Failure message'); }); }); }); diff --git a/test/payment/escrow/Escrow.behavior.js b/test/payment/escrow/Escrow.behavior.js index 53bad8a2d9f..f6c65fc02df 100644 --- a/test/payment/escrow/Escrow.behavior.js +++ b/test/payment/escrow/Escrow.behavior.js @@ -18,7 +18,9 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { }); it('only the primary account can deposit', async function () { - await shouldFail.reverting.withMessage(this.escrow.deposit(payee1, { from: payee2 }), "Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.escrow.deposit(payee1, { from: payee2 }), + 'Secondary: caller is not the primary account' + ); }); it('emits a deposited event', async function () { @@ -68,7 +70,9 @@ function shouldBehaveLikeEscrow (primary, [payee1, payee2]) { }); it('only the primary account can withdraw', async function () { - await shouldFail.reverting.withMessage(this.escrow.withdraw(payee1, { from: payee1 }), "Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.escrow.withdraw(payee1, { from: payee1 }), + 'Secondary: caller is not the primary account' + ); }); it('emits a withdrawn event', async function () { diff --git a/test/payment/escrow/Escrow.test.js b/test/payment/escrow/Escrow.test.js index 33e10b2d852..b7b9a29c018 100644 --- a/test/payment/escrow/Escrow.test.js +++ b/test/payment/escrow/Escrow.test.js @@ -3,7 +3,7 @@ const { shouldBehaveLikeEscrow } = require('./Escrow.behavior'); const Escrow = artifacts.require('Escrow'); -contract.only('Escrow', function ([_, primary, ...otherAccounts]) { +contract('Escrow', function ([_, primary, ...otherAccounts]) { beforeEach(async function () { this.escrow = await Escrow.new({ from: primary }); }); diff --git a/test/payment/escrow/RefundEscrow.test.js b/test/payment/escrow/RefundEscrow.test.js index 664995eb1ab..8559c7997c1 100644 --- a/test/payment/escrow/RefundEscrow.test.js +++ b/test/payment/escrow/RefundEscrow.test.js @@ -3,13 +3,13 @@ const { ZERO_ADDRESS } = constants; const RefundEscrow = artifacts.require('RefundEscrow'); -contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) { +contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) { const amount = ether('54'); const refundees = [refundee1, refundee2]; it('requires a non-null beneficiary', async function () { await shouldFail.reverting.withMessage( - RefundEscrow.new(ZERO_ADDRESS, { from: primary }), "RefundEscrow: beneficiary is the zero address" + RefundEscrow.new(ZERO_ADDRESS, { from: primary }), 'RefundEscrow: beneficiary is the zero address' ); }); @@ -32,17 +32,23 @@ contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, ref it('does not refund refundees', async function () { await this.escrow.deposit(refundee1, { from: primary, value: amount }); - await shouldFail.reverting.withMessage(this.escrow.withdraw(refundee1), "ConditionalEscrow: payee is not allowed to withdraw"); + await shouldFail.reverting.withMessage(this.escrow.withdraw(refundee1), + 'ConditionalEscrow: payee is not allowed to withdraw' + ); }); it('does not allow beneficiary withdrawal', async function () { await this.escrow.deposit(refundee1, { from: primary, value: amount }); - await shouldFail.reverting.withMessage(this.escrow.beneficiaryWithdraw(), "RefundEscrow: beneficiary can only withdraw while closed"); + await shouldFail.reverting.withMessage(this.escrow.beneficiaryWithdraw(), + 'RefundEscrow: beneficiary can only withdraw while closed' + ); }); }); it('only the primary account can enter closed state', async function () { - await shouldFail.reverting.withMessage(this.escrow.close({ from: beneficiary }), "Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.escrow.close({ from: beneficiary }), + 'Secondary: caller is not the primary account' + ); const { logs } = await this.escrow.close({ from: primary }); expectEvent.inLogs(logs, 'RefundsClosed'); @@ -56,11 +62,15 @@ contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, ref }); it('rejects deposits', async function () { - await shouldFail.reverting.withMessage(this.escrow.deposit(refundee1, { from: primary, value: amount }), "RefundEscrow: can only deposit while active"); + await shouldFail.reverting.withMessage(this.escrow.deposit(refundee1, { from: primary, value: amount }), + 'RefundEscrow: can only deposit while active' + ); }); it('does not refund refundees', async function () { - await shouldFail.reverting.withMessage(this.escrow.withdraw(refundee1),"ConditionalEscrow: payee is not allowed to withdraw"); + await shouldFail.reverting.withMessage(this.escrow.withdraw(refundee1), + 'ConditionalEscrow: payee is not allowed to withdraw' + ); }); it('allows beneficiary withdrawal', async function () { @@ -70,16 +80,22 @@ contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, ref }); it('prevents entering the refund state', async function () { - await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: primary }),"RefundEscrow: can only enable refunds while active"); + await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: primary }), + 'RefundEscrow: can only enable refunds while active' + ); }); it('prevents re-entering the closed state', async function () { - await shouldFail.reverting.withMessage(this.escrow.close({ from: primary }),"RefundEscrow: can only close while active"); + await shouldFail.reverting.withMessage(this.escrow.close({ from: primary }), + 'RefundEscrow: can only close while active' + ); }); }); it('only the primary account can enter refund state', async function () { - await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: beneficiary }),"Secondary: caller is not the primary account"); + await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: beneficiary }), + 'Secondary: caller is not the primary account' + ); const { logs } = await this.escrow.enableRefunds({ from: primary }); expectEvent.inLogs(logs, 'RefundsEnabled'); @@ -93,7 +109,9 @@ contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, ref }); it('rejects deposits', async function () { - await shouldFail.reverting.withMessage(this.escrow.deposit(refundee1, { from: primary, value: amount }),"RefundEscrow: can only deposit while active"); + await shouldFail.reverting.withMessage(this.escrow.deposit(refundee1, { from: primary, value: amount }), + 'RefundEscrow: can only deposit while active' + ); }); it('refunds refundees', async function () { @@ -105,15 +123,21 @@ contract.only('RefundEscrow', function ([_, primary, beneficiary, refundee1, ref }); it('does not allow beneficiary withdrawal', async function () { - await shouldFail.reverting.withMessage(this.escrow.beneficiaryWithdraw(),"RefundEscrow: beneficiary can only withdraw while closed"); + await shouldFail.reverting.withMessage(this.escrow.beneficiaryWithdraw(), + 'RefundEscrow: beneficiary can only withdraw while closed' + ); }); it('prevents entering the closed state', async function () { - await shouldFail.reverting.withMessage(this.escrow.close({ from: primary }),"RefundEscrow: can only close while active"); + await shouldFail.reverting.withMessage(this.escrow.close({ from: primary }), + 'RefundEscrow: can only close while active' + ); }); it('prevents re-entering the refund state', async function () { - await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: primary }),"RefundEscrow: can only enable refunds while active"); + await shouldFail.reverting.withMessage(this.escrow.enableRefunds({ from: primary }), + 'RefundEscrow: can only enable refunds while active' + ); }); }); }); diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 9cc6641459e..f61ede6b1e6 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -3,7 +3,7 @@ const { ZERO_ADDRESS } = constants; const ERC20Mock = artifacts.require('ERC20Mock'); -contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { +contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { const initialSupply = new BN(100); beforeEach(async function () { this.token = await ERC20Mock.new(initialHolder, initialSupply); @@ -37,7 +37,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const amount = initialSupply.addn(1); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.transfer(to, amount, { from: initialHolder }),"SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.transfer(to, amount, { from: initialHolder }), + 'SafeMath: subtraction overflow' + ); }); }); @@ -68,7 +70,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const to = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.transfer(to, initialSupply, { from: initialHolder }), "ERC20: transfer to the zero address"); + await shouldFail.reverting.withMessage(this.token.transfer(to, initialSupply, { from: initialHolder }), + 'ERC20: transfer to the zero address' + ); }); }); }); @@ -126,7 +130,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const amount = initialSupply.addn(1); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.transferFrom( + initialHolder, to, amount, { from: spender }), 'SafeMath: subtraction overflow' + ); }); }); }); @@ -140,7 +146,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const amount = initialSupply; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.transferFrom( + initialHolder, to, amount, { from: spender }), 'SafeMath: subtraction overflow' + ); }); }); @@ -148,7 +156,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const amount = initialSupply.addn(1); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.transferFrom( + initialHolder, to, amount, { from: spender }), 'SafeMath: subtraction overflow' + ); }); }); }); @@ -163,7 +173,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) }); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.transferFrom(initialHolder, to, amount, { from: spender }, "ERC20: transfer to the zero address")); + await shouldFail.reverting.withMessage(this.token.transferFrom( + initialHolder, to, amount, { from: spender }), 'ERC20: transfer to the zero address' + ); }); }); }); @@ -175,7 +187,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) function shouldDecreaseApproval (amount) { describe('when there was no approved amount before', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.decreaseAllowance(spender, amount, { from: initialHolder }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.decreaseAllowance( + spender, amount, { from: initialHolder }), 'SafeMath: subtraction overflow' + ); }); }); @@ -209,7 +223,7 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) it('reverts when more than the full allowance is removed', async function () { await shouldFail.reverting.withMessage( - this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }, "no idea") + this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }, 'no idea') ); }); }); @@ -233,7 +247,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const spender = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.decreaseAllowance(spender, amount, { from: initialHolder }, "ERC20: approve to the zero address")); + await shouldFail.reverting.withMessage(this.token.decreaseAllowance( + spender, amount, { from: initialHolder }, 'ERC20: approve to the zero address') + ); }); }); }); @@ -315,7 +331,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const spender = ZERO_ADDRESS; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.increaseAllowance(spender, amount, { from: initialHolder }), "ERC20: approve to the zero address"); + await shouldFail.reverting.withMessage( + this.token.increaseAllowance(spender, amount, { from: initialHolder }), 'ERC20: approve to the zero address' + ); }); }); }); @@ -324,7 +342,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) const amount = new BN(50); it('rejects a null account', async function () { - await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, amount), "ERC20: mint to the zero address"); + await shouldFail.reverting.withMessage( + this.token.mint(ZERO_ADDRESS, amount), 'ERC20: mint to the zero address' + ); }); describe('for a non null account', function () { @@ -355,12 +375,15 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) describe('_burn', function () { it('rejects a null account', async function () { - await shouldFail.reverting.withMessage(this.token.burn(ZERO_ADDRESS, new BN(1)), "ERC20: burn from the zero address"); + await shouldFail.reverting.withMessage(this.token.burn(ZERO_ADDRESS, new BN(1)), + 'ERC20: burn from the zero address'); }); describe('for a non null account', function () { it('rejects burning more than balance', async function () { - await shouldFail.reverting.withMessage(this.token.burn(initialHolder, initialSupply.addn(1)), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.burn( + initialHolder, initialSupply.addn(1)), 'SafeMath: subtraction overflow' + ); }); const describeBurn = function (description, amount) { @@ -406,16 +429,22 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) }); it('rejects a null account', async function () { - await shouldFail.reverting.withMessage(this.token.burnFrom(ZERO_ADDRESS, new BN(1)), "ERC20: burn from the zero address"); + await shouldFail.reverting.withMessage(this.token.burnFrom(ZERO_ADDRESS, new BN(1)), + 'ERC20: burn from the zero address' + ); }); describe('for a non null account', function () { it('rejects burning more than allowance', async function () { - await shouldFail.reverting.withMessage(this.token.burnFrom(initialHolder, allowance.addn(1)), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.burnFrom(initialHolder, allowance.addn(1)), + 'SafeMath: subtraction overflow' + ); }); it('rejects burning more than balance', async function () { - await shouldFail.reverting.withMessage(this.token.burnFrom(initialHolder, initialSupply.addn(1)), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.burnFrom(initialHolder, initialSupply.addn(1)), + 'SafeMath: subtraction overflow' + ); }); const describeBurnFrom = function (description, amount) { @@ -477,7 +506,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) describe('when the owner is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.approveInternal(ZERO_ADDRESS, recipient, initialSupply), "ERC20: approve from the zero address"); + await shouldFail.reverting.withMessage(this.token.approveInternal(ZERO_ADDRESS, recipient, initialSupply), + 'ERC20: approve from the zero address' + ); }); }); }); @@ -555,7 +586,9 @@ contract.only('ERC20', function ([_, initialHolder, recipient, anotherAccount]) describe('when the spender is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(approve.call(this, owner, ZERO_ADDRESS, supply), "ERC20: approve to the zero address"); + await shouldFail.reverting.withMessage(approve.call(this, owner, ZERO_ADDRESS, supply), + 'ERC20: approve to the zero address' + ); }); }); } diff --git a/test/token/ERC20/ERC20Burnable.test.js b/test/token/ERC20/ERC20Burnable.test.js index 24b0f83d050..62499183868 100644 --- a/test/token/ERC20/ERC20Burnable.test.js +++ b/test/token/ERC20/ERC20Burnable.test.js @@ -3,7 +3,7 @@ const { BN } = require('openzeppelin-test-helpers'); const { shouldBehaveLikeERC20Burnable } = require('./behaviors/ERC20Burnable.behavior'); const ERC20BurnableMock = artifacts.require('ERC20BurnableMock'); -contract.only('ERC20Burnable', function ([_, owner, ...otherAccounts]) { +contract('ERC20Burnable', function ([_, owner, ...otherAccounts]) { const initialBalance = new BN(1000); beforeEach(async function () { diff --git a/test/token/ERC20/ERC20Capped.test.js b/test/token/ERC20/ERC20Capped.test.js index 214783c312a..2f4c7c3a1c4 100644 --- a/test/token/ERC20/ERC20Capped.test.js +++ b/test/token/ERC20/ERC20Capped.test.js @@ -4,12 +4,12 @@ const { shouldBehaveLikeERC20Capped } = require('./behaviors/ERC20Capped.behavio const ERC20Capped = artifacts.require('ERC20Capped'); -contract.only('ERC20Capped', function ([_, minter, ...otherAccounts]) { +contract('ERC20Capped', function ([_, minter, ...otherAccounts]) { const cap = ether('1000'); it('requires a non-zero cap', async function () { await shouldFail.reverting.withMessage( - ERC20Capped.new(new BN(0), { from: minter }), "ERC20Capped: cap is 0" + ERC20Capped.new(new BN(0), { from: minter }), 'ERC20Capped: cap is 0' ); }); diff --git a/test/token/ERC20/ERC20Detailed.test.js b/test/token/ERC20/ERC20Detailed.test.js index 02655e70fc1..1978350b266 100644 --- a/test/token/ERC20/ERC20Detailed.test.js +++ b/test/token/ERC20/ERC20Detailed.test.js @@ -2,7 +2,7 @@ const { BN } = require('openzeppelin-test-helpers'); const ERC20DetailedMock = artifacts.require('ERC20DetailedMock'); -contract.only('ERC20Detailed', function () { +contract('ERC20Detailed', function () { const _name = 'My Detailed ERC20'; const _symbol = 'MDT'; const _decimals = new BN(18); diff --git a/test/token/ERC20/ERC20Mintable.test.js b/test/token/ERC20/ERC20Mintable.test.js index 8168bd90cfc..659276ddd23 100644 --- a/test/token/ERC20/ERC20Mintable.test.js +++ b/test/token/ERC20/ERC20Mintable.test.js @@ -2,7 +2,7 @@ const { shouldBehaveLikeERC20Mintable } = require('./behaviors/ERC20Mintable.beh const ERC20MintableMock = artifacts.require('ERC20MintableMock'); const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior'); -contract.only('ERC20Mintable', function ([_, minter, otherMinter, ...otherAccounts]) { +contract('ERC20Mintable', function ([_, minter, otherMinter, ...otherAccounts]) { beforeEach(async function () { this.token = await ERC20MintableMock.new({ from: minter }); }); diff --git a/test/token/ERC20/ERC20Pausable.test.js b/test/token/ERC20/ERC20Pausable.test.js index 707cbe1941b..9b9f2bedb19 100644 --- a/test/token/ERC20/ERC20Pausable.test.js +++ b/test/token/ERC20/ERC20Pausable.test.js @@ -3,7 +3,7 @@ const { BN, expectEvent, shouldFail } = require('openzeppelin-test-helpers'); const ERC20PausableMock = artifacts.require('ERC20PausableMock'); const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior'); -contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherAccount, ...otherAccounts]) { +contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherAccount, ...otherAccounts]) { const initialSupply = new BN(100); beforeEach(async function () { @@ -42,7 +42,7 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano }); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.pause({ from }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.token.pause({ from }), 'Pausable: paused'); }); }); }); @@ -51,7 +51,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano const from = anotherAccount; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.pause({ from }), "PauserRole: caller does not have the Pauser role"); + await shouldFail.reverting.withMessage(this.token.pause({ from }), + 'PauserRole: caller does not have the Pauser role' + ); }); }); }); @@ -79,7 +81,7 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano describe('when the token is unpaused', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.unpause({ from }), "Pausable: not paused"); + await shouldFail.reverting.withMessage(this.token.unpause({ from }), 'Pausable: not paused'); }); }); }); @@ -88,7 +90,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano const from = anotherAccount; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.unpause({ from }), "PauserRole: caller does not have the Pauser role"); + await shouldFail.reverting.withMessage(this.token.unpause({ from }), + 'PauserRole: caller does not have the Pauser role' + ); }); }); }); @@ -134,7 +138,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano it('reverts when trying to transfer when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting.withMessage(this.token.transfer(recipient, initialSupply, { from: pauser }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.token.transfer(recipient, initialSupply, { from: pauser }), + 'Pausable: paused' + ); }); }); @@ -159,7 +165,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano it('reverts when trying to approve when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting.withMessage(this.token.approve(anotherAccount, allowance, { from: pauser }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.token.approve(anotherAccount, allowance, { from: pauser }), + 'Pausable: paused' + ); }); }); @@ -190,7 +198,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano it('reverts when trying to transfer from when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting.withMessage(this.token.transferFrom(pauser, recipient, allowance, { from: anotherAccount }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.token.transferFrom( + pauser, recipient, allowance, { from: anotherAccount }), 'Pausable: paused' + ); }); }); @@ -220,7 +230,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano it('reverts when trying to transfer when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting.withMessage(this.token.decreaseAllowance(anotherAccount, decrement, { from: pauser }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.token.decreaseAllowance( + anotherAccount, decrement, { from: pauser }), 'Pausable: paused' + ); }); }); @@ -250,7 +262,9 @@ contract.only('ERC20Pausable', function ([_, pauser, otherPauser, recipient, ano it('reverts when trying to increase approval when paused', async function () { await this.token.pause({ from: pauser }); - await shouldFail.reverting.withMessage(this.token.increaseAllowance(anotherAccount, increment, { from: pauser }), "Pausable: paused"); + await shouldFail.reverting.withMessage(this.token.increaseAllowance( + anotherAccount, increment, { from: pauser }), 'Pausable: paused' + ); }); }); }); diff --git a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js index 8afd52359e3..45f3f9c1a17 100644 --- a/test/token/ERC20/behaviors/ERC20Burnable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Burnable.behavior.js @@ -35,7 +35,9 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { const amount = initialBalance.addn(1); it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.burn(amount, { from: owner }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.burn(amount, { from: owner }), + 'SafeMath: subtraction overflow' + ); }); }); }); @@ -82,7 +84,9 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { it('reverts', async function () { await this.token.approve(burner, amount, { from: owner }); - await shouldFail.reverting.withMessage(this.token.burnFrom(owner, amount, { from: burner }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.burnFrom(owner, amount, { from: burner }), + 'SafeMath: subtraction overflow' + ); }); }); @@ -91,7 +95,9 @@ function shouldBehaveLikeERC20Burnable (owner, initialBalance, [burner]) { it('reverts', async function () { await this.token.approve(burner, allowance, { from: owner }); - await shouldFail.reverting.withMessage(this.token.burnFrom(owner, allowance.addn(1), { from: burner }), "SafeMath: subtraction overflow"); + await shouldFail.reverting.withMessage(this.token.burnFrom(owner, allowance.addn(1), { from: burner }), + 'SafeMath: subtraction overflow' + ); }); }); }); diff --git a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js index f3f470c4d83..2c658868e3d 100644 --- a/test/token/ERC20/behaviors/ERC20Mintable.behavior.js +++ b/test/token/ERC20/behaviors/ERC20Mintable.behavior.js @@ -40,7 +40,9 @@ function shouldBehaveLikeERC20Mintable (minter, [other]) { const from = other; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.mint(other, amount, { from }), "MinterRole: caller does not have the Minter role"); + await shouldFail.reverting.withMessage(this.token.mint(other, amount, { from }), + 'MinterRole: caller does not have the Minter role' + ); }); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 29421947409..c0a51114338 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -36,7 +36,9 @@ function shouldBehaveLikeERC721 ( context('when querying the zero address', function () { it('throws', async function () { - await shouldFail.reverting.withMessage(this.token.balanceOf(ZERO_ADDRESS)); + await shouldFail.reverting.withMessage( + this.token.balanceOf(ZERO_ADDRESS), 'ERC721: balance query for the zero address' + ); }); }); }); @@ -54,7 +56,9 @@ function shouldBehaveLikeERC721 ( const tokenId = unknownTokenId; it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage( + this.token.ownerOf(tokenId), 'ERC721: owner query of nonexistent token' + ); }); }); }); @@ -178,21 +182,26 @@ function shouldBehaveLikeERC721 ( context('when the address of the previous owner is incorrect', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(transferFunction.call(this, other, other, tokenId, { from: owner }) + await shouldFail.reverting.withMessage( + transferFunction.call(this, other, other, tokenId, { from: owner }), 'ERC721: transfer of unowned token' ); }); }); context('when the sender is not authorized for the token id', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(transferFunction.call(this, owner, other, tokenId, { from: other }) + await shouldFail.reverting.withMessage( + transferFunction.call(this, owner, other, tokenId, { from: other }), + 'ERC721: transfer caller is not owner nor approved' ); }); }); context('when the given token ID does not exist', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(transferFunction.call(this, owner, other, unknownTokenId, { from: owner }) + await shouldFail.reverting.withMessage( + transferFunction.call(this, owner, other, unknownTokenId, { from: owner }), + 'about airtel' ); }); }); @@ -200,7 +209,8 @@ function shouldBehaveLikeERC721 ( context('when the address to transfer the token to is the zero address', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - transferFunction.call(this, owner, ZERO_ADDRESS, tokenId, { from: owner }) + transferFunction.call(this, owner, ZERO_ADDRESS, tokenId, { from: owner }), + 'ERC721: transfer to the zero address' ); }); }); @@ -265,7 +275,8 @@ function shouldBehaveLikeERC721 ( this.receiver.address, unknownTokenId, { from: owner }, - ) + ), + 'ERC721: operator query for nonexistent token' ); }); }); @@ -284,7 +295,8 @@ function shouldBehaveLikeERC721 ( it('reverts', async function () { const invalidReceiver = await ERC721ReceiverMock.new('0x42', false); await shouldFail.reverting.withMessage( - this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }) + this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }), + 'ERC721: transfer to non ERC721Receiver implementer' ); }); }); @@ -293,7 +305,8 @@ function shouldBehaveLikeERC721 ( it('reverts', async function () { const invalidReceiver = await ERC721ReceiverMock.new(RECEIVER_MAGIC_VALUE, true); await shouldFail.reverting.withMessage( - this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }) + this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }), + 'ERC721ReceiverMock: reverting' ); }); }); @@ -302,7 +315,8 @@ function shouldBehaveLikeERC721 ( it('reverts', async function () { const invalidReceiver = this.token; await shouldFail.reverting.withMessage( - this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }) + this.token.safeTransferFrom(owner, invalidReceiver.address, tokenId, { from: owner }), + 'VM Exception while processing transaction: revert' ); }); }); @@ -391,21 +405,23 @@ function shouldBehaveLikeERC721 ( context('when the address that receives the approval is the owner', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - this.token.approve(owner, tokenId, { from: owner }) + this.token.approve(owner, tokenId, { from: owner }), 'ERC721: transfer to current owner' ); }); }); context('when the sender does not own the given token ID', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.approve(approved, tokenId, { from: other })); + await shouldFail.reverting.withMessage(this.token.approve(approved, tokenId, { from: other }), + 'ERC721: approve caller is not owner nor approved'); }); }); context('when the sender is approved for the given token ID', function () { it('reverts', async function () { await this.token.approve(approved, tokenId, { from: owner }); - await shouldFail.reverting.withMessage(this.token.approve(anotherApproved, tokenId, { from: approved })); + await shouldFail.reverting.withMessage(this.token.approve(anotherApproved, tokenId, { from: approved }), + 'ERC721: approve caller is not owner nor approved'); }); }); @@ -421,7 +437,8 @@ function shouldBehaveLikeERC721 ( context('when the given token ID does not exist', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.approve(approved, unknownTokenId, { from: operator })); + await shouldFail.reverting.withMessage(this.token.approve(approved, unknownTokenId, { from: operator }), + 'ERC721: owner query of nonexistent token'); }); }); }); @@ -499,7 +516,8 @@ function shouldBehaveLikeERC721 ( context('when the operator is the owner', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.setApprovalForAll(owner, true, { from: owner })); + await shouldFail.reverting.withMessage(this.token.setApprovalForAll(owner, true, { from: owner }), + 'ERC721: approve to caller'); }); }); }); diff --git a/test/token/ERC721/ERC721.test.js b/test/token/ERC721/ERC721.test.js index 50945deddb0..9f2ddc16d47 100644 --- a/test/token/ERC721/ERC721.test.js +++ b/test/token/ERC721/ERC721.test.js @@ -4,7 +4,7 @@ const { ZERO_ADDRESS } = constants; const { shouldBehaveLikeERC721 } = require('./ERC721.behavior'); const ERC721Mock = artifacts.require('ERC721Mock.sol'); -contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { +contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { beforeEach(async function () { this.token = await ERC721Mock.new({ from: creator }); }); @@ -16,7 +16,9 @@ contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) describe('_mint(address, uint256)', function () { it('reverts with a null destination address', async function () { - await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, tokenId), "ERC721: mint to the zero address"); + await shouldFail.reverting.withMessage( + this.token.mint(ZERO_ADDRESS, tokenId), 'ERC721: mint to the zero address' + ); }); context('with minted token', async function () { @@ -34,14 +36,16 @@ contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) }); it('reverts when adding a token id that already exists', async function () { - await shouldFail.reverting.withMessage(this.token.mint(tokenOwner, tokenId), "ERC721: token already minted"); + await shouldFail.reverting.withMessage(this.token.mint(tokenOwner, tokenId), 'ERC721: token already minted'); }); }); }); describe('_burn(address, uint256)', function () { it('reverts when burning a non-existent token id', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), "ERC721: owner query of nonexistent token"); + await shouldFail.reverting.withMessage( + this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), 'ERC721: owner query of nonexistent token' + ); }); context('with minted token', function () { @@ -50,7 +54,9 @@ contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) }); it('reverts when the account is not the owner', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](other, tokenId), "ERC721: burn of unowned token"); + await shouldFail.reverting.withMessage( + this.token.methods['burn(address,uint256)'](other, tokenId), 'ERC721: burn of unowned token' + ); }); context('with burnt token', function () { @@ -64,11 +70,16 @@ contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); - await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId), "ERC721: owner query of nonexistent token"); + await shouldFail.reverting.withMessage( + this.token.ownerOf(tokenId), 'ERC721: owner query of nonexistent token' + ); }); it('reverts when burning a token id that has been deleted', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), "ERC721: owner query of nonexistent token"); + await shouldFail.reverting.withMessage( + this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), + 'ERC721: owner query of nonexistent token' + ); }); }); }); @@ -76,7 +87,9 @@ contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) describe('_burn(uint256)', function () { it('reverts when burning a non-existent token id', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId), "ERC721: owner query of nonexistent token"); + await shouldFail.reverting.withMessage( + this.token.methods['burn(uint256)'](tokenId), 'ERC721: owner query of nonexistent token' + ); }); context('with minted token', function () { @@ -95,11 +108,15 @@ contract.only('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); - await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId), "ERC721: owner query of nonexistent token"); + await shouldFail.reverting.withMessage( + this.token.ownerOf(tokenId), 'ERC721: owner query of nonexistent token' + ); }); it('reverts when burning a token id that has been deleted', async function () { - await shouldFail.reverting.withMessage(this.token.methods['burn(uint256)'](tokenId), "ERC721: owner query of nonexistent token"); + await shouldFail.reverting.withMessage( + this.token.methods['burn(uint256)'](tokenId), 'ERC721: owner query of nonexistent token' + ); }); }); }); diff --git a/test/token/ERC721/ERC721Full.test.js b/test/token/ERC721/ERC721Full.test.js index d5e1087c59f..d166d5b4921 100644 --- a/test/token/ERC721/ERC721Full.test.js +++ b/test/token/ERC721/ERC721Full.test.js @@ -64,7 +64,9 @@ contract('ERC721Full', function ([ it('burns all tokens', async function () { await this.token.burn(secondTokenId, { from: owner }); (await this.token.totalSupply()).should.be.bignumber.equal('0'); - await shouldFail.reverting.withMessage(this.token.tokenByIndex(0)); + await shouldFail.reverting.withMessage( + this.token.tokenByIndex(0), 'ERC721Enumerable: global index out of bounds' + ); }); }); @@ -85,7 +87,9 @@ contract('ERC721Full', function ([ }); it('reverts when setting metadata for non existent token id', async function () { - await shouldFail.reverting.withMessage(this.token.setTokenURI(nonExistentTokenId, sampleUri)); + await shouldFail.reverting.withMessage( + this.token.setTokenURI(nonExistentTokenId, sampleUri), 'ERC721Metadata: URI set of nonexistent token' + ); }); it('can burn token with metadata', async function () { @@ -99,7 +103,9 @@ contract('ERC721Full', function ([ }); it('reverts when querying metadata for non existent token id', async function () { - await shouldFail.reverting.withMessage(this.token.tokenURI(nonExistentTokenId)); + await shouldFail.reverting.withMessage( + this.token.tokenURI(nonExistentTokenId), 'ERC721Metadata: query of nonexistent token' + ); }); }); @@ -127,13 +133,17 @@ contract('ERC721Full', function ([ describe('when the index is greater than or equal to the total tokens owned by the given address', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.tokenOfOwnerByIndex(owner, 2)); + await shouldFail.reverting.withMessage( + this.token.tokenOfOwnerByIndex(owner, 2), 'ERC721Enumerable: owner index out of bounds' + ); }); }); describe('when the given address does not own any token', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.tokenOfOwnerByIndex(another, 0)); + await shouldFail.reverting.withMessage( + this.token.tokenOfOwnerByIndex(another, 0), 'ERC721Enumerable: owner index out of bounds' + ); }); }); @@ -153,7 +163,9 @@ contract('ERC721Full', function ([ it('returns empty collection for original owner', async function () { (await this.token.balanceOf(owner)).should.be.bignumber.equal('0'); - await shouldFail.reverting.withMessage(this.token.tokenOfOwnerByIndex(owner, 0)); + await shouldFail.reverting.withMessage( + this.token.tokenOfOwnerByIndex(owner, 0), 'ERC721Enumerable: owner index out of bounds' + ); }); }); }); @@ -167,7 +179,9 @@ contract('ERC721Full', function ([ }); it('should revert if index is greater than supply', async function () { - await shouldFail.reverting.withMessage(this.token.tokenByIndex(2)); + await shouldFail.reverting.withMessage( + this.token.tokenByIndex(2), 'ERC721Enumerable: global index out of bounds' + ); }); [firstTokenId, secondTokenId].forEach(function (tokenId) { diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index 7edb29aace2..b092c0faa02 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -46,13 +46,16 @@ function shouldBehaveLikeMintAndBurnERC721 ( describe('when the given owner address is the zero address', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter })); + await shouldFail.reverting.withMessage( + this.token.mint(ZERO_ADDRESS, thirdTokenId, { from: minter }), + 'ERC721: mint to the zero address' + ); }); }); describe('when the given token ID was already tracked by this contract', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter })); + await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter }), 'no idea'); }); }); }); @@ -76,7 +79,10 @@ function shouldBehaveLikeMintAndBurnERC721 ( }); it('burns the given token ID and adjusts the balance of the owner', async function () { - await shouldFail.reverting.withMessage(this.token.ownerOf(tokenId)); + await shouldFail.reverting.withMessage( + this.token.ownerOf(tokenId), + 'ERC721: owner query of nonexistent token' + ); (await this.token.balanceOf(owner)).should.be.bignumber.equal('1'); }); @@ -98,7 +104,9 @@ function shouldBehaveLikeMintAndBurnERC721 ( context('getApproved', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.getApproved(tokenId)); + await shouldFail.reverting.withMessage( + this.token.getApproved(tokenId), 'ERC721: approved query of nonexistent token' + ); }); }); }); @@ -106,7 +114,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( describe('when the given token ID was not tracked by this contract', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - this.token.burn(unknownTokenId, { from: creator }) + this.token.burn(unknownTokenId, { from: creator }), 'ERC721: owner query of nonexistent token' ); }); }); diff --git a/test/token/ERC721/ERC721PausedToken.behavior.js b/test/token/ERC721/ERC721PausedToken.behavior.js index 02429506428..94d2e098638 100644 --- a/test/token/ERC721/ERC721PausedToken.behavior.js +++ b/test/token/ERC721/ERC721PausedToken.behavior.js @@ -12,24 +12,34 @@ function shouldBehaveLikeERC721PausedToken (owner, [recipient, operator]) { }); it('reverts when trying to approve', async function () { - await shouldFail.reverting.withMessage(this.token.approve(recipient, firstTokenId, { from: owner })); + await shouldFail.reverting.withMessage( + this.token.approve(recipient, firstTokenId, { from: owner }), 'Pausable: paused' + ); }); it('reverts when trying to setApprovalForAll', async function () { - await shouldFail.reverting.withMessage(this.token.setApprovalForAll(operator, true, { from: owner })); + await shouldFail.reverting.withMessage( + this.token.setApprovalForAll(operator, true, { from: owner }), 'Pausable: paused' + ); }); it('reverts when trying to transferFrom', async function () { - await shouldFail.reverting.withMessage(this.token.transferFrom(owner, recipient, firstTokenId, { from: owner })); + await shouldFail.reverting.withMessage( + this.token.transferFrom(owner, recipient, firstTokenId, { from: owner }), 'Pausable: paused' + ); }); it('reverts when trying to safeTransferFrom', async function () { - await shouldFail.reverting.withMessage(this.token.safeTransferFrom(owner, recipient, firstTokenId, { from: owner })); + await shouldFail.reverting.withMessage( + this.token.safeTransferFrom(owner, recipient, firstTokenId, { from: owner }), 'Pausable: paused' + ); }); it('reverts when trying to safeTransferFrom with data', async function () { - await shouldFail.reverting.withMessage(this.token.methods['safeTransferFrom(address,address,uint256,bytes)']( - owner, recipient, firstTokenId, mockData, { from: owner }) + await shouldFail.reverting.withMessage( + this.token.methods['safeTransferFrom(address,address,uint256,bytes)']( + owner, recipient, firstTokenId, mockData, { from: owner } + ), 'Pausable: paused' ); }); diff --git a/test/utils/ReentrancyGuard.test.js b/test/utils/ReentrancyGuard.test.js index 66632d37f32..c4a072db85e 100644 --- a/test/utils/ReentrancyGuard.test.js +++ b/test/utils/ReentrancyGuard.test.js @@ -3,7 +3,7 @@ const { shouldFail } = require('openzeppelin-test-helpers'); const ReentrancyMock = artifacts.require('ReentrancyMock'); const ReentrancyAttack = artifacts.require('ReentrancyAttack'); -contract.only('ReentrancyGuard', function () { +contract('ReentrancyGuard', function () { beforeEach(async function () { this.reentrancyMock = await ReentrancyMock.new(); (await this.reentrancyMock.counter()).should.be.bignumber.equal('0'); @@ -11,7 +11,8 @@ contract.only('ReentrancyGuard', function () { it('should not allow remote callback', async function () { const attacker = await ReentrancyAttack.new(); - await shouldFail.reverting.withMessage(this.reentrancyMock.countAndCall(attacker.address), "ReentrancyGuard: reentrant call"); + await shouldFail.reverting.withMessage( + this.reentrancyMock.countAndCall(attacker.address), 'ReentrancyGuard: reentrant call'); }); // The following are more side-effects than intended behavior: @@ -19,10 +20,14 @@ contract.only('ReentrancyGuard', function () { // in the side-effects. it('should not allow local recursion', async function () { - await shouldFail.reverting.withMessage(this.reentrancyMock.countLocalRecursive(10), "ReentrancyGuard: reentrant call"); + await shouldFail.reverting.withMessage( + this.reentrancyMock.countLocalRecursive(10), 'ReentrancyGuard: reentrant call' + ); }); it('should not allow indirect local recursion', async function () { - await shouldFail.reverting.withMessage(this.reentrancyMock.countThisRecursive(10), "ReentrancyMock: failed call"); + await shouldFail.reverting.withMessage( + this.reentrancyMock.countThisRecursive(10), 'ReentrancyMock: failed call' + ); }); }); From 92133e01ce586c57cefbbf6949a4a88b887cc91d Mon Sep 17 00:00:00 2001 From: balajipachai Date: Sat, 20 Apr 2019 14:29:47 +0530 Subject: [PATCH 15/20] Achieved 100% code coverage --- test/payment/escrow/ConditionalEscrow.test.js | 4 +++- test/token/ERC721/ERC721.behavior.js | 2 +- test/token/ERC721/ERC721MintBurn.behavior.js | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/payment/escrow/ConditionalEscrow.test.js b/test/payment/escrow/ConditionalEscrow.test.js index aa27477c72b..705833567ba 100644 --- a/test/payment/escrow/ConditionalEscrow.test.js +++ b/test/payment/escrow/ConditionalEscrow.test.js @@ -26,7 +26,9 @@ contract('ConditionalEscrow', function ([_, owner, payee, ...otherAccounts]) { it('reverts on withdrawals', async function () { await this.escrow.deposit(payee, { from: owner, value: amount }); - await shouldFail.reverting.withMessage(this.escrow.withdraw(payee, { from: owner }), 'Failure message'); + await shouldFail.reverting.withMessage(this.escrow.withdraw(payee, { from: owner }), + 'ConditionalEscrow: payee is not allowed to withdraw' + ); }); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index c0a51114338..31c7b3f959a 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -201,7 +201,7 @@ function shouldBehaveLikeERC721 ( it('reverts', async function () { await shouldFail.reverting.withMessage( transferFunction.call(this, owner, other, unknownTokenId, { from: owner }), - 'about airtel' + 'ERC721: operator query for nonexistent token' ); }); }); diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index b092c0faa02..b434741bfeb 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -55,7 +55,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( describe('when the given token ID was already tracked by this contract', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter }), 'no idea'); + await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter }), 'ERC721: token already minted.'); }); }); }); @@ -114,7 +114,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( describe('when the given token ID was not tracked by this contract', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - this.token.burn(unknownTokenId, { from: creator }), 'ERC721: owner query of nonexistent token' + this.token.burn(unknownTokenId, { from: creator }), 'ERC721: operator query for nonexistent token' ); }); }); From 9ea1f50b7cea2a48c161d5ac4a95394d21ea99aa Mon Sep 17 00:00:00 2001 From: balajipachai Date: Sat, 20 Apr 2019 15:07:17 +0530 Subject: [PATCH 16/20] Updated the test cases with shouldFail.reverting.withMessage() --- package-lock.json | 75 +++++++++----------- test/token/ERC721/ERC721MintBurn.behavior.js | 4 +- 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58e7b97cb8c..4485e5f4388 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1435,9 +1435,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30000948", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000948.tgz", - "integrity": "sha512-Lw4y7oz1X5MOMZm+2IFaSISqVVQvUuD+ZUSfeYK/SlYiMjkHN/eJ2PDfJehW5NA6JjrxYSSnIWfwjeObQMEjFQ==", + "version": "1.0.30000962", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000962.tgz", + "integrity": "sha512-WXYsW38HK+6eaj5IZR16Rn91TGhU3OhbwjKZvJ4HN/XBIABLKfbij9Mnd3pM0VEwZSlltWjoWg3I8FQ0DGgNOA==", "dev": true }, "caseless": { @@ -2180,9 +2180,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.116", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.116.tgz", - "integrity": "sha512-NKwKAXzur5vFCZYBHpdWjTMO8QptNLNP80nItkSIgUOapPAo9Uia+RvkCaZJtO7fhQaVElSvBPWEc2ku6cKsPA==", + "version": "1.3.125", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.125.tgz", + "integrity": "sha512-XxowpqQxJ4nDwUXHtVtmEhRqBpm2OnjBomZmZtHD0d2Eo0244+Ojezhk3sD/MBSSe2nxCdGQFRXHIsf/LUTL9A==", "dev": true }, "elliptic": { @@ -2802,12 +2802,6 @@ "safe-buffer": "^5.1.1", "secp256k1": "^3.0.1" } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true } } }, @@ -5737,15 +5731,15 @@ "dev": true }, "level-codec": { - "version": "9.0.0", - "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-9.0.0.tgz", - "integrity": "sha512-OIpVvjCcZNP5SdhcNupnsI1zo5Y9Vpm+k/F1gfG5kXrtctlrwanisakweJtE0uA0OpLukRfOQae+Fg0M5Debhg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-9.0.1.tgz", + "integrity": "sha512-ajFP0kJ+nyq4i6kptSM+mAvJKLOg1X5FiFPtLG9M5gCEZyBmgDi3FkDrvlMkEzrUn1cWxtvVmrvoS4ASyO/q+Q==", "dev": true }, "level-errors": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-2.0.0.tgz", - "integrity": "sha512-AmY4HCp9h3OiU19uG+3YWkdELgy05OTP/r23aNHaQKWv8DO787yZgsEuGVkoph40uwN+YdUKnANlrxSsoOaaxg==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-2.0.1.tgz", + "integrity": "sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw==", "dev": true, "requires": { "errno": "~0.1.1" @@ -5990,14 +5984,6 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "strip-bom": "^2.0.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - } } }, "locate-path": { @@ -6812,14 +6798,6 @@ "graceful-fs": "^4.1.2", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - } } }, "pathval": { @@ -6859,6 +6837,12 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", @@ -8283,8 +8267,7 @@ "dependencies": { "bignumber.js": { "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", - "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", - "dev": true + "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git" }, "utf8": { "version": "2.1.2", @@ -8303,6 +8286,13 @@ "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", "xmlhttprequest": "*" + }, + "dependencies": { + "bignumber.js": { + "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", + "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", + "dev": true + } } } } @@ -8465,9 +8455,9 @@ "dev": true }, "stream-to-pull-stream": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/stream-to-pull-stream/-/stream-to-pull-stream-1.7.2.tgz", - "integrity": "sha1-dXYJrhzr0zx0MtSvvjH/eGULnd4=", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/stream-to-pull-stream/-/stream-to-pull-stream-1.7.3.tgz", + "integrity": "sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg==", "dev": true, "requires": { "looper": "^3.0.0", @@ -10051,12 +10041,12 @@ "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "dev": true, "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#d8d7fc9cc1fd781186c25676af100d1ec727013e", + "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "ethereumjs-util": "^5.1.1" } }, "ethereumjs-abi": { - "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#d8d7fc9cc1fd781186c25676af100d1ec727013e", + "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", "dev": true, "requires": { @@ -10365,7 +10355,8 @@ }, "websocket": { "version": "1.0.26", - "resolved": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", + "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.26.tgz", + "integrity": "sha512-fjcrYDPIQxpTnqFQ9JjxUQcdvR89MFAOjPBlF+vjOt49w/XW4fJknUoMz/mDIn2eK1AdslVojcaOxOqyZZV8rw==", "dev": true, "requires": { "debug": "^2.2.0", diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index b434741bfeb..d9de268e365 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -55,7 +55,9 @@ function shouldBehaveLikeMintAndBurnERC721 ( describe('when the given token ID was already tracked by this contract', function () { it('reverts', async function () { - await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter }), 'ERC721: token already minted.'); + await shouldFail.reverting.withMessage(this.token.mint(owner, firstTokenId, { from: minter }), + 'ERC721: token already minted.' + ); }); }); }); From a946483e619225ad35fab875d99b32d302e6c61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Venturo?= Date: Mon, 22 Apr 2019 16:41:39 -0300 Subject: [PATCH 17/20] Fix package-lock. --- package-lock.json | 2661 ++++----------------------------------------- 1 file changed, 208 insertions(+), 2453 deletions(-) diff --git a/package-lock.json b/package-lock.json index ba434b9d560..c36c4d1ef3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1279,103 +1279,10 @@ } } }, - "caller-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", - "integrity": "sha1-lAhe9jWB7NPaqSREqP6U6CV3dR8=", - "dev": true, - "requires": { - "callsites": "^0.2.0" - } - }, - "callsites": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz", - "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", - "dev": true - }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true - }, - "caniuse-lite": { - "version": "1.0.30000962", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000962.tgz", - "integrity": "sha512-WXYsW38HK+6eaj5IZR16Rn91TGhU3OhbwjKZvJ4HN/XBIABLKfbij9Mnd3pM0VEwZSlltWjoWg3I8FQ0DGgNOA==", - "dev": true - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true - }, - "chai": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", - "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", - "dev": true, - "requires": { - "assertion-error": "^1.0.1", - "check-error": "^1.0.1", - "deep-eql": "^3.0.0", - "get-func-name": "^2.0.0", - "pathval": "^1.0.0", - "type-detect": "^4.0.0" - } - }, - "chai-bn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/chai-bn/-/chai-bn-0.1.1.tgz", - "integrity": "sha512-e1npVXt3cQfZ6oQET9oP38vNj/4HeJ4ojeUpuC8YzhVbTJpIDqANVt7TKi7Dq9yKlHySk2FqbmiMih35iT4DYg==", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "chardet": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.4.2.tgz", - "integrity": "sha1-tUc7M9yXxCTl2Y3IfVXU2KKci/I=", - "dev": true - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true - }, - "checkpoint-store": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/checkpoint-store/-/checkpoint-store-1.1.0.tgz", - "integrity": "sha1-BOTLUWuRQziTWB5tRgGnjpVS6gY=", - "dev": true, - "requires": { - "functional-red-black-tree": "^1.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz", - "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", - "dev": true - }, - "cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", "dev": true, "requires": { "is-callable": "^1.1.4", @@ -2112,10 +2019,10 @@ "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", "dev": true }, - "electron-to-chromium": { - "version": "1.3.125", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.125.tgz", - "integrity": "sha512-XxowpqQxJ4nDwUXHtVtmEhRqBpm2OnjBomZmZtHD0d2Eo0244+Ojezhk3sD/MBSSe2nxCdGQFRXHIsf/LUTL9A==", + "fast-deep-equal": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", "dev": true }, "fast-diff": { @@ -2409,10 +2316,9 @@ "locate-path": "^2.0.0" } }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "get-caller-file": { + "version": "1.0.3", + "bundled": true, "dev": true }, "get-stream": { @@ -2420,10 +2326,29 @@ "bundled": true, "dev": true }, - "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "invert-kv": { + "version": "1.0.0", + "bundled": true, + "dev": true + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "is-stream": { + "version": "1.1.0", + "bundled": true, + "dev": true + }, + "isexe": { + "version": "2.0.0", + "bundled": true, + "dev": true + }, + "lcid": { + "version": "1.0.0", + "bundled": true, "dev": true, "requires": { "invert-kv": "^1.0.0" @@ -2605,1103 +2530,91 @@ "version": "2.0.0", "bundled": true, "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "bundled": true, + "dev": true, + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "bundled": true, + "dev": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "dev": true, + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "dev": true, + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + } + } + }, + "y18n": { + "version": "3.2.1", + "bundled": true, + "dev": true + }, + "yallist": { + "version": "3.0.2", + "bundled": true, + "dev": true + }, + "yargs": { + "version": "11.1.0", + "bundled": true, + "dev": true, + "requires": { + "cliui": "^4.0.0", + "decamelize": "^1.1.1", + "find-up": "^2.1.0", + "get-caller-file": "^1.0.1", + "os-locale": "^2.0.0", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^2.0.0", + "which-module": "^2.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^9.0.2" + } + }, + "yargs-parser": { + "version": "9.0.2", + "bundled": true, + "dev": true, + "requires": { + "camelcase": "^4.1.0" + } } } }, - "eslint-plugin-promise": { - "version": "3.8.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.8.0.tgz", - "integrity": "sha512-JiFL9UFR15NKpHyGii1ZcvmtIqa3UTwiDAGb8atSffe43qJ3+1czVGN6UtkklpcJ2DVnqvTMzEKRaJdBkAL2aQ==", - "dev": true - }, - "eslint-plugin-standard": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-3.1.0.tgz", - "integrity": "sha512-fVcdyuKRr0EZ4fjWl3c+gp1BANFJD1+RaWa2UPYfMZ6jCtp5RG00kSaXnK/dE5sYzt4kaWJ9qdxqUfc0d9kX0w==", - "dev": true - }, - "eslint-scope": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", - "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", - "dev": true, - "requires": { - "esrecurse": "^4.1.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz", - "integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q==", - "dev": true - }, - "eslint-visitor-keys": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz", - "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", - "dev": true - }, - "espree": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz", - "integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==", - "dev": true, - "requires": { - "acorn": "^5.5.0", - "acorn-jsx": "^3.0.0" - } - }, - "esprima": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", - "dev": true - }, - "esprima-extract-comments": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/esprima-extract-comments/-/esprima-extract-comments-1.1.0.tgz", - "integrity": "sha512-sBQUnvJwpeE9QnPrxh7dpI/dp67erYG4WXEAreAMoelPRpMR7NWb4YtwRPn9b+H1uLQKl/qS8WYmyaljTpjIsw==", - "dev": true, - "optional": true, - "requires": { - "esprima": "^4.0.0" - }, - "dependencies": { - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "optional": true - } - } - }, - "esquery": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.0.1.tgz", - "integrity": "sha512-SmiyZ5zIWH9VM+SRUReLS5Q8a7GxtRdxEBVZpm98rJM7Sb+A9DVCndXfkeFUd3byderg+EbDkfnevfCwynWaNA==", - "dev": true, - "requires": { - "estraverse": "^4.0.0" - } - }, - "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", - "dev": true, - "requires": { - "estraverse": "^4.1.0" - } - }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", - "dev": true - }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true - }, - "eth-block-tracker": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/eth-block-tracker/-/eth-block-tracker-3.0.1.tgz", - "integrity": "sha512-WUVxWLuhMmsfenfZvFO5sbl1qFY2IqUlw/FPVmjjdElpqLsZtSG+wPe9Dz7W/sB6e80HgFKknOmKk2eNlznHug==", - "dev": true, - "requires": { - "eth-query": "^2.1.0", - "ethereumjs-tx": "^1.3.3", - "ethereumjs-util": "^5.1.3", - "ethjs-util": "^0.1.3", - "json-rpc-engine": "^3.6.0", - "pify": "^2.3.0", - "tape": "^4.6.3" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "eth-ens-namehash": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/eth-ens-namehash/-/eth-ens-namehash-2.0.8.tgz", - "integrity": "sha1-IprEbsqG1S4MmR58sq74P/D2i88=", - "dev": true, - "requires": { - "idna-uts46-hx": "^2.3.1", - "js-sha3": "^0.5.7" - }, - "dependencies": { - "js-sha3": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", - "dev": true - } - } - }, - "eth-json-rpc-infura": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/eth-json-rpc-infura/-/eth-json-rpc-infura-3.2.0.tgz", - "integrity": "sha512-FLcpdxPRVBCUc7yoE+wHGvyYg2lATedP+/q7PsKvaSzQpJbgTG4ZjLnyrLanxDr6M1k/dSNa6V5QnILwjUKJcw==", - "dev": true, - "requires": { - "cross-fetch": "^2.1.1", - "eth-json-rpc-middleware": "^1.5.0", - "json-rpc-engine": "^3.4.0", - "json-rpc-error": "^2.0.0", - "tape": "^4.8.0" - } - }, - "eth-json-rpc-middleware": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/eth-json-rpc-middleware/-/eth-json-rpc-middleware-1.6.0.tgz", - "integrity": "sha512-tDVCTlrUvdqHKqivYMjtFZsdD7TtpNLBCfKAcOpaVs7orBMS/A8HWro6dIzNtTZIR05FAbJ3bioFOnZpuCew9Q==", - "dev": true, - "requires": { - "async": "^2.5.0", - "eth-query": "^2.1.2", - "eth-tx-summary": "^3.1.2", - "ethereumjs-block": "^1.6.0", - "ethereumjs-tx": "^1.3.3", - "ethereumjs-util": "^5.1.2", - "ethereumjs-vm": "^2.1.0", - "fetch-ponyfill": "^4.0.0", - "json-rpc-engine": "^3.6.0", - "json-rpc-error": "^2.0.0", - "json-stable-stringify": "^1.0.1", - "promise-to-callback": "^1.0.0", - "tape": "^4.6.3" - }, - "dependencies": { - "ethereum-common": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.2.0.tgz", - "integrity": "sha512-XOnAR/3rntJgbCdGhqdaLIxDLWKLmsZOGhHdBKadEr6gEnJLH52k93Ou+TUdFaPN3hJc3isBZBal3U/XZ15abA==", - "dev": true - }, - "ethereumjs-block": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz", - "integrity": "sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg==", - "dev": true, - "requires": { - "async": "^2.0.1", - "ethereum-common": "0.2.0", - "ethereumjs-tx": "^1.2.2", - "ethereumjs-util": "^5.0.0", - "merkle-patricia-tree": "^2.1.2" - } - }, - "ethereumjs-common": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.1.0.tgz", - "integrity": "sha512-LUmYkKV/HcZbWRyu3OU9YOevsH3VJDXtI6kEd8VZweQec+JjDGKCmAVKUyzhYUHqxRJu7JNALZ3A/b3NXOP6tA==", - "dev": true - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "ethereumjs-vm": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz", - "integrity": "sha512-r/XIUik/ynGbxS3y+mvGnbOKnuLo40V5Mj1J25+HEO63aWYREIqvWeRO/hnROlMBE5WoniQmPmhiaN0ctiHaXw==", - "dev": true, - "requires": { - "async": "^2.1.2", - "async-eventemitter": "^0.2.2", - "ethereumjs-account": "^2.0.3", - "ethereumjs-block": "~2.2.0", - "ethereumjs-common": "^1.1.0", - "ethereumjs-util": "^6.0.0", - "fake-merkle-patricia-tree": "^1.0.1", - "functional-red-black-tree": "^1.0.1", - "merkle-patricia-tree": "^2.3.2", - "rustbn.js": "~0.2.0", - "safe-buffer": "^5.1.1" - }, - "dependencies": { - "ethereumjs-block": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-2.2.0.tgz", - "integrity": "sha512-Ye+uG/L2wrp364Zihdlr/GfC3ft+zG8PdHcRtsBFNNH1CkOhxOwdB8friBU85n89uRZ9eIMAywCq0F4CwT1wAw==", - "dev": true, - "requires": { - "async": "^2.0.1", - "ethereumjs-common": "^1.1.0", - "ethereumjs-tx": "^1.2.2", - "ethereumjs-util": "^5.0.0", - "merkle-patricia-tree": "^2.1.2" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-util": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz", - "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "0.1.6", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "merkle-patricia-tree": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz", - "integrity": "sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==", - "dev": true, - "requires": { - "async": "^1.4.2", - "ethereumjs-util": "^5.0.0", - "level-ws": "0.0.0", - "levelup": "^1.2.1", - "memdown": "^1.0.0", - "readable-stream": "^2.0.0", - "rlp": "^2.0.0", - "semaphore": ">=1.0.1" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - } - } - }, - "level-codec": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-7.0.1.tgz", - "integrity": "sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==", - "dev": true - }, - "level-errors": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-1.0.5.tgz", - "integrity": "sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==", - "dev": true, - "requires": { - "errno": "~0.1.1" - } - }, - "levelup": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/levelup/-/levelup-1.3.9.tgz", - "integrity": "sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==", - "dev": true, - "requires": { - "deferred-leveldown": "~1.2.1", - "level-codec": "~7.0.0", - "level-errors": "~1.0.3", - "level-iterator-stream": "~1.3.0", - "prr": "~1.0.1", - "semver": "~5.4.1", - "xtend": "~4.0.0" - } - } - } - }, - "eth-lib": { - "version": "0.1.27", - "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.1.27.tgz", - "integrity": "sha512-B8czsfkJYzn2UIEMwjc7Mbj+Cy72V+/OXH/tb44LV8jhrjizQJJ325xMOMyk3+ETa6r6oi0jsUY14+om8mQMWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.6", - "elliptic": "^6.4.0", - "keccakjs": "^0.2.1", - "nano-json-stream-parser": "^0.1.2", - "servify": "^0.1.12", - "ws": "^3.0.0", - "xhr-request-promise": "^0.1.2" - } - }, - "eth-query": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/eth-query/-/eth-query-2.1.2.tgz", - "integrity": "sha1-1nQdkAAQa1FRDHLbktY2VFam2l4=", - "dev": true, - "requires": { - "json-rpc-random-id": "^1.0.0", - "xtend": "^4.0.1" - } - }, - "eth-sig-util": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-2.0.2.tgz", - "integrity": "sha512-tB6E8jf/aZQ943bo3+iojl8xRe3Jzcl+9OT6v8K7kWis6PdIX19SB2vYvN849cB9G9m/XLjYFK381SgdbsnpTA==", - "dev": true, - "requires": { - "ethereumjs-abi": "0.6.5", - "ethereumjs-util": "^5.1.1" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ethereumjs-block": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-2.2.0.tgz", - "integrity": "sha512-Ye+uG/L2wrp364Zihdlr/GfC3ft+zG8PdHcRtsBFNNH1CkOhxOwdB8friBU85n89uRZ9eIMAywCq0F4CwT1wAw==", - "dev": true, - "requires": { - "async": "^2.0.1", - "ethereumjs-common": "^1.1.0", - "ethereumjs-tx": "^1.2.2", - "ethereumjs-util": "^5.0.0", - "merkle-patricia-tree": "^2.1.2" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-util": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz", - "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "0.1.6", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "merkle-patricia-tree": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz", - "integrity": "sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==", - "dev": true, - "requires": { - "async": "^1.4.2", - "ethereumjs-util": "^5.0.0", - "level-ws": "0.0.0", - "levelup": "^1.2.1", - "memdown": "^1.0.0", - "readable-stream": "^2.0.0", - "rlp": "^2.0.0", - "semaphore": ">=1.0.1" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - } - } - }, - "level-codec": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-7.0.1.tgz", - "integrity": "sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==", - "dev": true - }, - "level-errors": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-1.0.5.tgz", - "integrity": "sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==", - "dev": true, - "requires": { - "errno": "~0.1.1" - } - }, - "levelup": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/levelup/-/levelup-1.3.9.tgz", - "integrity": "sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==", - "dev": true, - "requires": { - "deferred-leveldown": "~1.2.1", - "level-codec": "~7.0.0", - "level-errors": "~1.0.3", - "level-iterator-stream": "~1.3.0", - "prr": "~1.0.1", - "semver": "~5.4.1", - "xtend": "~4.0.0" - } - } - } - }, - "ethereum-common": { - "version": "0.0.16", - "resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.0.16.tgz", - "integrity": "sha1-mh4Wnq00q3XgifUMpRK/0PvRJlU=", - "dev": true - }, - "ethereumjs-abi": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.5.tgz", - "integrity": "sha1-WmN+8Wq0NHP6cqKa2QhxQFs/UkE=", - "dev": true, - "requires": { - "bn.js": "^4.10.0", - "ethereumjs-util": "^4.3.0" - }, - "dependencies": { - "ethereumjs-util": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-4.5.0.tgz", - "integrity": "sha1-PpQosxfuvaPXJg2FT93alUsfG8Y=", - "dev": true, - "requires": { - "bn.js": "^4.8.0", - "create-hash": "^1.1.2", - "keccakjs": "^0.2.0", - "rlp": "^2.0.0", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-account": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/ethereumjs-account/-/ethereumjs-account-2.0.5.tgz", - "integrity": "sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA==", - "dev": true, - "requires": { - "ethereumjs-util": "^5.0.0", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-block": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-1.2.2.tgz", - "integrity": "sha1-LsdTSlkCG47JuDww5JaQxuuu3aE=", - "dev": true, - "requires": { - "async": "^1.5.2", - "ethereum-common": "0.0.16", - "ethereumjs-tx": "^1.0.0", - "ethereumjs-util": "^4.0.1", - "merkle-patricia-tree": "^2.1.2" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - }, - "ethereumjs-util": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-4.5.0.tgz", - "integrity": "sha1-PpQosxfuvaPXJg2FT93alUsfG8Y=", - "dev": true, - "requires": { - "bn.js": "^4.8.0", - "create-hash": "^1.1.2", - "keccakjs": "^0.2.0", - "rlp": "^2.0.0", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-common": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-0.6.1.tgz", - "integrity": "sha512-4jOrfDu9qOBTTGGb3zrfT1tE1Hyc6a8LJpEk0Vk9AYlLkBY7crjVICyJpRvjNI+KLDMpMITMw3eWVZOLMtZdhw==", - "dev": true - }, - "ethereumjs-testrpc-sc": { - "version": "6.1.6", - "resolved": "https://registry.npmjs.org/ethereumjs-testrpc-sc/-/ethereumjs-testrpc-sc-6.1.6.tgz", - "integrity": "sha512-iv2qiGBFgk9mn5Nq2enX8dG5WQ7Lk+FCqpnxfPfH4Ns8KLPwttmNOy264nh3SXDJJvcQwz/XnlLteDQVILotbg==", - "dev": true, - "requires": { - "source-map-support": "^0.5.3" - } - }, - "ethereumjs-tx": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/ethereumjs-tx/-/ethereumjs-tx-1.3.4.tgz", - "integrity": "sha512-kOgUd5jC+0tgV7t52UDECMMz9Uf+Lro+6fSpCvzWemtXfMEcwI3EOxf5mVPMRbTFkMMhuERokNNVF3jItAjidg==", - "dev": true, - "requires": { - "ethereum-common": "^0.0.18", - "ethereumjs-util": "^5.0.0" - }, - "dependencies": { - "ethereum-common": { - "version": "0.0.18", - "resolved": "https://registry.npmjs.org/ethereum-common/-/ethereum-common-0.0.18.tgz", - "integrity": "sha1-L9w1dvIykDNYl26znaeDIT/5Uj8=", - "dev": true - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-util": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.0.0.tgz", - "integrity": "sha512-E3yKUyl0Fs95nvTFQZe/ZSNcofhDzUsDlA5y2uoRmf1+Ec7gpGhNCsgKkZBRh7Br5op8mJcYF/jFbmjj909+nQ==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.6", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "ethereumjs-vm": { - "version": "https://github.com/Agusx1211/ethereumjs-vm/releases/download/2.4.1/ethereumjs-vm-2.4.4-coverage.tar.gz", - "integrity": "sha512-MDHFkodtVBn/mrJ7ZUF6UrG36OyvKIq79zbzo2w3vA5QXeqEvp06Jw1a3r0tELNYOyiPPNt+2boyH9XCZ4GipQ==", - "dev": true, - "requires": { - "async": "^2.1.2", - "async-eventemitter": "^0.2.2", - "ethereumjs-account": "^2.0.3", - "ethereumjs-block": "~2.1.0", - "ethereumjs-common": "^0.6.0", - "ethereumjs-util": "^6.0.0", - "fake-merkle-patricia-tree": "^1.0.1", - "functional-red-black-tree": "^1.0.1", - "merkle-patricia-tree": "^2.1.2", - "rustbn.js": "~0.2.0", - "safe-buffer": "^5.1.1" - }, - "dependencies": { - "ethereumjs-block": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-2.1.0.tgz", - "integrity": "sha512-ip+x4/7hUInX+TQfhEKsQh9MJK1Dbjp4AuPjf1UdX3udAV4beYD4EMCNIPzBLCsGS8WQZYXLpo83tVTISYNpow==", - "dev": true, - "requires": { - "async": "^2.0.1", - "ethereumjs-common": "^0.6.0", - "ethereumjs-tx": "^1.2.2", - "ethereumjs-util": "^5.0.0", - "merkle-patricia-tree": "^2.1.2" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - } - } - }, - "ethereumjs-wallet": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/ethereumjs-wallet/-/ethereumjs-wallet-0.6.2.tgz", - "integrity": "sha512-DHEKPV9lYORM7dL8602dkb+AgdfzCYz2lxpdYQoD3OwG355LLDuivW9rGuLpDMCry/ORyBYV6n+QCo/71SwACg==", - "dev": true, - "optional": true, - "requires": { - "aes-js": "^3.1.1", - "bs58check": "^2.1.2", - "ethereumjs-util": "^5.2.0", - "hdkey": "^1.0.0", - "safe-buffer": "^5.1.2", - "scrypt.js": "^0.2.0", - "utf8": "^3.0.0", - "uuid": "^3.3.2" - }, - "dependencies": { - "aes-js": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", - "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==", - "dev": true, - "optional": true - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "optional": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "uuid": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", - "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", - "dev": true, - "optional": true - } - } - }, - "ethers": { - "version": "4.0.27", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.27.tgz", - "integrity": "sha512-+DXZLP/tyFnXWxqr2fXLT67KlGUfLuvDkHSOtSC9TUVG9OIj6yrG5JPeXRMYo15xkOYwnjgdMKrXp5V94rtjJA==", - "dev": true, - "requires": { - "@types/node": "^10.3.2", - "aes-js": "3.0.0", - "bn.js": "^4.4.0", - "elliptic": "6.3.3", - "hash.js": "1.1.3", - "js-sha3": "0.5.7", - "scrypt-js": "2.0.4", - "setimmediate": "1.0.4", - "uuid": "2.0.1", - "xmlhttprequest": "1.8.0" - }, - "dependencies": { - "elliptic": { - "version": "6.3.3", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.3.3.tgz", - "integrity": "sha1-VILZZG1UvLif19mU/J4ulWiHbj8=", - "dev": true, - "requires": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", - "hash.js": "^1.0.0", - "inherits": "^2.0.1" - } - }, - "js-sha3": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.7.tgz", - "integrity": "sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc=", - "dev": true - }, - "uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", - "dev": true - } - } - }, - "ethjs-abi": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz", - "integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=", - "dev": true, - "requires": { - "bn.js": "4.11.6", - "js-sha3": "0.5.5", - "number-to-bn": "1.7.0" - }, - "dependencies": { - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", - "dev": true - }, - "js-sha3": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", - "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=", - "dev": true - } - } - }, - "ethjs-unit": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz", - "integrity": "sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk=", - "dev": true, - "requires": { - "bn.js": "4.11.6", - "number-to-bn": "1.7.0" - }, - "dependencies": { - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", - "dev": true - } - } - }, - "ethjs-util": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz", - "integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==", - "dev": true, - "requires": { - "is-hex-prefixed": "1.0.0", - "strip-hex-prefix": "1.0.0" - } - }, - "eventemitter3": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-1.1.1.tgz", - "integrity": "sha1-R3hr2qCHyvext15zq8XH1UAVjNA=", - "dev": true - }, - "events": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/events/-/events-3.0.0.tgz", - "integrity": "sha512-Dc381HFWJzEOhQ+d8pkNon++bk9h6cdAoAj4iE6Q4y6xgTzySWXlKn05/TVNpjnfRqi/X0EpJEJohPjNI3zpVA==", - "dev": true - }, - "evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", - "dev": true, - "requires": { - "md5.js": "^1.3.4", - "safe-buffer": "^5.1.1" - } - }, - "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", - "dev": true, - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "express": { - "version": "4.16.4", - "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", - "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", - "dev": true, - "requires": { - "accepts": "~1.3.5", - "array-flatten": "1.1.1", - "body-parser": "1.18.3", - "content-disposition": "0.5.2", - "content-type": "~1.0.4", - "cookie": "0.3.1", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "1.1.1", - "fresh": "0.5.2", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.4", - "qs": "6.5.2", - "range-parser": "~1.2.0", - "safe-buffer": "5.1.2", - "send": "0.16.2", - "serve-static": "1.13.2", - "setprototypeof": "1.1.0", - "statuses": "~1.4.0", - "type-is": "~1.6.16", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", - "dev": true - } - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", - "dev": true - }, - "external-editor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-2.1.0.tgz", - "integrity": "sha512-E44iT5QVOUJBKij4IIV3uvxuNlbKS38Tw1HiupxEIHPv9qtC2PrDYohbXV5U+1jnfIXttny8gUhj+oZvflFlzA==", - "dev": true, - "requires": { - "chardet": "^0.4.0", - "iconv-lite": "^0.4.17", - "tmp": "^0.0.33" - } - }, - "extract-comments": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/extract-comments/-/extract-comments-1.1.0.tgz", - "integrity": "sha512-dzbZV2AdSSVW/4E7Ti5hZdHWbA+Z80RJsJhr5uiL10oyjl/gy7/o+HI1HwK4/WSZhlq4SNKU3oUzXlM13Qx02Q==", - "dev": true, - "optional": true, - "requires": { - "esprima-extract-comments": "^1.1.0", - "parse-code-context": "^1.0.0" - } - }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", - "dev": true - }, - "fake-merkle-patricia-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/fake-merkle-patricia-tree/-/fake-merkle-patricia-tree-1.0.1.tgz", - "integrity": "sha1-S4w6z7Ugr635hgsfFM2M40As3dM=", - "dev": true, - "requires": { - "checkpoint-store": "^1.1.0" - } - }, - "fast-deep-equal": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", - "dev": true - }, - "fast-diff": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", - "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "fd-slicer": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", - "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", - "dev": true, - "requires": { - "pend": "~1.2.0" - } - }, - "fetch-ponyfill": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/fetch-ponyfill/-/fetch-ponyfill-4.1.0.tgz", - "integrity": "sha1-rjzl9zLGReq4fkroeTQUcJsjmJM=", - "dev": true, - "requires": { - "node-fetch": "~1.7.1" - }, - "dependencies": { - "node-fetch": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", - "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - } - }, - "yargs-parser": { - "version": "9.0.2", - "bundled": true, - "dev": true, - "requires": { - "camelcase": "^4.1.0" - } - } - } - }, - "ganache-cli-coverage": { - "version": "https://github.com/frangio/ganache-cli/releases/download/v6.4.1-coverage/ganache-cli-coverage-6.4.1.tgz", - "integrity": "sha512-/BJIoofYEN5DuyUUO9edBGhQpMQTAuN03a1K8eqtWFkO29wHnbsaG/aIzahRbngcmV+A0ctyvokiLa2FL1rHeQ==", + "ganache-cli-coverage": { + "version": "https://github.com/frangio/ganache-cli/releases/download/v6.4.1-coverage/ganache-cli-coverage-6.4.1.tgz", + "integrity": "sha512-/BJIoofYEN5DuyUUO9edBGhQpMQTAuN03a1K8eqtWFkO29wHnbsaG/aIzahRbngcmV+A0ctyvokiLa2FL1rHeQ==", "dev": true, "requires": { "bn.js": "4.11.8", @@ -3912,513 +2825,79 @@ "dev": true }, "require-directory": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "require-main-filename": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true - }, - "shebang-command": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true - }, - "source-map-support": { - "version": "0.5.9", - "bundled": true, - "dev": true, - "requires": { - "buffer-from": "^1.0.0", - "source-map": "^0.6.0" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "bundled": true, - "dev": true - } - } - }, - "string-width": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "strip-eof": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "which": { - "version": "1.3.1", - "bundled": true, - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "bundled": true, - "dev": true - }, - "wrap-ansi": { - "version": "2.1.0", - "bundled": true, - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "y18n": { - "version": "3.2.1", - "bundled": true, - "dev": true - }, - "yallist": { - "version": "3.0.2", - "bundled": true, - "dev": true - }, - "yargs": { - "version": "11.1.0", - "bundled": true, - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - } - }, - "yargs-parser": { - "version": "9.0.2", - "bundled": true, - "dev": true, - "requires": { - "camelcase": "^4.1.0" - } - } - } - }, - "ganache-cli-coverage": { - "version": "github:Agusx1211/ganache-cli#c462b3fc48fe9b16756f7799885c0741114d9ed3", - "from": "github:Agusx1211/ganache-cli#c462b3fc48fe9b16756f7799885c0741114d9ed3", - "dev": true, - "requires": { - "async": "^2.6.1", - "bn.js": "4.11.8", - "ganache-core": "github:agusx1211/ganache-core#d885dd09685f84150db8ef11cd6929785acd0f98", - "source-map-support": "^0.5.3", - "web3": "^1.0.0-beta.36", - "yargs": "^11.0.0" - } - }, - "ganache-core": { - "version": "github:agusx1211/ganache-core#d885dd09685f84150db8ef11cd6929785acd0f98", - "from": "github:agusx1211/ganache-core#coverage", - "dev": true, - "requires": { - "abstract-leveldown": "3.0.0", - "async": "2.6.1", - "bip39": "2.5.0", - "bn.js": "4.11.8", - "cachedown": "1.0.0", - "clone": "2.1.2", - "debug": "3.1.0", - "encoding-down": "5.0.4", - "eth-sig-util": "2.0.2", - "ethereumjs-abi": "0.6.5", - "ethereumjs-account": "2.0.5", - "ethereumjs-block": "1.2.2", - "ethereumjs-tx": "1.3.4", - "ethereumjs-util": "^5.2.0", - "ethereumjs-vm": "https://github.com/Agusx1211/ethereumjs-vm/releases/download/2.4.1/ethereumjs-vm-2.4.4-coverage.tar.gz", - "ethereumjs-wallet": "0.6.2", - "heap": "0.2.6", - "level-sublevel": "6.6.4", - "levelup": "3.1.1", - "lodash": "4.17.10", - "merkle-patricia-tree": "2.3.1", - "seedrandom": "2.4.4", - "tmp": "0.0.33", - "web3": "1.0.0-beta.35", - "web3-provider-engine": "14.1.0", - "websocket": "1.0.26" - }, - "dependencies": { - "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", - "dev": true, - "requires": { - "lodash": "^4.17.10" - } - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - }, - "utf8": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", - "integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g=", - "dev": true - }, - "uuid": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.1.tgz", - "integrity": "sha1-wqMN7bPlNdcsz4LjQ5QaULqFM6w=", - "dev": true, - "optional": true - }, - "web3": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3/-/web3-1.0.0-beta.35.tgz", - "integrity": "sha512-xwDmUhvTcHQvvNnOPcPZZgCxKUsI2e+GbHy7JkTK3/Rmnutazy8x7fsAXT9myw7V1qpi3GgLoZ3fkglSUbg1Mg==", - "dev": true, - "optional": true, - "requires": { - "web3-bzz": "1.0.0-beta.35", - "web3-core": "1.0.0-beta.35", - "web3-eth": "1.0.0-beta.35", - "web3-eth-personal": "1.0.0-beta.35", - "web3-net": "1.0.0-beta.35", - "web3-shh": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - } - }, - "web3-bzz": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-bzz/-/web3-bzz-1.0.0-beta.35.tgz", - "integrity": "sha512-BhAU0qhlr8zltm4gs/+P1gki2VkxHJaM2Rrh4DGesDW0lzwufRoNvWFlwx1bKHoFPWNbSmm9PRkHOYOINL/Tgw==", - "dev": true, - "optional": true, - "requires": { - "got": "7.1.0", - "swarm-js": "0.1.37", - "underscore": "1.8.3" - } - }, - "web3-core": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-core/-/web3-core-1.0.0-beta.35.tgz", - "integrity": "sha512-ayGavbgVk4KL9Y88Uv411fBJ0SVgVfKhKEBweKYzmP0zOqneMzWt6YsyD1n6kRvjAbqA0AfUPEOKyMNjcx2tjw==", - "dev": true, - "requires": { - "web3-core-helpers": "1.0.0-beta.35", - "web3-core-method": "1.0.0-beta.35", - "web3-core-requestmanager": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - } - }, - "web3-core-helpers": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-core-helpers/-/web3-core-helpers-1.0.0-beta.35.tgz", - "integrity": "sha512-APOu3sEsamyqWt//8o4yq9KF25/uqGm+pQShson/sC4gKzmfJB07fLo2ond0X30E8fIqAPeVCotPXQxGciGUmA==", - "dev": true, - "requires": { - "underscore": "1.8.3", - "web3-eth-iban": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - } - }, - "web3-core-method": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-core-method/-/web3-core-method-1.0.0-beta.35.tgz", - "integrity": "sha512-jidImCide8q0GpfsO4L73qoHrbkeWgwU3uOH5DKtJtv0ccmG086knNMRgryb/o9ZgetDWLmDEsJnHjBSoIwcbA==", - "dev": true, - "requires": { - "underscore": "1.8.3", - "web3-core-helpers": "1.0.0-beta.35", - "web3-core-promievent": "1.0.0-beta.35", - "web3-core-subscriptions": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - } - }, - "web3-core-promievent": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-core-promievent/-/web3-core-promievent-1.0.0-beta.35.tgz", - "integrity": "sha512-GvqXqKq07OmHuVi5uNRg6k79a1/CI0ViCC+EtNv4CORHtDRmYEt5Bvdv6z6FJEiaaQkD0lKbFwNhLxutx7HItw==", - "dev": true, - "requires": { - "any-promise": "1.3.0", - "eventemitter3": "1.1.1" - } - }, - "web3-core-requestmanager": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-core-requestmanager/-/web3-core-requestmanager-1.0.0-beta.35.tgz", - "integrity": "sha512-S+zW2h17ZZQU9oe3yaCJE0E7aJS4C3Kf4kGPDv+nXjW0gKhQQhgVhw1Doq/aYQGqNSWJp7f1VHkz5gQWwg6RRg==", - "dev": true, - "requires": { - "underscore": "1.8.3", - "web3-core-helpers": "1.0.0-beta.35", - "web3-providers-http": "1.0.0-beta.35", - "web3-providers-ipc": "1.0.0-beta.35", - "web3-providers-ws": "1.0.0-beta.35" - } + "version": "2.1.1", + "bundled": true, + "dev": true }, - "web3-core-subscriptions": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-core-subscriptions/-/web3-core-subscriptions-1.0.0-beta.35.tgz", - "integrity": "sha512-gXzLrWvcGkGiWq1y33Z4Y80XI8XMrwowiQJkrPSjQ81K5PBKquOGwcMffLaKcwdmEy/NpsOXDeFo3eLE1Ghvvw==", - "dev": true, - "requires": { - "eventemitter3": "1.1.1", - "underscore": "1.8.3", - "web3-core-helpers": "1.0.0-beta.35" - } + "require-main-filename": { + "version": "1.0.1", + "bundled": true, + "dev": true }, - "web3-eth": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-eth/-/web3-eth-1.0.0-beta.35.tgz", - "integrity": "sha512-04mcb2nGPXThawuuYICPOxv0xOHofvQKsjZeIq+89nyOC8DQMGTAErDkGyMHQYtjpth5XDhic0wuEsA80AmFZA==", - "dev": true, - "optional": true, - "requires": { - "underscore": "1.8.3", - "web3-core": "1.0.0-beta.35", - "web3-core-helpers": "1.0.0-beta.35", - "web3-core-method": "1.0.0-beta.35", - "web3-core-subscriptions": "1.0.0-beta.35", - "web3-eth-abi": "1.0.0-beta.35", - "web3-eth-accounts": "1.0.0-beta.35", - "web3-eth-contract": "1.0.0-beta.35", - "web3-eth-iban": "1.0.0-beta.35", - "web3-eth-personal": "1.0.0-beta.35", - "web3-net": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - } + "set-blocking": { + "version": "2.0.0", + "bundled": true, + "dev": true }, - "web3-eth-abi": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-eth-abi/-/web3-eth-abi-1.0.0-beta.35.tgz", - "integrity": "sha512-KUDC+EtFFYG8z01ZleKrASdjj327/rtWHzEt6RWsEj7bBa0bGp9nEh+nqdZx/Sdgz1O8tnfFzJlrRcXpfr1vGg==", + "shebang-command": { + "version": "1.2.0", + "bundled": true, "dev": true, "requires": { - "bn.js": "4.11.6", - "underscore": "1.8.3", - "web3-core-helpers": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - }, - "dependencies": { - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", - "dev": true - } + "shebang-regex": "^1.0.0" } }, - "web3-eth-accounts": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-eth-accounts/-/web3-eth-accounts-1.0.0-beta.35.tgz", - "integrity": "sha512-duIgRsfht/0kAW/eQ0X9lKtVIykbETrnM2H7EnvplCzPHtQLodpib4o9JXfh9n6ZDgdDC7cuJoiVB9QJg089ew==", - "dev": true, - "optional": true, - "requires": { - "any-promise": "1.3.0", - "crypto-browserify": "3.12.0", - "eth-lib": "0.2.7", - "scrypt.js": "0.2.0", - "underscore": "1.8.3", - "uuid": "2.0.1", - "web3-core": "1.0.0-beta.35", - "web3-core-helpers": "1.0.0-beta.35", - "web3-core-method": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - }, - "dependencies": { - "eth-lib": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", - "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", - "dev": true, - "optional": true, - "requires": { - "bn.js": "^4.11.6", - "elliptic": "^6.4.0", - "xhr-request-promise": "^0.1.2" - } - } - } + "shebang-regex": { + "version": "1.0.0", + "bundled": true, + "dev": true }, - "web3-eth-contract": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-eth-contract/-/web3-eth-contract-1.0.0-beta.35.tgz", - "integrity": "sha512-foPohOg5O1UCGKGZOIs+kQK5IZdV2QQ7pAWwNxH8WHplUA+fre1MurXNpoxknUmH6mYplFhXjqgYq2MsrBpHrA==", - "dev": true, - "optional": true, - "requires": { - "underscore": "1.8.3", - "web3-core": "1.0.0-beta.35", - "web3-core-helpers": "1.0.0-beta.35", - "web3-core-method": "1.0.0-beta.35", - "web3-core-promievent": "1.0.0-beta.35", - "web3-core-subscriptions": "1.0.0-beta.35", - "web3-eth-abi": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" - } + "signal-exit": { + "version": "3.0.2", + "bundled": true, + "dev": true }, - "web3-eth-iban": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-eth-iban/-/web3-eth-iban-1.0.0-beta.35.tgz", - "integrity": "sha512-H5wkcNcAIc+h/WoDIKv7ZYmrM2Xqu3O7jBQl1IWo73EDVQji+AoB2i3J8tuwI1yZRInRwrfpI3Zuwuf54hXHmQ==", + "source-map-support": { + "version": "0.5.9", + "bundled": true, "dev": true, "requires": { - "bn.js": "4.11.6", - "web3-utils": "1.0.0-beta.35" + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" }, "dependencies": { - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", + "source-map": { + "version": "0.6.1", + "bundled": true, "dev": true } } }, - "web3-eth-personal": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-eth-personal/-/web3-eth-personal-1.0.0-beta.35.tgz", - "integrity": "sha512-AcM9nnlxu7ZRRxPvkrFB9eLxMM4A2cPfj2aCg21Wb2EpMnhR+b/O1cT33k7ApRowoMpM+T9M8vx2oPNwXfaCOQ==", + "string-width": { + "version": "2.1.1", + "bundled": true, "dev": true, "requires": { - "web3-core": "1.0.0-beta.35", - "web3-core-helpers": "1.0.0-beta.35", - "web3-core-method": "1.0.0-beta.35", - "web3-net": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" } }, - "web3-net": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-net/-/web3-net-1.0.0-beta.35.tgz", - "integrity": "sha512-bbwaQ/KohGjIJ6HAKbZ6KrklCAaG6/B7hIbAbVLSFLxF+Yz9lmAgQYaDInpidpC/NLb3WOmcbRF+P77J4qMVIA==", + "strip-ansi": { + "version": "4.0.0", + "bundled": true, "dev": true, "requires": { - "web3-core": "1.0.0-beta.35", - "web3-core-method": "1.0.0-beta.35", - "web3-utils": "1.0.0-beta.35" + "ansi-regex": "^3.0.0" } }, - "web3-providers-http": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.0.0-beta.35.tgz", - "integrity": "sha512-DcIMFq52Fb08UpWyZ3ZlES6NsNqJnco4hBS/Ej6eOcASfuUayPI+GLkYVZsnF3cBYqlH+DOKuArcKSuIxK7jIA==", - "dev": true, - "requires": { - "web3-core-helpers": "1.0.0-beta.35", - "xhr2-cookies": "1.1.0" - } + "strip-eof": { + "version": "1.0.0", + "bundled": true, + "dev": true }, - "web3-providers-ipc": { - "version": "1.0.0-beta.35", - "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.0.0-beta.35.tgz", - "integrity": "sha512-iB0FG0HcpUnayfa8pn4guqEQ4Y1nrroi/jffdtQgFkrNt0sD3fMSwwC0AbmECqj3tDLl0e1slBR0RENll+ZF0g==", + "which": { + "version": "1.3.1", + "bundled": true, "dev": true, "requires": { "isexe": "^2.0.0" @@ -4434,9 +2913,8 @@ "bundled": true, "dev": true, "requires": { - "underscore": "1.8.3", - "web3-core-helpers": "1.0.0-beta.35", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" }, "dependencies": { "ansi-regex": { @@ -4509,10 +2987,9 @@ "camelcase": "^4.1.0" }, "dependencies": { - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", + "camelcase": { + "version": "4.1.0", + "bundled": true, "dev": true } } @@ -4633,12 +3110,12 @@ "dev": true }, "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.0.tgz", + "integrity": "sha512-l2jRuU1NAWK6AW5qqcTATWQJvNPEwkM7NEKSiv/gqOsoSQbVoWyqVEY5GS+XPQ88zLNmqASRpzfdm8d79hJS+w==", "dev": true, "requires": { - "neo-async": "^2.6.0", + "async": "^2.5.0", "optimist": "^0.6.1", "source-map": "^0.6.1", "uglify-js": "^3.1.4" @@ -5199,21 +3676,13 @@ "dev": true }, "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.6.1.tgz", + "integrity": "sha1-bl/mfYsgXOTSL60Ft3geja3MSzA=", "dev": true, "requires": { "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "dependencies": { - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - } + "esprima": "^2.6.0" } }, "jsbn": { @@ -5314,239 +3783,6 @@ "integrity": "sha1-GwuP+ayceIklBYK3C3ExXZ2m2aM=", "dev": true }, - "level-codec": { - "version": "9.0.1", - "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-9.0.1.tgz", - "integrity": "sha512-ajFP0kJ+nyq4i6kptSM+mAvJKLOg1X5FiFPtLG9M5gCEZyBmgDi3FkDrvlMkEzrUn1cWxtvVmrvoS4ASyO/q+Q==", - "dev": true - }, - "level-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-2.0.1.tgz", - "integrity": "sha512-UVprBJXite4gPS+3VznfgDSU8PTRuVX0NXwoWW50KLxd2yw4Y1t2JUR5In1itQnudZqRMT9DlAM3Q//9NCjCFw==", - "dev": true, - "requires": { - "errno": "~0.1.1" - } - }, - "level-iterator-stream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz", - "integrity": "sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "level-errors": "^1.0.3", - "readable-stream": "^1.0.33", - "xtend": "^4.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "level-errors": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-1.1.2.tgz", - "integrity": "sha512-Sw/IJwWbPKF5Ai4Wz60B52yj0zYeqzObLh8k1Tk88jVmD51cJSKWSYpRyhVIvFzZdvsPqlH5wfhp/yxdsaQH4w==", - "dev": true, - "requires": { - "errno": "~0.1.1" - } - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } - } - }, - "level-post": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/level-post/-/level-post-1.0.7.tgz", - "integrity": "sha512-PWYqG4Q00asOrLhX7BejSajByB4EmG2GaKHfj3h5UmmZ2duciXLPGYWIjBzLECFWUGOZWlm5B20h/n3Gs3HKew==", - "dev": true, - "requires": { - "ltgt": "^2.1.2" - } - }, - "level-sublevel": { - "version": "6.6.4", - "resolved": "https://registry.npmjs.org/level-sublevel/-/level-sublevel-6.6.4.tgz", - "integrity": "sha512-pcCrTUOiO48+Kp6F1+UAzF/OtWqLcQVTVF39HLdZ3RO8XBoXt+XVPKZO1vVr1aUoxHZA9OtD2e1v7G+3S5KFDA==", - "dev": true, - "requires": { - "bytewise": "~1.1.0", - "level-codec": "^9.0.0", - "level-errors": "^2.0.0", - "level-iterator-stream": "^2.0.3", - "ltgt": "~2.1.1", - "pull-defer": "^0.2.2", - "pull-level": "^2.0.3", - "pull-stream": "^3.6.8", - "typewiselite": "~1.0.0", - "xtend": "~4.0.0" - }, - "dependencies": { - "level-iterator-stream": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-2.0.3.tgz", - "integrity": "sha512-I6Heg70nfF+e5Y3/qfthJFexhRw/Gi3bIymCoXAlijZdAcLaPuWSJs3KXyTYf23ID6g0o2QF62Yh+grOXY3Rig==", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.5", - "xtend": "^4.0.0" - } - }, - "ltgt": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ltgt/-/ltgt-2.1.3.tgz", - "integrity": "sha1-EIUaBtmWS5cReEQcI8nlJpjuzjQ=", - "dev": true - } - } - }, - "level-ws": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/level-ws/-/level-ws-0.0.0.tgz", - "integrity": "sha1-Ny5RIXeSSgBCSwtDrvK7QkltIos=", - "dev": true, - "requires": { - "readable-stream": "~1.0.15", - "xtend": "~2.1.1" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "object-keys": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz", - "integrity": "sha1-KKaq50KN0sOpLz2V8hM13SBOAzY=", - "dev": true - }, - "readable-stream": { - "version": "1.0.34", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, - "xtend": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-2.1.2.tgz", - "integrity": "sha1-bv7MKk2tjmlixJAbM3znuoe10os=", - "dev": true, - "requires": { - "object-keys": "~0.4.0" - } - } - } - }, - "levelup": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/levelup/-/levelup-3.1.1.tgz", - "integrity": "sha512-9N10xRkUU4dShSRRFTBdNaBxofz+PGaIZO962ckboJZiNmLuhVT6FZ6ZKAsICKfUBO76ySaYU6fJWX/jnj3Lcg==", - "dev": true, - "requires": { - "deferred-leveldown": "~4.0.0", - "level-errors": "~2.0.0", - "level-iterator-stream": "~3.0.0", - "xtend": "~4.0.0" - }, - "dependencies": { - "abstract-leveldown": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/abstract-leveldown/-/abstract-leveldown-5.0.0.tgz", - "integrity": "sha512-5mU5P1gXtsMIXg65/rsYGsi93+MlogXZ9FA8JnwKurHQg64bfXwGYVdVdijNTVNOlAsuIiOwHdvFFD5JqCJQ7A==", - "dev": true, - "requires": { - "xtend": "~4.0.0" - } - }, - "deferred-leveldown": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/deferred-leveldown/-/deferred-leveldown-4.0.2.tgz", - "integrity": "sha512-5fMC8ek8alH16QiV0lTCis610D1Zt1+LA4MS4d63JgS32lrCjTFDUFz2ao09/j2I4Bqb5jL4FZYwu7Jz0XO1ww==", - "dev": true, - "requires": { - "abstract-leveldown": "~5.0.0", - "inherits": "^2.0.3" - } - }, - "level-iterator-stream": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/level-iterator-stream/-/level-iterator-stream-3.0.1.tgz", - "integrity": "sha512-nEIQvxEED9yRThxvOrq8Aqziy4EGzrxSZK+QzEFAVuJvQ8glfyZ96GB6BoI4sBbLfjMXm2w4vu3Tkcm9obcY0g==", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "readable-stream": "^2.3.6", - "xtend": "^4.0.0" - } - }, - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -5568,6 +3804,14 @@ "pify": "^2.0.0", "pinkie-promise": "^2.0.0", "strip-bom": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "locate-path": { @@ -5881,12 +4125,6 @@ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, - "neo-async": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", - "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", - "dev": true - }, "nice-try": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.4.tgz", @@ -6196,6 +4434,14 @@ "graceful-fs": "^4.1.2", "pify": "^2.0.0", "pinkie-promise": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } } }, "pathval": { @@ -6235,12 +4481,6 @@ "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", @@ -7347,9 +5587,9 @@ "dev": true }, "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", "dev": true, "requires": { "argparse": "^1.0.7", @@ -7454,14 +5694,15 @@ "req-cwd": "^1.0.1", "shelljs": "^0.7.4", "sol-explore": "^1.6.2", - "solidity-parser-sc": "github:maxsam4/solidity-parser#3f0a30b97b460861654771871bcd970e73d47459", + "solidity-parser-sc": "github:maxsam4/solidity-parser#solidity-0.5", "tree-kill": "^1.2.0", "web3": "^0.20.6" }, "dependencies": { "bignumber.js": { "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", - "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git" + "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", + "dev": true }, "utf8": { "version": "2.1.2", @@ -7475,18 +5716,11 @@ "integrity": "sha512-VU6/DSUX93d1fCzBz7WP/SGCQizO1rKZi4Px9j/3yRyfssHyFcZamMw2/sj4E8TlfMXONvZLoforR8B4bRoyTQ==", "dev": true, "requires": { - "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", + "bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", "crypto-js": "^3.1.4", "utf8": "^2.1.1", "xhr2-cookies": "^1.1.0", "xmlhttprequest": "*" - }, - "dependencies": { - "bignumber.js": { - "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", - "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git", - "dev": true - } } } } @@ -7636,29 +5870,11 @@ "tweetnacl": "~0.14.0" } }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true - }, - "stream-to-pull-stream": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/stream-to-pull-stream/-/stream-to-pull-stream-1.7.3.tgz", - "integrity": "sha512-6sNyqJpr5dIOQdgNy/xcDWwDuzAsAwVzhzrWlAPAQ7Lkjx/rv0wgvxEyKwTq6FmNd5rjTrELt/CLmaSw7crMGg==", - "dev": true, - "requires": { - "looper": "^3.0.0", - "pull-stream": "^3.2.3" - }, - "dependencies": { - "looper": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/looper/-/looper-3.0.0.tgz", - "integrity": "sha1-LvpUw7HLq6m5Su4uWRSwvlf7t0k=", - "dev": true - } - } + "statuses": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", + "dev": true }, "strict-uri-encode": { "version": "1.1.0", @@ -7998,9 +6214,9 @@ "dev": true }, "truffle-contract": { - "version": "4.0.12", - "resolved": "https://registry.npmjs.org/truffle-contract/-/truffle-contract-4.0.12.tgz", - "integrity": "sha512-/ZfGvBgMB+NcKtJ0gpq803JyhNW0BNiEb29HgEr0FS7rLh4fGXD7gfYzwWwl3neKLeqGtAyhxEPMPBOTqNe+xw==", + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/truffle-contract/-/truffle-contract-4.0.11.tgz", + "integrity": "sha512-lzKFdLngTSt7MQMOvsUhOEPUjagSbGVkhQm7rSant4Y/VSWIppL3GXqpTOzdcOJMHgL9iYlMEm42+pHXq6DZxg==", "dev": true, "requires": { "bignumber.js": "^7.2.1", @@ -8161,189 +6377,6 @@ "is-typedarray": "^1.0.0" } }, - "typewise": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/typewise/-/typewise-1.0.3.tgz", - "integrity": "sha1-EGeTZUCvl5N8xdz5kiSG6fooRlE=", - "dev": true, - "requires": { - "typewise-core": "^1.2.0" - } - }, - "typewise-core": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/typewise-core/-/typewise-core-1.2.0.tgz", - "integrity": "sha1-l+uRgFx/VdL5QXSPpQ0xXZke8ZU=", - "dev": true - }, - "typewiselite": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/typewiselite/-/typewiselite-1.0.0.tgz", - "integrity": "sha1-yIgvobsQksBgBal/NO9chQjjZk4=", - "dev": true - }, - "uglify-js": { - "version": "3.5.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.4.tgz", - "integrity": "sha512-GpKo28q/7Bm5BcX9vOu4S46FwisbPbAmkkqPnGIpKvKTM96I85N6XHQV+k4I6FA2wxgLhcsSyHoNhzucwCflvA==", - "dev": true, - "optional": true, - "requires": { - "commander": "~2.20.0", - "source-map": "~0.6.1" - }, - "dependencies": { - "commander": { - "version": "2.20.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", - "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", - "dev": true, - "optional": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - } - } - }, - "ultron": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", - "dev": true - }, - "unbzip2-stream": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", - "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", - "dev": true, - "requires": { - "buffer": "^5.2.1", - "through": "^2.3.8" - } - }, - "underscore": { - "version": "1.8.3", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", - "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", - "dev": true - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true - }, - "unorm": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/unorm/-/unorm-1.5.0.tgz", - "integrity": "sha512-sMfSWoiRaXXeDZSXC+YRZ23H4xchQpwxjpw1tmfR+kgbBCaOgln4NI0LXejJIhnBuKINrB3WRn+ZI8IWssirVw==", - "dev": true - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - }, - "dependencies": { - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - } - } - }, - "url-parse": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.4.4.tgz", - "integrity": "sha512-/92DTTorg4JjktLNLe6GPS2/RvAd/RGr6LuktmWSMLEOa6rjnlrFXNgSbSmkNvCoL2T028A0a1JaJLzRMlFoHg==", - "dev": true, - "requires": { - "querystringify": "^2.0.0", - "requires-port": "^1.0.0" - } - }, - "url-parse-lax": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", - "integrity": "sha1-evjzA2Rem9eaJy56FKxovAYJ2nM=", - "dev": true, - "requires": { - "prepend-http": "^1.0.1" - } - }, - "url-set-query": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", - "integrity": "sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk=", - "dev": true - }, - "url-to-options": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", - "integrity": "sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=", - "dev": true - }, - "utf8": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz", - "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==", - "dev": true, - "optional": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", - "dev": true, - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.18" - } - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "typedarray-to-buffer": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", - "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", - "dev": true, - "requires": { - "is-typedarray": "^1.0.0" - } - }, "uglify-js": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", @@ -8756,266 +6789,6 @@ "web3-utils": "1.0.0-beta.37" } }, - "web3-provider-engine": { - "version": "14.1.0", - "resolved": "https://registry.npmjs.org/web3-provider-engine/-/web3-provider-engine-14.1.0.tgz", - "integrity": "sha512-vGZtqhSUzGTiMGhJXNnB/aRDlrPZLhLnBZ2NPArkZtr8XSrwg9m08tw4+PuWg5za0TJuoE/vuPQc501HddZZWw==", - "dev": true, - "requires": { - "async": "^2.5.0", - "backoff": "^2.5.0", - "clone": "^2.0.0", - "cross-fetch": "^2.1.0", - "eth-block-tracker": "^3.0.0", - "eth-json-rpc-infura": "^3.1.0", - "eth-sig-util": "^1.4.2", - "ethereumjs-block": "^1.2.2", - "ethereumjs-tx": "^1.2.0", - "ethereumjs-util": "^5.1.5", - "ethereumjs-vm": "^2.3.4", - "json-rpc-error": "^2.0.0", - "json-stable-stringify": "^1.0.1", - "promise-to-callback": "^1.0.0", - "readable-stream": "^2.2.9", - "request": "^2.85.0", - "semaphore": "^1.0.3", - "ws": "^5.1.1", - "xhr": "^2.2.0", - "xtend": "^4.0.1" - }, - "dependencies": { - "eth-sig-util": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", - "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", - "dev": true, - "requires": { - "ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", - "ethereumjs-util": "^5.1.1" - } - }, - "ethereumjs-abi": { - "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#572d4bafe08a8a231137e1f9daeb0f8a23f197d2", - "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git", - "dev": true, - "requires": { - "bn.js": "^4.11.8", - "ethereumjs-util": "^6.0.0" - }, - "dependencies": { - "ethereumjs-util": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz", - "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "0.1.6", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-common": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-common/-/ethereumjs-common-1.1.0.tgz", - "integrity": "sha512-LUmYkKV/HcZbWRyu3OU9YOevsH3VJDXtI6kEd8VZweQec+JjDGKCmAVKUyzhYUHqxRJu7JNALZ3A/b3NXOP6tA==", - "dev": true - }, - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - }, - "ethereumjs-vm": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/ethereumjs-vm/-/ethereumjs-vm-2.6.0.tgz", - "integrity": "sha512-r/XIUik/ynGbxS3y+mvGnbOKnuLo40V5Mj1J25+HEO63aWYREIqvWeRO/hnROlMBE5WoniQmPmhiaN0ctiHaXw==", - "dev": true, - "requires": { - "async": "^2.1.2", - "async-eventemitter": "^0.2.2", - "ethereumjs-account": "^2.0.3", - "ethereumjs-block": "~2.2.0", - "ethereumjs-common": "^1.1.0", - "ethereumjs-util": "^6.0.0", - "fake-merkle-patricia-tree": "^1.0.1", - "functional-red-black-tree": "^1.0.1", - "merkle-patricia-tree": "^2.3.2", - "rustbn.js": "~0.2.0", - "safe-buffer": "^5.1.1" - }, - "dependencies": { - "ethereumjs-block": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-2.2.0.tgz", - "integrity": "sha512-Ye+uG/L2wrp364Zihdlr/GfC3ft+zG8PdHcRtsBFNNH1CkOhxOwdB8friBU85n89uRZ9eIMAywCq0F4CwT1wAw==", - "dev": true, - "requires": { - "async": "^2.0.1", - "ethereumjs-common": "^1.1.0", - "ethereumjs-tx": "^1.2.2", - "ethereumjs-util": "^5.0.0", - "merkle-patricia-tree": "^2.1.2" - }, - "dependencies": { - "ethereumjs-util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz", - "integrity": "sha512-CJAKdI0wgMbQFLlLRtZKGcy/L6pzVRgelIZqRqNbuVFM3K9VEnyfbcvz0ncWMRNCe4kaHWjwRYQcYMucmwsnWA==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "^0.1.3", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "ethereumjs-util": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz", - "integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==", - "dev": true, - "requires": { - "bn.js": "^4.11.0", - "create-hash": "^1.1.2", - "ethjs-util": "0.1.6", - "keccak": "^1.0.2", - "rlp": "^2.0.0", - "safe-buffer": "^5.1.1", - "secp256k1": "^3.0.1" - } - } - } - }, - "level-codec": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/level-codec/-/level-codec-7.0.1.tgz", - "integrity": "sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==", - "dev": true - }, - "level-errors": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/level-errors/-/level-errors-1.0.5.tgz", - "integrity": "sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==", - "dev": true, - "requires": { - "errno": "~0.1.1" - } - }, - "levelup": { - "version": "1.3.9", - "resolved": "https://registry.npmjs.org/levelup/-/levelup-1.3.9.tgz", - "integrity": "sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==", - "dev": true, - "requires": { - "deferred-leveldown": "~1.2.1", - "level-codec": "~7.0.0", - "level-errors": "~1.0.3", - "level-iterator-stream": "~1.3.0", - "prr": "~1.0.1", - "semver": "~5.4.1", - "xtend": "~4.0.0" - } - }, - "merkle-patricia-tree": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz", - "integrity": "sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==", - "dev": true, - "requires": { - "async": "^1.4.2", - "ethereumjs-util": "^5.0.0", - "level-ws": "0.0.0", - "levelup": "^1.2.1", - "memdown": "^1.0.0", - "readable-stream": "^2.0.0", - "rlp": "^2.0.0", - "semaphore": ">=1.0.1" - }, - "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", - "dev": true - } - } - }, - "ws": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz", - "integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==", - "dev": true, - "requires": { - "async-limiter": "~1.0.0" - } - } - } - }, - "web3-providers": { - "version": "1.0.0-beta.48", - "resolved": "https://registry.npmjs.org/web3-providers/-/web3-providers-1.0.0-beta.48.tgz", - "integrity": "sha512-rqWe370lftaYqvTSe8b7vdaANEBeoME6f30yD8VIEkKD6iEbp5TqCtP6A22zC6CEcVnCUrXIKsBCSI71f+QEtw==", - "dev": true, - "requires": { - "@babel/runtime": "^7.3.1", - "@types/node": "^10.12.18", - "eventemitter3": "3.1.0", - "lodash": "^4.17.11", - "oboe": "2.1.4", - "url-parse": "1.4.4", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", - "xhr2-cookies": "1.1.0" - }, - "dependencies": { - "eventemitter3": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", - "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==", - "dev": true - }, - "oboe": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/oboe/-/oboe-2.1.4.tgz", - "integrity": "sha1-IMiM2wwVNxuwQRklfU/dNLCqSfY=", - "dev": true, - "requires": { - "http-https": "^1.0.0" - } - }, - "websocket": { - "version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", - "from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible", - "dev": true, - "requires": { - "debug": "^2.2.0", - "nan": "^2.3.3", - "typedarray-to-buffer": "^3.1.2", - "yaeti": "^0.0.6" - } - } - } - }, "web3-providers-http": { "version": "1.0.0-beta.37", "resolved": "https://registry.npmjs.org/web3-providers-http/-/web3-providers-http-1.0.0-beta.37.tgz", @@ -9045,7 +6818,7 @@ "requires": { "underscore": "1.8.3", "web3-core-helpers": "1.0.0-beta.37", - "websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2" + "websocket": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible" }, "dependencies": { "websocket": { @@ -9102,24 +6875,6 @@ } } }, - "websocket": { - "version": "1.0.26", - "resolved": "https://registry.npmjs.org/websocket/-/websocket-1.0.26.tgz", - "integrity": "sha512-fjcrYDPIQxpTnqFQ9JjxUQcdvR89MFAOjPBlF+vjOt49w/XW4fJknUoMz/mDIn2eK1AdslVojcaOxOqyZZV8rw==", - "dev": true, - "requires": { - "debug": "^2.2.0", - "nan": "^2.3.3", - "typedarray-to-buffer": "^3.1.2", - "yaeti": "^0.0.6" - } - }, - "whatwg-fetch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==", - "dev": true - }, "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", From 3cd9d5b13457a78dd06b01a1b21657f5e5b78bad Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 23 Apr 2019 19:58:07 -0300 Subject: [PATCH 18/20] address review comments --- .../crowdsale/price/IncreasingPriceCrowdsale.sol | 4 ++-- .../crowdsale/validation/TimedCrowdsale.sol | 2 +- contracts/drafts/TokenVesting.sol | 2 +- contracts/token/ERC20/SafeERC20.sol | 2 +- contracts/token/ERC721/ERC721.sol | 8 ++++---- contracts/token/ERC721/ERC721Metadata.sol | 2 +- .../access/roles/PublicRole.behavior.js | 1 - test/crowdsale/IncreasingPriceCrowdsale.test.js | 6 +++--- test/crowdsale/MintedCrowdsale.test.js | 8 ++------ test/crowdsale/TimedCrowdsale.test.js | 4 ++-- test/drafts/SignedSafeMath.test.js | 15 +++++++-------- test/drafts/TokenVesting.test.js | 2 +- test/math/SafeMath.test.js | 11 +++++------ test/ownership/Ownable.behavior.js | 6 +++--- test/token/ERC20/ERC20.test.js | 3 ++- test/token/ERC20/SafeERC20.test.js | 16 ++++++++-------- test/token/ERC721/ERC721.behavior.js | 6 +++--- test/token/ERC721/ERC721.test.js | 14 +++++++------- test/token/ERC721/ERC721Full.test.js | 2 +- test/token/ERC721/ERC721MintBurn.behavior.js | 4 ++-- 20 files changed, 56 insertions(+), 62 deletions(-) diff --git a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol index 345d3cc733a..095970b2a57 100644 --- a/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ b/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol @@ -23,7 +23,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { constructor (uint256 initialRate, uint256 finalRate) public { require(finalRate > 0, "IncreasingPriceCrowdsale: final rate is 0"); // solhint-disable-next-line max-line-length - require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate is less than final rate"); + require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate is not greater than final rate"); _initialRate = initialRate; _finalRate = finalRate; } @@ -33,7 +33,7 @@ contract IncreasingPriceCrowdsale is TimedCrowdsale { * all calls to it are a mistake. */ function rate() public view returns (uint256) { - revert(); + revert("IncreasingPriceCrowdsale: rate() called"); } /** diff --git a/contracts/crowdsale/validation/TimedCrowdsale.sol b/contracts/crowdsale/validation/TimedCrowdsale.sol index a655f5abeec..d7fbd14e9b7 100644 --- a/contracts/crowdsale/validation/TimedCrowdsale.sol +++ b/contracts/crowdsale/validation/TimedCrowdsale.sol @@ -37,7 +37,7 @@ contract TimedCrowdsale is Crowdsale { // solhint-disable-next-line not-rely-on-time require(openingTime >= block.timestamp, "TimedCrowdsale: opening time is before current time"); // solhint-disable-next-line max-line-length - require(closingTime > openingTime, "TimedCrowdsale: closing time is before opening time"); + require(closingTime > openingTime, "TimedCrowdsale: opening time is not before closing time"); _openingTime = openingTime; _closingTime = closingTime; diff --git a/contracts/drafts/TokenVesting.sol b/contracts/drafts/TokenVesting.sol index 631f3477407..df7a28db48d 100644 --- a/contracts/drafts/TokenVesting.sol +++ b/contracts/drafts/TokenVesting.sol @@ -52,7 +52,7 @@ contract TokenVesting is Ownable { require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); require(duration > 0, "TokenVesting: duration is 0"); // solhint-disable-next-line max-line-length - require(start.add(duration) > block.timestamp, "TokenVesting: starting time is before current time"); + require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); _beneficiary = beneficiary; _revocable = revocable; diff --git a/contracts/token/ERC20/SafeERC20.sol b/contracts/token/ERC20/SafeERC20.sol index c8ce656049c..5e14549b3a3 100644 --- a/contracts/token/ERC20/SafeERC20.sol +++ b/contracts/token/ERC20/SafeERC20.sol @@ -69,7 +69,7 @@ library SafeERC20 { if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), "SafeERC20: unknown low-level call return data"); + require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } } diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index 65be6162fc5..cce864dcda0 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -71,7 +71,7 @@ contract ERC721 is ERC165, IERC721 { */ function ownerOf(uint256 tokenId) public view returns (address) { address owner = _tokenOwner[tokenId]; - require(owner != address(0), "ERC721: owner query of nonexistent token"); + require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } @@ -103,7 +103,7 @@ contract ERC721 is ERC165, IERC721 { * @return address currently approved for the given token ID */ function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "ERC721: approved query of nonexistent token"); + require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } @@ -225,7 +225,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token being burned */ function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner, "ERC721: burn of unowned token"); + require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own"); _clearApproval(tokenId); @@ -252,7 +252,7 @@ contract ERC721 is ERC165, IERC721 { * @param tokenId uint256 ID of the token to be transferred */ function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from, "ERC721: transfer of unowned token"); + require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _clearApproval(tokenId); diff --git a/contracts/token/ERC721/ERC721Metadata.sol b/contracts/token/ERC721/ERC721Metadata.sol index e4d3e31773f..7b295c7eedc 100644 --- a/contracts/token/ERC721/ERC721Metadata.sol +++ b/contracts/token/ERC721/ERC721Metadata.sol @@ -56,7 +56,7 @@ contract ERC721Metadata is ERC165, ERC721, IERC721Metadata { * @param tokenId uint256 ID of the token to query */ function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId), "ERC721Metadata: query of nonexistent token"); + require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); return _tokenURIs[tokenId]; } diff --git a/test/behaviors/access/roles/PublicRole.behavior.js b/test/behaviors/access/roles/PublicRole.behavior.js index 286ef2c3c07..fcdc03005a5 100644 --- a/test/behaviors/access/roles/PublicRole.behavior.js +++ b/test/behaviors/access/roles/PublicRole.behavior.js @@ -56,7 +56,6 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen context('from unauthorized account', function () { const from = other; - //, "CapperRole: caller does not have the Capper role" it('reverts', async function () { await shouldFail.reverting.withMessage(this.contract[`only${rolename}Mock`]({ from }), `${rolename}Role: caller does not have the ${rolename} role` diff --git a/test/crowdsale/IncreasingPriceCrowdsale.test.js b/test/crowdsale/IncreasingPriceCrowdsale.test.js index e8f041136d7..ba4ad0b8747 100644 --- a/test/crowdsale/IncreasingPriceCrowdsale.test.js +++ b/test/crowdsale/IncreasingPriceCrowdsale.test.js @@ -28,13 +28,13 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) it('reverts with a final rate larger than the initial rate', async function () { await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate.addn(1) - ), 'IncreasingPriceCrowdsale: initial rate is less than final rate'); + ), 'IncreasingPriceCrowdsale: initial rate is not greater than final rate'); }); it('reverts with a final rate equal to the initial rate', async function () { await shouldFail.reverting.withMessage(IncreasingPriceCrowdsaleImpl.new( this.startTime, this.closingTime, wallet, this.token.address, initialRate, initialRate - ), 'IncreasingPriceCrowdsale: initial rate is less than final rate'); + ), 'IncreasingPriceCrowdsale: initial rate is not greater than final rate'); }); it('reverts with a final rate of zero', async function () { @@ -58,7 +58,7 @@ contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) it('reverts when the base Crowdsale\'s rate function is called', async function () { await shouldFail.reverting.withMessage(this.crowdsale.rate(), - 'VM Exception while processing transaction: revert' + 'IncreasingPriceCrowdsale: rate() called' ); }); diff --git a/test/crowdsale/MintedCrowdsale.test.js b/test/crowdsale/MintedCrowdsale.test.js index 3351ad8d65f..2928f0142dc 100644 --- a/test/crowdsale/MintedCrowdsale.test.js +++ b/test/crowdsale/MintedCrowdsale.test.js @@ -32,15 +32,11 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser] }); it('rejects bare payments', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.send(value), - 'VM Exception while processing transaction: revert' - ); + await shouldFail.reverting(this.crowdsale.send(value)); }); it('rejects token purchases', async function () { - await shouldFail.reverting.withMessage(this.crowdsale.buyTokens(investor, { value: value, from: purchaser }), - 'VM Exception while processing transaction: revert' - ); + await shouldFail.reverting(this.crowdsale.buyTokens(investor, { value: value, from: purchaser })); }); }); }); diff --git a/test/crowdsale/TimedCrowdsale.test.js b/test/crowdsale/TimedCrowdsale.test.js index da082d633b0..bcc1c729673 100644 --- a/test/crowdsale/TimedCrowdsale.test.js +++ b/test/crowdsale/TimedCrowdsale.test.js @@ -29,13 +29,13 @@ contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) { it('reverts if the closing time is before the opening time', async function () { await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime.sub(time.duration.seconds(1)), rate, wallet, this.token.address - ), 'TimedCrowdsale: closing time is before opening time'); + ), 'TimedCrowdsale: opening time is not before closing time'); }); it('reverts if the closing time equals the opening time', async function () { await shouldFail.reverting.withMessage(TimedCrowdsaleImpl.new( this.openingTime, this.openingTime, rate, wallet, this.token.address - ), 'TimedCrowdsale: closing time is before opening time'); + ), 'TimedCrowdsale: opening time is not before closing time'); }); context('with crowdsale', function () { diff --git a/test/drafts/SignedSafeMath.test.js b/test/drafts/SignedSafeMath.test.js index 01c954853a3..2f24ce869d5 100644 --- a/test/drafts/SignedSafeMath.test.js +++ b/test/drafts/SignedSafeMath.test.js @@ -13,10 +13,9 @@ contract('SignedSafeMath', function () { (await fn(rhs, lhs)).should.be.bignumber.equal(expected); } - async function testFailsCommutative (fn, lhs, rhs) { - // TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages - await shouldFail.reverting.withMessage(fn(lhs, rhs)); - await shouldFail.reverting.withMessage(fn(rhs, lhs)); + async function testFailsCommutative (fn, lhs, rhs, reason) { + await shouldFail.reverting.withMessage(fn(lhs, rhs), reason); + await shouldFail.reverting.withMessage(fn(rhs, lhs), reason); } describe('add', function () { @@ -38,14 +37,14 @@ contract('SignedSafeMath', function () { const a = MAX_INT256; const b = new BN('1'); - await testFailsCommutative(this.safeMath.add, a, b); + await testFailsCommutative(this.safeMath.add, a, b, 'SignedSafeMath: addition overflow'); }); it('reverts on negative addition overflow', async function () { const a = MIN_INT256; const b = new BN('-1'); - await testFailsCommutative(this.safeMath.add, a, b); + await testFailsCommutative(this.safeMath.add, a, b, 'SignedSafeMath: addition overflow'); }); }); @@ -100,14 +99,14 @@ contract('SignedSafeMath', function () { const a = MAX_INT256; const b = new BN('2'); - await testFailsCommutative(this.safeMath.mul, a, b); + await testFailsCommutative(this.safeMath.mul, a, b, 'SignedSafeMath: multiplication overflow'); }); it('reverts when minimum integer is multiplied by -1', async function () { const a = MIN_INT256; const b = new BN('-1'); - await testFailsCommutative(this.safeMath.mul, a, b); + await testFailsCommutative(this.safeMath.mul, a, b, 'SignedSafeMath: multiplication overflow'); }); }); diff --git a/test/drafts/TokenVesting.test.js b/test/drafts/TokenVesting.test.js index 46050b10682..6e6ac498c1c 100644 --- a/test/drafts/TokenVesting.test.js +++ b/test/drafts/TokenVesting.test.js @@ -46,7 +46,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { this.start = now.sub(this.duration).sub(time.duration.minutes(1)); await shouldFail.reverting.withMessage( TokenVesting.new(beneficiary, this.start, this.cliffDuration, this.duration, true, { from: owner }), - 'TokenVesting: starting time is before current time' + 'TokenVesting: final time is before current time' ); }); diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index 001900278b0..3657bec45fa 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -13,10 +13,9 @@ contract('SafeMath', function () { (await fn(rhs, lhs)).should.be.bignumber.equal(expected); } - async function testFailsCommutative (fn, lhs, rhs) { - // TODO @nventuro How to distinguish between add() & mul() calls s.t. to show the appropriate messages - await shouldFail.reverting.withMessage(fn(lhs, rhs)); - await shouldFail.reverting.withMessage(fn(rhs, lhs)); + async function testFailsCommutative (fn, lhs, rhs, reason) { + await shouldFail.reverting.withMessage(fn(lhs, rhs), reason); + await shouldFail.reverting.withMessage(fn(rhs, lhs), reason); } describe('add', function () { @@ -31,7 +30,7 @@ contract('SafeMath', function () { const a = MAX_UINT256; const b = new BN('1'); - await testFailsCommutative(this.safeMath.add, a, b); + await testFailsCommutative(this.safeMath.add, a, b, 'SafeMath: addition overflow'); }); }); @@ -70,7 +69,7 @@ contract('SafeMath', function () { const a = MAX_UINT256; const b = new BN('2'); - await testFailsCommutative(this.safeMath.mul, a, b); + await testFailsCommutative(this.safeMath.mul, a, b, "SafeMath: multiplication overflow"); }); }); diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index be956e06f72..1571ef17e56 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -17,11 +17,11 @@ function shouldBehaveLikeOwnable (owner, [other]) { }); it('should prevent non-owners from transferring', async function () { - await shouldFail.reverting.withMessage(this.ownable.transferOwnership(other, { from: other })); + await shouldFail.reverting.withMessage(this.ownable.transferOwnership(other, { from: other }), 'Ownable: caller is not the owner'); }); it('should guard ownership against stuck state', async function () { - await shouldFail.reverting.withMessage(this.ownable.transferOwnership(ZERO_ADDRESS, { from: owner })); + await shouldFail.reverting.withMessage(this.ownable.transferOwnership(ZERO_ADDRESS, { from: owner }), 'Ownable: new owner is the zero address'); }); it('loses owner after renouncement', async function () { @@ -32,7 +32,7 @@ function shouldBehaveLikeOwnable (owner, [other]) { }); it('should prevent non-owners from renouncement', async function () { - await shouldFail.reverting.withMessage(this.ownable.renounceOwnership({ from: other })); + await shouldFail.reverting.withMessage(this.ownable.renounceOwnership({ from: other }), 'Ownable: caller is not the owner'); }); }); } diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 1ece8377ec1..81e16752969 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -223,7 +223,8 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { it('reverts when more than the full allowance is removed', async function () { await shouldFail.reverting.withMessage( - this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }, 'no idea') + this.token.decreaseAllowance(spender, approvedAmount.addn(1), { from: initialHolder }), + 'SafeMath: subtraction overflow' ); }); }); diff --git a/test/token/ERC20/SafeERC20.test.js b/test/token/ERC20/SafeERC20.test.js index e514808f7fa..acdac9cfa21 100644 --- a/test/token/ERC20/SafeERC20.test.js +++ b/test/token/ERC20/SafeERC20.test.js @@ -41,23 +41,23 @@ contract('SafeERC20', function ([_, hasNoCode]) { function shouldRevertOnAllCalls () { it('reverts on transfer', async function () { - await shouldFail.reverting.withMessage(this.wrapper.transfer()); + await shouldFail.reverting.withMessage(this.wrapper.transfer(), "SafeERC20: low-level call failed"); }); it('reverts on transferFrom', async function () { - await shouldFail.reverting.withMessage(this.wrapper.transferFrom()); + await shouldFail.reverting.withMessage(this.wrapper.transferFrom(), "SafeERC20: low-level call failed"); }); it('reverts on approve', async function () { - await shouldFail.reverting.withMessage(this.wrapper.approve(0)); + await shouldFail.reverting.withMessage(this.wrapper.approve(0), "SafeERC20: low-level call failed"); }); it('reverts on increaseAllowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.increaseAllowance(0)); + await shouldFail.reverting.withMessage(this.wrapper.increaseAllowance(0), "SafeERC20: low-level call failed"); }); it('reverts on decreaseAllowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(0)); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(0), "SafeERC20: low-level call failed"); }); } @@ -89,7 +89,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(10)); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(10), "SafeERC20: low-level call failed"); }); }); @@ -99,7 +99,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when approving a non-zero allowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.approve(20)); + await shouldFail.reverting.withMessage(this.wrapper.approve(20), "SafeERC20: low-level call failed"); }); it('doesn\'t revert when approving a zero allowance', async function () { @@ -115,7 +115,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance to a negative value', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(200)); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(200), "SafeERC20: low-level call failed"); }); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 31c7b3f959a..190b0527736 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -57,7 +57,7 @@ function shouldBehaveLikeERC721 ( it('reverts', async function () { await shouldFail.reverting.withMessage( - this.token.ownerOf(tokenId), 'ERC721: owner query of nonexistent token' + this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token' ); }); }); @@ -183,7 +183,7 @@ function shouldBehaveLikeERC721 ( context('when the address of the previous owner is incorrect', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - transferFunction.call(this, other, other, tokenId, { from: owner }), 'ERC721: transfer of unowned token' + transferFunction.call(this, other, other, tokenId, { from: owner }), 'ERC721: transfer of token that is not own' ); }); }); @@ -438,7 +438,7 @@ function shouldBehaveLikeERC721 ( context('when the given token ID does not exist', function () { it('reverts', async function () { await shouldFail.reverting.withMessage(this.token.approve(approved, unknownTokenId, { from: operator }), - 'ERC721: owner query of nonexistent token'); + 'ERC721: owner query for nonexistent token'); }); }); }); diff --git a/test/token/ERC721/ERC721.test.js b/test/token/ERC721/ERC721.test.js index 9f2ddc16d47..95cd3f707c3 100644 --- a/test/token/ERC721/ERC721.test.js +++ b/test/token/ERC721/ERC721.test.js @@ -44,7 +44,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { describe('_burn(address, uint256)', function () { it('reverts when burning a non-existent token id', async function () { await shouldFail.reverting.withMessage( - this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), 'ERC721: owner query of nonexistent token' + this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), 'ERC721: owner query for nonexistent token' ); }); @@ -55,7 +55,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('reverts when the account is not the owner', async function () { await shouldFail.reverting.withMessage( - this.token.methods['burn(address,uint256)'](other, tokenId), 'ERC721: burn of unowned token' + this.token.methods['burn(address,uint256)'](other, tokenId), 'ERC721: burn of token that is not own' ); }); @@ -71,14 +71,14 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); await shouldFail.reverting.withMessage( - this.token.ownerOf(tokenId), 'ERC721: owner query of nonexistent token' + this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token' ); }); it('reverts when burning a token id that has been deleted', async function () { await shouldFail.reverting.withMessage( this.token.methods['burn(address,uint256)'](tokenOwner, tokenId), - 'ERC721: owner query of nonexistent token' + 'ERC721: owner query for nonexistent token' ); }); }); @@ -88,7 +88,7 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { describe('_burn(uint256)', function () { it('reverts when burning a non-existent token id', async function () { await shouldFail.reverting.withMessage( - this.token.methods['burn(uint256)'](tokenId), 'ERC721: owner query of nonexistent token' + this.token.methods['burn(uint256)'](tokenId), 'ERC721: owner query for nonexistent token' ); }); @@ -109,13 +109,13 @@ contract('ERC721', function ([_, creator, tokenOwner, other, ...accounts]) { it('deletes the token', async function () { (await this.token.balanceOf(tokenOwner)).should.be.bignumber.equal('0'); await shouldFail.reverting.withMessage( - this.token.ownerOf(tokenId), 'ERC721: owner query of nonexistent token' + this.token.ownerOf(tokenId), 'ERC721: owner query for nonexistent token' ); }); it('reverts when burning a token id that has been deleted', async function () { await shouldFail.reverting.withMessage( - this.token.methods['burn(uint256)'](tokenId), 'ERC721: owner query of nonexistent token' + this.token.methods['burn(uint256)'](tokenId), 'ERC721: owner query for nonexistent token' ); }); }); diff --git a/test/token/ERC721/ERC721Full.test.js b/test/token/ERC721/ERC721Full.test.js index d166d5b4921..cb02c43c318 100644 --- a/test/token/ERC721/ERC721Full.test.js +++ b/test/token/ERC721/ERC721Full.test.js @@ -104,7 +104,7 @@ contract('ERC721Full', function ([ it('reverts when querying metadata for non existent token id', async function () { await shouldFail.reverting.withMessage( - this.token.tokenURI(nonExistentTokenId), 'ERC721Metadata: query of nonexistent token' + this.token.tokenURI(nonExistentTokenId), 'ERC721Metadata: URI query for nonexistent token' ); }); }); diff --git a/test/token/ERC721/ERC721MintBurn.behavior.js b/test/token/ERC721/ERC721MintBurn.behavior.js index d9de268e365..814867222dd 100644 --- a/test/token/ERC721/ERC721MintBurn.behavior.js +++ b/test/token/ERC721/ERC721MintBurn.behavior.js @@ -83,7 +83,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( it('burns the given token ID and adjusts the balance of the owner', async function () { await shouldFail.reverting.withMessage( this.token.ownerOf(tokenId), - 'ERC721: owner query of nonexistent token' + 'ERC721: owner query for nonexistent token' ); (await this.token.balanceOf(owner)).should.be.bignumber.equal('1'); }); @@ -107,7 +107,7 @@ function shouldBehaveLikeMintAndBurnERC721 ( context('getApproved', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - this.token.getApproved(tokenId), 'ERC721: approved query of nonexistent token' + this.token.getApproved(tokenId), 'ERC721: approved query for nonexistent token' ); }); }); From a0eda429be1d34a8f267d222da2cb26998d8bdcf Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 23 Apr 2019 20:03:56 -0300 Subject: [PATCH 19/20] fix linter issues --- package-lock.json | 4 ++-- test/math/SafeMath.test.js | 2 +- test/ownership/Ownable.behavior.js | 15 ++++++++++++--- test/token/ERC20/ERC20.test.js | 2 +- test/token/ERC20/SafeERC20.test.js | 16 ++++++++-------- test/token/ERC721/ERC721.behavior.js | 3 ++- 6 files changed, 26 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index c36c4d1ef3d..5a984e6b52b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3808,7 +3808,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } @@ -4438,7 +4438,7 @@ "dependencies": { "pify": { "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "resolved": "http://registry.npmjs.org/pify/-/pify-2.3.0.tgz", "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true } diff --git a/test/math/SafeMath.test.js b/test/math/SafeMath.test.js index 3657bec45fa..3a717a6add3 100644 --- a/test/math/SafeMath.test.js +++ b/test/math/SafeMath.test.js @@ -69,7 +69,7 @@ contract('SafeMath', function () { const a = MAX_UINT256; const b = new BN('2'); - await testFailsCommutative(this.safeMath.mul, a, b, "SafeMath: multiplication overflow"); + await testFailsCommutative(this.safeMath.mul, a, b, 'SafeMath: multiplication overflow'); }); }); diff --git a/test/ownership/Ownable.behavior.js b/test/ownership/Ownable.behavior.js index 1571ef17e56..308de2ffead 100644 --- a/test/ownership/Ownable.behavior.js +++ b/test/ownership/Ownable.behavior.js @@ -17,11 +17,17 @@ function shouldBehaveLikeOwnable (owner, [other]) { }); it('should prevent non-owners from transferring', async function () { - await shouldFail.reverting.withMessage(this.ownable.transferOwnership(other, { from: other }), 'Ownable: caller is not the owner'); + await shouldFail.reverting.withMessage( + this.ownable.transferOwnership(other, { from: other }), + 'Ownable: caller is not the owner' + ); }); it('should guard ownership against stuck state', async function () { - await shouldFail.reverting.withMessage(this.ownable.transferOwnership(ZERO_ADDRESS, { from: owner }), 'Ownable: new owner is the zero address'); + await shouldFail.reverting.withMessage( + this.ownable.transferOwnership(ZERO_ADDRESS, { from: owner }), + 'Ownable: new owner is the zero address' + ); }); it('loses owner after renouncement', async function () { @@ -32,7 +38,10 @@ function shouldBehaveLikeOwnable (owner, [other]) { }); it('should prevent non-owners from renouncement', async function () { - await shouldFail.reverting.withMessage(this.ownable.renounceOwnership({ from: other }), 'Ownable: caller is not the owner'); + await shouldFail.reverting.withMessage( + this.ownable.renounceOwnership({ from: other }), + 'Ownable: caller is not the owner' + ); }); }); } diff --git a/test/token/ERC20/ERC20.test.js b/test/token/ERC20/ERC20.test.js index 81e16752969..ba506d51967 100644 --- a/test/token/ERC20/ERC20.test.js +++ b/test/token/ERC20/ERC20.test.js @@ -427,7 +427,7 @@ contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) { beforeEach('approving', async function () { await this.token.approve(spender, allowance, { from: initialHolder }); }); - + it('rejects a null account', async function () { await shouldFail.reverting.withMessage(this.token.burnFrom(ZERO_ADDRESS, new BN(1)), 'ERC20: burn from the zero address' diff --git a/test/token/ERC20/SafeERC20.test.js b/test/token/ERC20/SafeERC20.test.js index acdac9cfa21..4958dff0adc 100644 --- a/test/token/ERC20/SafeERC20.test.js +++ b/test/token/ERC20/SafeERC20.test.js @@ -41,23 +41,23 @@ contract('SafeERC20', function ([_, hasNoCode]) { function shouldRevertOnAllCalls () { it('reverts on transfer', async function () { - await shouldFail.reverting.withMessage(this.wrapper.transfer(), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.transfer(), 'SafeERC20: low-level call failed'); }); it('reverts on transferFrom', async function () { - await shouldFail.reverting.withMessage(this.wrapper.transferFrom(), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.transferFrom(), 'SafeERC20: low-level call failed'); }); it('reverts on approve', async function () { - await shouldFail.reverting.withMessage(this.wrapper.approve(0), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.approve(0), 'SafeERC20: low-level call failed'); }); it('reverts on increaseAllowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.increaseAllowance(0), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.increaseAllowance(0), 'SafeERC20: low-level call failed'); }); it('reverts on decreaseAllowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(0), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(0), 'SafeERC20: low-level call failed'); }); } @@ -89,7 +89,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(10), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(10), 'SafeERC20: low-level call failed'); }); }); @@ -99,7 +99,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when approving a non-zero allowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.approve(20), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.approve(20), 'SafeERC20: low-level call failed'); }); it('doesn\'t revert when approving a zero allowance', async function () { @@ -115,7 +115,7 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance to a negative value', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(200), "SafeERC20: low-level call failed"); + await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(200), 'SafeERC20: low-level call failed'); }); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 190b0527736..75c8187c00c 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -183,7 +183,8 @@ function shouldBehaveLikeERC721 ( context('when the address of the previous owner is incorrect', function () { it('reverts', async function () { await shouldFail.reverting.withMessage( - transferFunction.call(this, other, other, tokenId, { from: owner }), 'ERC721: transfer of token that is not own' + transferFunction.call(this, other, other, tokenId, { from: owner }), + 'ERC721: transfer of token that is not own' ); }); }); From fb2aa30d61d0389d6bd6d55e8a96501a6a24f40b Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 23 Apr 2019 20:45:05 -0300 Subject: [PATCH 20/20] fix remaining revert reasons --- contracts/token/ERC721/ERC721.sol | 2 +- test/token/ERC20/SafeERC20.test.js | 33 ++++++++++++++++++---------- test/token/ERC721/ERC721.behavior.js | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/contracts/token/ERC721/ERC721.sol b/contracts/token/ERC721/ERC721.sol index ec7807c5899..e71905c56ad 100644 --- a/contracts/token/ERC721/ERC721.sol +++ b/contracts/token/ERC721/ERC721.sol @@ -89,7 +89,7 @@ contract ERC721 is ERC165, IERC721 { require(to != owner, "ERC721: transfer to current owner"); require(msg.sender == owner || isApprovedForAll(owner, msg.sender), - "ERC721: approve caller is not owner nor approved" + "ERC721: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; diff --git a/test/token/ERC20/SafeERC20.test.js b/test/token/ERC20/SafeERC20.test.js index 4958dff0adc..3271cae968b 100644 --- a/test/token/ERC20/SafeERC20.test.js +++ b/test/token/ERC20/SafeERC20.test.js @@ -11,7 +11,7 @@ contract('SafeERC20', function ([_, hasNoCode]) { this.wrapper = await SafeERC20Wrapper.new(hasNoCode); }); - shouldRevertOnAllCalls(); + shouldRevertOnAllCalls('SafeERC20: call to non-contract'); }); describe('with token that returns false on all calls', function () { @@ -19,7 +19,7 @@ contract('SafeERC20', function ([_, hasNoCode]) { this.wrapper = await SafeERC20Wrapper.new((await ERC20ReturnFalseMock.new()).address); }); - shouldRevertOnAllCalls(); + shouldRevertOnAllCalls('SafeERC20: ERC20 operation did not succeed'); }); describe('with token that returns true on all calls', function () { @@ -39,25 +39,27 @@ contract('SafeERC20', function ([_, hasNoCode]) { }); }); -function shouldRevertOnAllCalls () { +function shouldRevertOnAllCalls (reason) { it('reverts on transfer', async function () { - await shouldFail.reverting.withMessage(this.wrapper.transfer(), 'SafeERC20: low-level call failed'); + await shouldFail.reverting.withMessage(this.wrapper.transfer(), reason); }); it('reverts on transferFrom', async function () { - await shouldFail.reverting.withMessage(this.wrapper.transferFrom(), 'SafeERC20: low-level call failed'); + await shouldFail.reverting.withMessage(this.wrapper.transferFrom(), reason); }); it('reverts on approve', async function () { - await shouldFail.reverting.withMessage(this.wrapper.approve(0), 'SafeERC20: low-level call failed'); + await shouldFail.reverting.withMessage(this.wrapper.approve(0), reason); }); it('reverts on increaseAllowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.increaseAllowance(0), 'SafeERC20: low-level call failed'); + // [TODO] make sure it's reverting for the right reason + await shouldFail.reverting(this.wrapper.increaseAllowance(0)); }); it('reverts on decreaseAllowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(0), 'SafeERC20: low-level call failed'); + // [TODO] make sure it's reverting for the right reason + await shouldFail.reverting(this.wrapper.decreaseAllowance(0)); }); } @@ -89,7 +91,10 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(10), 'SafeERC20: low-level call failed'); + await shouldFail.reverting.withMessage( + this.wrapper.decreaseAllowance(10), + 'SafeMath: subtraction overflow' + ); }); }); @@ -99,7 +104,10 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when approving a non-zero allowance', async function () { - await shouldFail.reverting.withMessage(this.wrapper.approve(20), 'SafeERC20: low-level call failed'); + await shouldFail.reverting.withMessage( + this.wrapper.approve(20), + 'SafeERC20: approve from non-zero to non-zero allowance' + ); }); it('doesn\'t revert when approving a zero allowance', async function () { @@ -115,7 +123,10 @@ function shouldOnlyRevertOnErrors () { }); it('reverts when decreasing the allowance to a negative value', async function () { - await shouldFail.reverting.withMessage(this.wrapper.decreaseAllowance(200), 'SafeERC20: low-level call failed'); + await shouldFail.reverting.withMessage( + this.wrapper.decreaseAllowance(200), + 'SafeMath: subtraction overflow' + ); }); }); }); diff --git a/test/token/ERC721/ERC721.behavior.js b/test/token/ERC721/ERC721.behavior.js index 75c8187c00c..673e52be278 100644 --- a/test/token/ERC721/ERC721.behavior.js +++ b/test/token/ERC721/ERC721.behavior.js @@ -422,7 +422,7 @@ function shouldBehaveLikeERC721 ( it('reverts', async function () { await this.token.approve(approved, tokenId, { from: owner }); await shouldFail.reverting.withMessage(this.token.approve(anotherApproved, tokenId, { from: approved }), - 'ERC721: approve caller is not owner nor approved'); + 'ERC721: approve caller is not owner nor approved for all'); }); });