aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-12 07:43:19 +0800
committerchriseth <chris@ethereum.org>2018-07-16 21:33:20 +0800
commitaa08460d94f0e3ac8e067f89786175fb5ebba73b (patch)
tree9a0f9b91f71886ab8648f2d82e04a7449c325fda
parent21e97da2949a421987b0c6ad75bd401ce1dad0ab (diff)
downloaddexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.tar
dexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.tar.gz
dexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.tar.bz2
dexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.tar.lz
dexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.tar.xz
dexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.tar.zst
dexon-solidity-aa08460d94f0e3ac8e067f89786175fb5ebba73b.zip
Replace throw with revert() in end-to-end tests
-rw-r--r--test/contracts/AuctionRegistrar.cpp10
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp2
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp16
3 files changed, 14 insertions, 14 deletions
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 4f135730..8bfd97df 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -125,26 +125,26 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
emit Changed(_name);
if (previousOwner != 0x0000000000000000000000000000000000000000) {
if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100))
- throw;
+ revert();
} else {
if (!auction.highestBidder.send(auction.highestBid - auction.secondHighestBid))
- throw;
+ revert();
}
}
function reserve(string _name) external payable {
if (bytes(_name).length == 0)
- throw;
+ revert();
bool needAuction = requiresAuction(_name);
if (needAuction)
{
if (now < m_toRecord[_name].renewalDate)
- throw;
+ revert();
bid(_name, msg.sender, msg.value);
} else {
Record storage record = m_toRecord[_name];
if (record.owner != 0x0000000000000000000000000000000000000000)
- throw;
+ revert();
m_toRecord[_name].owner = msg.sender;
emit Changed(_name);
}
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index ff683de0..9ebf109e 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -84,7 +84,7 @@ contract FixedFeeRegistrar is Registrar {
function disown(string memory _name, address _refund) onlyrecordowner(_name) {
delete m_recordData[uint(keccak256(bytes(_name))) / 8];
if (!_refund.send(c_fee))
- throw;
+ revert();
emit Changed(_name);
}
function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) {
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index be74c5ff..9317eedd 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -2095,7 +2095,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
contract C {
function () external payable {
- throw;
+ revert();
}
}
)";
@@ -7741,7 +7741,7 @@ BOOST_AUTO_TEST_CASE(simple_throw)
if (x > 10)
return x + 10;
else
- throw;
+ revert();
return 2;
}
}
@@ -9603,7 +9603,7 @@ BOOST_AUTO_TEST_CASE(mutex)
contract mutexed {
bool locked;
modifier protected {
- if (locked) throw;
+ if (locked) revert();
locked = true;
_;
locked = false;
@@ -9615,16 +9615,16 @@ BOOST_AUTO_TEST_CASE(mutex)
function withdraw(uint amount) protected returns (uint) {
// NOTE: It is very bad practice to write this function this way.
// Please refer to the documentation of how to do this properly.
- if (amount > shares) throw;
- if (!msg.sender.call.value(amount)("")) throw;
+ if (amount > shares) revert();
+ if (!msg.sender.call.value(amount)("")) revert();
shares -= amount;
return shares;
}
function withdrawUnprotected(uint amount) public returns (uint) {
// NOTE: It is very bad practice to write this function this way.
// Please refer to the documentation of how to do this properly.
- if (amount > shares) throw;
- if (!msg.sender.call.value(amount)("")) throw;
+ if (amount > shares) revert();
+ if (!msg.sender.call.value(amount)("")) revert();
shares -= amount;
return shares;
}
@@ -11159,7 +11159,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_in_modifiers)
a := 2
}
if (a != 2)
- throw;
+ revert();
_;
}
function f() m public returns (bool) {