aboutsummaryrefslogtreecommitdiffstats
path: root/test/compilationTests/milestonetracker
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-12 07:49:00 +0800
committerchriseth <chris@ethereum.org>2018-07-16 21:33:31 +0800
commitbdac82ecdbb6a4d27e9c5b11ce48d2d653a652e6 (patch)
treedb49e85ba17521aa55af555ab7b064894e587fbb /test/compilationTests/milestonetracker
parentaa08460d94f0e3ac8e067f89786175fb5ebba73b (diff)
downloaddexon-solidity-bdac82ecdbb6a4d27e9c5b11ce48d2d653a652e6.tar.gz
dexon-solidity-bdac82ecdbb6a4d27e9c5b11ce48d2d653a652e6.tar.zst
dexon-solidity-bdac82ecdbb6a4d27e9c5b11ce48d2d653a652e6.zip
Replace throw with revert() in compilation tests
Diffstat (limited to 'test/compilationTests/milestonetracker')
-rw-r--r--test/compilationTests/milestonetracker/MilestoneTracker.sol56
-rw-r--r--test/compilationTests/milestonetracker/RLP.sol38
2 files changed, 47 insertions, 47 deletions
diff --git a/test/compilationTests/milestonetracker/MilestoneTracker.sol b/test/compilationTests/milestonetracker/MilestoneTracker.sol
index c123862f..856fb1a5 100644
--- a/test/compilationTests/milestonetracker/MilestoneTracker.sol
+++ b/test/compilationTests/milestonetracker/MilestoneTracker.sol
@@ -83,14 +83,14 @@ contract MilestoneTracker {
/// @dev The following modifiers only allow specific roles to call functions
/// with these modifiers
- modifier onlyRecipient { if (msg.sender != recipient) throw; _; }
- modifier onlyArbitrator { if (msg.sender != arbitrator) throw; _; }
- modifier onlyDonor { if (msg.sender != donor) throw; _; }
+ modifier onlyRecipient { if (msg.sender != recipient) revert(); _; }
+ modifier onlyArbitrator { if (msg.sender != arbitrator) revert(); _; }
+ modifier onlyDonor { if (msg.sender != donor) revert(); _; }
/// @dev The following modifiers prevent functions from being called if the
/// campaign has been canceled or if new milestones are being proposed
- modifier campaignNotCanceled { if (campaignCanceled) throw; _; }
- modifier notChanging { if (changingMilestones) throw; _; }
+ modifier campaignNotCanceled { if (campaignCanceled) revert(); _; }
+ modifier notChanging { if (changingMilestones) revert(); _; }
// @dev Events to make the payment movements easy to find on the blockchain
event NewMilestoneListProposed();
@@ -204,8 +204,8 @@ contract MilestoneTracker {
uint i;
- if (!changingMilestones) throw;
- if (keccak256(proposedMilestones) != _hashProposals) throw;
+ if (!changingMilestones) revert();
+ if (keccak256(proposedMilestones) != _hashProposals) revert();
// Cancel all the unfinished milestones
for (i=0; i<milestones.length; i++) {
@@ -218,7 +218,7 @@ contract MilestoneTracker {
RLP.RLPItem memory itmProposals = mProposedMilestones.toRLPItem(true);
- if (!itmProposals.isList()) throw;
+ if (!itmProposals.isList()) revert();
RLP.Iterator memory itrProposals = itmProposals.iterator();
@@ -229,7 +229,7 @@ contract MilestoneTracker {
Milestone storage milestone = milestones[milestones.length ++];
- if (!itmProposal.isList()) throw;
+ if (!itmProposal.isList()) revert();
RLP.Iterator memory itrProposal = itmProposal.iterator();
@@ -258,14 +258,14 @@ contract MilestoneTracker {
function markMilestoneComplete(uint _idMilestone)
public campaignNotCanceled notChanging
{
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
if ( (msg.sender != milestone.milestoneLeadLink)
&&(msg.sender != recipient))
- throw;
- if (milestone.status != MilestoneStatus.AcceptedAndInProgress) throw;
- if (now < milestone.minCompletionDate) throw;
- if (now > milestone.maxCompletionDate) throw;
+ revert();
+ if (milestone.status != MilestoneStatus.AcceptedAndInProgress) revert();
+ if (now < milestone.minCompletionDate) revert();
+ if (now > milestone.maxCompletionDate) revert();
milestone.status = MilestoneStatus.Completed;
milestone.doneTime = now;
emit ProposalStatusChanged(_idMilestone, milestone.status);
@@ -276,10 +276,10 @@ contract MilestoneTracker {
function approveCompletedMilestone(uint _idMilestone)
public campaignNotCanceled notChanging
{
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
if ((msg.sender != milestone.reviewer) ||
- (milestone.status != MilestoneStatus.Completed)) throw;
+ (milestone.status != MilestoneStatus.Completed)) revert();
authorizePayment(_idMilestone);
}
@@ -291,10 +291,10 @@ contract MilestoneTracker {
function rejectMilestone(uint _idMilestone)
public campaignNotCanceled notChanging
{
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
if ((msg.sender != milestone.reviewer) ||
- (milestone.status != MilestoneStatus.Completed)) throw;
+ (milestone.status != MilestoneStatus.Completed)) revert();
milestone.status = MilestoneStatus.AcceptedAndInProgress;
emit ProposalStatusChanged(_idMilestone, milestone.status);
@@ -306,14 +306,14 @@ contract MilestoneTracker {
/// @param _idMilestone ID of the milestone to be paid out
function requestMilestonePayment(uint _idMilestone
) public campaignNotCanceled notChanging {
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
if ( (msg.sender != milestone.milestoneLeadLink)
&&(msg.sender != recipient))
- throw;
+ revert();
if ((milestone.status != MilestoneStatus.Completed) ||
(now < milestone.doneTime + milestone.reviewTime))
- throw;
+ revert();
authorizePayment(_idMilestone);
}
@@ -323,11 +323,11 @@ contract MilestoneTracker {
function cancelMilestone(uint _idMilestone)
public onlyRecipient campaignNotCanceled notChanging
{
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
if ((milestone.status != MilestoneStatus.AcceptedAndInProgress) &&
(milestone.status != MilestoneStatus.Completed))
- throw;
+ revert();
milestone.status = MilestoneStatus.Canceled;
emit ProposalStatusChanged(_idMilestone, milestone.status);
@@ -338,11 +338,11 @@ contract MilestoneTracker {
/// @param _idMilestone ID of the milestone to be paid out
function arbitrateApproveMilestone(uint _idMilestone
) public onlyArbitrator campaignNotCanceled notChanging {
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
if ((milestone.status != MilestoneStatus.AcceptedAndInProgress) &&
(milestone.status != MilestoneStatus.Completed))
- throw;
+ revert();
authorizePayment(_idMilestone);
}
@@ -355,13 +355,13 @@ contract MilestoneTracker {
// @dev This internal function is executed when the milestone is paid out
function authorizePayment(uint _idMilestone) internal {
- if (_idMilestone >= milestones.length) throw;
+ if (_idMilestone >= milestones.length) revert();
Milestone storage milestone = milestones[_idMilestone];
// Recheck again to not pay twice
- if (milestone.status == MilestoneStatus.AuthorizedForPayment) throw;
+ if (milestone.status == MilestoneStatus.AuthorizedForPayment) revert();
milestone.status = MilestoneStatus.AuthorizedForPayment;
if (!milestone.paymentSource.call.value(0)(milestone.payData))
- throw;
+ revert();
emit ProposalStatusChanged(_idMilestone, milestone.status);
}
}
diff --git a/test/compilationTests/milestonetracker/RLP.sol b/test/compilationTests/milestonetracker/RLP.sol
index e96bb332..e261bf23 100644
--- a/test/compilationTests/milestonetracker/RLP.sol
+++ b/test/compilationTests/milestonetracker/RLP.sol
@@ -39,13 +39,13 @@ library RLP {
self._unsafe_nextPtr = ptr + itemLength;
}
else
- throw;
+ revert();
}
function next(Iterator memory self, bool strict) internal view returns (RLPItem memory subItem) {
subItem = next(self);
if(strict && !_validate(subItem))
- throw;
+ revert();
return;
}
@@ -80,11 +80,11 @@ library RLP {
if(strict) {
uint len = self.length;
if(_payloadOffset(item) > len)
- throw;
+ revert();
if(_itemLength(item._unsafe_memPtr) != len)
- throw;
+ revert();
if(!_validate(item))
- throw;
+ revert();
}
return item;
}
@@ -160,7 +160,7 @@ library RLP {
/// @return An 'Iterator' over the item.
function iterator(RLPItem memory self) internal view returns (Iterator memory it) {
if (!isList(self))
- throw;
+ revert();
uint ptr = self._unsafe_memPtr + _payloadOffset(self);
it._unsafe_item = self;
it._unsafe_nextPtr = ptr;
@@ -183,7 +183,7 @@ library RLP {
/// @return The decoded string.
function toData(RLPItem memory self) internal returns (bytes memory bts) {
if(!isData(self))
- throw;
+ revert();
(uint rStartPos, uint len) = _decode(self);
bts = new bytes(len);
_copyToBytes(rStartPos, bts, len);
@@ -195,7 +195,7 @@ library RLP {
/// @return Array of RLPItems.
function toList(RLPItem memory self) internal view returns (RLPItem[] memory list) {
if(!isList(self))
- throw;
+ revert();
uint numItems = items(self);
list = new RLPItem[](numItems);
Iterator memory it = iterator(self);
@@ -212,7 +212,7 @@ library RLP {
/// @return The decoded string.
function toAscii(RLPItem memory self) internal returns (string memory str) {
if(!isData(self))
- throw;
+ revert();
(uint rStartPos, uint len) = _decode(self);
bytes memory bts = new bytes(len);
_copyToBytes(rStartPos, bts, len);
@@ -225,10 +225,10 @@ library RLP {
/// @return The decoded string.
function toUint(RLPItem memory self) internal view returns (uint data) {
if(!isData(self))
- throw;
+ revert();
(uint rStartPos, uint len) = _decode(self);
if (len > 32 || len == 0)
- throw;
+ revert();
assembly {
data := div(mload(rStartPos), exp(256, sub(32, len)))
}
@@ -240,16 +240,16 @@ library RLP {
/// @return The decoded string.
function toBool(RLPItem memory self) internal view returns (bool data) {
if(!isData(self))
- throw;
+ revert();
(uint rStartPos, uint len) = _decode(self);
if (len != 1)
- throw;
+ revert();
uint temp;
assembly {
temp := byte(0, mload(rStartPos))
}
if (temp > 1)
- throw;
+ revert();
return temp == 1 ? true : false;
}
@@ -259,10 +259,10 @@ library RLP {
/// @return The decoded string.
function toByte(RLPItem memory self) internal view returns (byte data) {
if(!isData(self))
- throw;
+ revert();
(uint rStartPos, uint len) = _decode(self);
if (len != 1)
- throw;
+ revert();
uint8 temp;
assembly {
temp := byte(0, mload(rStartPos))
@@ -292,10 +292,10 @@ library RLP {
/// @return The decoded string.
function toAddress(RLPItem memory self) internal view returns (address data) {
if(!isData(self))
- throw;
+ revert();
(uint rStartPos, uint len) = _decode(self);
if (len != 20)
- throw;
+ revert();
assembly {
data := div(mload(rStartPos), exp(256, 12))
}
@@ -350,7 +350,7 @@ library RLP {
// Get start position and length of the data.
function _decode(RLPItem memory self) private view returns (uint memPtr, uint len) {
if(!isData(self))
- throw;
+ revert();
uint b0;
uint start = self._unsafe_memPtr;
assembly {