mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace throw with revert() in end-to-end tests
This commit is contained in:
parent
21e97da294
commit
aa08460d94
@ -125,26 +125,26 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
|
|||||||
emit Changed(_name);
|
emit Changed(_name);
|
||||||
if (previousOwner != 0x0000000000000000000000000000000000000000) {
|
if (previousOwner != 0x0000000000000000000000000000000000000000) {
|
||||||
if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100))
|
if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100))
|
||||||
throw;
|
revert();
|
||||||
} else {
|
} else {
|
||||||
if (!auction.highestBidder.send(auction.highestBid - auction.secondHighestBid))
|
if (!auction.highestBidder.send(auction.highestBid - auction.secondHighestBid))
|
||||||
throw;
|
revert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reserve(string _name) external payable {
|
function reserve(string _name) external payable {
|
||||||
if (bytes(_name).length == 0)
|
if (bytes(_name).length == 0)
|
||||||
throw;
|
revert();
|
||||||
bool needAuction = requiresAuction(_name);
|
bool needAuction = requiresAuction(_name);
|
||||||
if (needAuction)
|
if (needAuction)
|
||||||
{
|
{
|
||||||
if (now < m_toRecord[_name].renewalDate)
|
if (now < m_toRecord[_name].renewalDate)
|
||||||
throw;
|
revert();
|
||||||
bid(_name, msg.sender, msg.value);
|
bid(_name, msg.sender, msg.value);
|
||||||
} else {
|
} else {
|
||||||
Record storage record = m_toRecord[_name];
|
Record storage record = m_toRecord[_name];
|
||||||
if (record.owner != 0x0000000000000000000000000000000000000000)
|
if (record.owner != 0x0000000000000000000000000000000000000000)
|
||||||
throw;
|
revert();
|
||||||
m_toRecord[_name].owner = msg.sender;
|
m_toRecord[_name].owner = msg.sender;
|
||||||
emit Changed(_name);
|
emit Changed(_name);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ contract FixedFeeRegistrar is Registrar {
|
|||||||
function disown(string memory _name, address _refund) onlyrecordowner(_name) {
|
function disown(string memory _name, address _refund) onlyrecordowner(_name) {
|
||||||
delete m_recordData[uint(keccak256(bytes(_name))) / 8];
|
delete m_recordData[uint(keccak256(bytes(_name))) / 8];
|
||||||
if (!_refund.send(c_fee))
|
if (!_refund.send(c_fee))
|
||||||
throw;
|
revert();
|
||||||
emit Changed(_name);
|
emit Changed(_name);
|
||||||
}
|
}
|
||||||
function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) {
|
function transfer(string memory _name, address _newOwner) onlyrecordowner(_name) {
|
||||||
|
@ -2095,7 +2095,7 @@ BOOST_AUTO_TEST_CASE(transfer_ether)
|
|||||||
|
|
||||||
contract C {
|
contract C {
|
||||||
function () external payable {
|
function () external payable {
|
||||||
throw;
|
revert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
@ -7741,7 +7741,7 @@ BOOST_AUTO_TEST_CASE(simple_throw)
|
|||||||
if (x > 10)
|
if (x > 10)
|
||||||
return x + 10;
|
return x + 10;
|
||||||
else
|
else
|
||||||
throw;
|
revert();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9603,7 +9603,7 @@ BOOST_AUTO_TEST_CASE(mutex)
|
|||||||
contract mutexed {
|
contract mutexed {
|
||||||
bool locked;
|
bool locked;
|
||||||
modifier protected {
|
modifier protected {
|
||||||
if (locked) throw;
|
if (locked) revert();
|
||||||
locked = true;
|
locked = true;
|
||||||
_;
|
_;
|
||||||
locked = false;
|
locked = false;
|
||||||
@ -9615,16 +9615,16 @@ BOOST_AUTO_TEST_CASE(mutex)
|
|||||||
function withdraw(uint amount) protected returns (uint) {
|
function withdraw(uint amount) protected returns (uint) {
|
||||||
// NOTE: It is very bad practice to write this function this way.
|
// NOTE: It is very bad practice to write this function this way.
|
||||||
// Please refer to the documentation of how to do this properly.
|
// Please refer to the documentation of how to do this properly.
|
||||||
if (amount > shares) throw;
|
if (amount > shares) revert();
|
||||||
if (!msg.sender.call.value(amount)("")) throw;
|
if (!msg.sender.call.value(amount)("")) revert();
|
||||||
shares -= amount;
|
shares -= amount;
|
||||||
return shares;
|
return shares;
|
||||||
}
|
}
|
||||||
function withdrawUnprotected(uint amount) public returns (uint) {
|
function withdrawUnprotected(uint amount) public returns (uint) {
|
||||||
// NOTE: It is very bad practice to write this function this way.
|
// NOTE: It is very bad practice to write this function this way.
|
||||||
// Please refer to the documentation of how to do this properly.
|
// Please refer to the documentation of how to do this properly.
|
||||||
if (amount > shares) throw;
|
if (amount > shares) revert();
|
||||||
if (!msg.sender.call.value(amount)("")) throw;
|
if (!msg.sender.call.value(amount)("")) revert();
|
||||||
shares -= amount;
|
shares -= amount;
|
||||||
return shares;
|
return shares;
|
||||||
}
|
}
|
||||||
@ -11159,7 +11159,7 @@ BOOST_AUTO_TEST_CASE(inline_assembly_in_modifiers)
|
|||||||
a := 2
|
a := 2
|
||||||
}
|
}
|
||||||
if (a != 2)
|
if (a != 2)
|
||||||
throw;
|
revert();
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
function f() m public returns (bool) {
|
function f() m public returns (bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user