aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-06-25 22:54:50 +0800
committerGitHub <noreply@github.com>2018-06-25 22:54:50 +0800
commit0ac46090971aab21120875e0e55317e4bd2b397e (patch)
treea027ddad46f3c20ef7d3b013b230083895c81db5
parentb7003505c46942ca2ee4e5317d14f421d5b9bc6d (diff)
parent6d9a091a8e0c7e5a958ff910c9f8dc828a39e0e4 (diff)
downloaddexon-solidity-0ac46090971aab21120875e0e55317e4bd2b397e.tar.gz
dexon-solidity-0ac46090971aab21120875e0e55317e4bd2b397e.tar.zst
dexon-solidity-0ac46090971aab21120875e0e55317e4bd2b397e.zip
Merge pull request #3534 from meowingtwurtle/strictAddresses
[BREAKING] Strict checking of address literals
-rw-r--r--docs/solidity-by-example.rst2
-rw-r--r--libsolidity/analysis/TypeChecker.cpp28
-rw-r--r--libsolidity/ast/Types.cpp6
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWallet.sol6
-rw-r--r--test/compilationTests/corion/ico.sol12
-rw-r--r--test/compilationTests/corion/module.sol2
-rw-r--r--test/compilationTests/corion/moduleHandler.sol4
-rw-r--r--test/compilationTests/corion/owned.sol2
-rw-r--r--test/compilationTests/corion/premium.sol4
-rw-r--r--test/compilationTests/corion/provider.sol22
-rw-r--r--test/compilationTests/corion/schelling.sol4
-rw-r--r--test/compilationTests/corion/token.sol14
-rw-r--r--test/compilationTests/gnosis/Events/Event.sol2
-rw-r--r--test/compilationTests/gnosis/Events/EventFactory.sol4
-rw-r--r--test/compilationTests/gnosis/Markets/Campaign.sol6
-rw-r--r--test/compilationTests/gnosis/Markets/StandardMarket.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/MajorityOracle.sol2
-rw-r--r--test/compilationTests/gnosis/Oracles/UltimateOracle.sol4
-rw-r--r--test/compilationTests/zeppelin/Bounty.sol2
-rw-r--r--test/compilationTests/zeppelin/MultisigWallet.sol4
-rw-r--r--test/compilationTests/zeppelin/crowdsale/Crowdsale.sol4
-rw-r--r--test/compilationTests/zeppelin/crowdsale/RefundVault.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/Claimable.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/DelayedClaimable.sol2
-rw-r--r--test/contracts/AuctionRegistrar.cpp4
-rw-r--r--test/contracts/FixedFeeRegistrar.cpp2
-rw-r--r--test/contracts/Wallet.cpp4
-rwxr-xr-xtest/externalTests.sh7
-rw-r--r--test/libsolidity/ABIEncoderTests.cpp6
-rw-r--r--test/libsolidity/SMTChecker.cpp14
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp4
-rw-r--r--test/libsolidity/SolidityExpressionCompiler.cpp2
-rw-r--r--test/libsolidity/syntaxTests/deprecated_functions.sol4
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol2
-rw-r--r--test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol3
-rw-r--r--test/libsolidity/syntaxTests/parsing/else_if_statement.sol6
-rw-r--r--test/libsolidity/syntaxTests/parsing/modifier.sol2
40 files changed, 115 insertions, 93 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index 2b3d4b48..e8fddd61 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -496,7 +496,7 @@ high or low invalid bids.
if (value <= highestBid) {
return false;
}
- if (highestBidder != 0) {
+ if (highestBidder != address(0)) {
// Refund the previously highest bidder.
pendingReturns[highestBidder] += highestBid;
}
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 19e931f2..b46d4849 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -2287,14 +2287,28 @@ void TypeChecker::endVisit(Literal const& _literal)
if (_literal.looksLikeAddress())
{
- if (_literal.passesAddressChecksum())
- _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
- else
- m_errorReporter.warning(
+ // Assign type here if it even looks like an address. This prevents double error in 050 mode for invalid address
+ _literal.annotation().type = make_shared<IntegerType>(160, IntegerType::Modifier::Address);
+
+ string msg;
+ if (_literal.value().length() != 42) // "0x" + 40 hex digits
+ // looksLikeAddress enforces that it is a hex literal starting with "0x"
+ msg =
+ "This looks like an address but is not exactly 40 hex digits. It is " +
+ to_string(_literal.value().length() - 2) +
+ " hex digits.";
+ else if (!_literal.passesAddressChecksum())
+ {
+ msg = "This looks like an address but has an invalid checksum.";
+ if (!_literal.getChecksummedAddress().empty())
+ msg += " Correct checksummed address: \"" + _literal.getChecksummedAddress() + "\".";
+ }
+
+ if (!msg.empty())
+ m_errorReporter.syntaxError(
_literal.location(),
- "This looks like an address but has an invalid checksum. "
- "If this is not used as an address, please prepend '00'. " +
- (!_literal.getChecksummedAddress().empty() ? "Correct checksummed address: '" + _literal.getChecksummedAddress() + "'. " : "") +
+ msg +
+ " If this is not used as an address, please prepend '00'. " +
"For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals"
);
}
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index c4d97c64..68c53af1 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -858,11 +858,13 @@ bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{
if (_convertTo.category() == Category::Integer)
{
- if (m_value == rational(0))
- return true;
if (isFractional())
return false;
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo);
+ if (targetType.isAddress())
+ return false;
+ if (m_value == rational(0))
+ return true;
unsigned forSignBit = (targetType.isSigned() ? 1 : 0);
if (m_value > rational(0))
{
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
index a6f67c7a..48b75230 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWallet.sol
@@ -50,7 +50,7 @@ contract MultiSigWallet {
}
modifier transactionExists(uint transactionId) {
- if (transactions[transactionId].destination == 0)
+ if (transactions[transactionId].destination == address(0))
throw;
_;
}
@@ -74,7 +74,7 @@ contract MultiSigWallet {
}
modifier notNull(address _address) {
- if (_address == 0)
+ if (_address == address(0))
throw;
_;
}
@@ -107,7 +107,7 @@ contract MultiSigWallet {
validRequirement(_owners.length, _required)
{
for (uint i=0; i<_owners.length; i++) {
- if (isOwner[_owners[i]] || _owners[i] == 0)
+ if (isOwner[_owners[i]] || _owners[i] == address(0))
throw;
isOwner[_owners[i]] = true;
}
diff --git a/test/compilationTests/corion/ico.sol b/test/compilationTests/corion/ico.sol
index c61e3448..13f8ab01 100644
--- a/test/compilationTests/corion/ico.sol
+++ b/test/compilationTests/corion/ico.sol
@@ -162,7 +162,7 @@ contract ico is safeMath {
interest_s memory _idb;
address _addr = beneficiary;
uint256 _to = (block.number - startBlock) / interestBlockDelay;
- if ( _addr == 0x00 ) { _addr = msg.sender; }
+ if ( _addr == address(0x00) ) { _addr = msg.sender; }
require( block.number > icoDelay );
require( ! aborted );
@@ -257,7 +257,7 @@ contract ico is safeMath {
@premiumContractAddr Address of the corion premium token contract
*/
require( msg.sender == owner );
- require( tokenAddr == 0x00 && premiumAddr == 0x00 );
+ require( tokenAddr == address(0x00) && premiumAddr == address(0x00) );
tokenAddr = tokenContractAddr;
premiumAddr = premiumContractAddr;
}
@@ -281,7 +281,7 @@ contract ico is safeMath {
If they call the contract without any function then this process will be taken place.
*/
require( isICO() );
- require( buy(msg.sender, 0x00) );
+ require( buy(msg.sender, address(0x00)) );
}
function buy(address beneficiaryAddress, address affilateAddress) payable returns (bool success) {
@@ -300,9 +300,9 @@ contract ico is safeMath {
@affilateAddress The address of the person who offered who will get the referral reward. It can not be equal with the beneficiaryAddress.
*/
require( isICO() );
- if ( beneficiaryAddress == 0x00) { beneficiaryAddress = msg.sender; }
+ if ( beneficiaryAddress == address(0x00)) { beneficiaryAddress = msg.sender; }
if ( beneficiaryAddress == affilateAddress ) {
- affilateAddress = 0x00;
+ affilateAddress = address(0x00);
}
uint256 _value = msg.value;
if ( beneficiaryAddress.balance < 0.2 ether ) {
@@ -317,7 +317,7 @@ contract ico is safeMath {
totalMint = safeAdd(totalMint, _reward);
require( foundationAddress.send(_value * 10 / 100) );
uint256 extra;
- if ( affilateAddress != 0x00 && ( brought[affilateAddress].eth > 0 || interestDB[affilateAddress][0].amount > 0 ) ) {
+ if ( affilateAddress != address(0x00) && ( brought[affilateAddress].eth > 0 || interestDB[affilateAddress][0].amount > 0 ) ) {
affiliate[affilateAddress].weight = safeAdd(affiliate[affilateAddress].weight, _reward);
extra = affiliate[affilateAddress].weight;
uint256 rate;
diff --git a/test/compilationTests/corion/module.sol b/test/compilationTests/corion/module.sol
index 51fb8231..5f13215f 100644
--- a/test/compilationTests/corion/module.sol
+++ b/test/compilationTests/corion/module.sol
@@ -123,7 +123,7 @@ contract module {
@ret This is the module handler address or not
*/
- if ( moduleHandlerAddress == 0x00 ) { return true; }
+ if ( moduleHandlerAddress == address(0x00) ) { return true; }
if ( moduleStatus != status.Connected ) { return false; }
return addr == moduleHandlerAddress;
}
diff --git a/test/compilationTests/corion/moduleHandler.sol b/test/compilationTests/corion/moduleHandler.sol
index d1f928c5..1d546b40 100644
--- a/test/compilationTests/corion/moduleHandler.sol
+++ b/test/compilationTests/corion/moduleHandler.sol
@@ -73,7 +73,7 @@ contract moduleHandler is multiOwner, announcementTypes {
require( success && ! found );
(success, found, id) = getModuleIDByHash(input.name);
require( success && ! found );
- (success, found, id) = getModuleIDByAddress(0x00);
+ (success, found, id) = getModuleIDByAddress(address(0x00));
require( success );
if ( ! found ) {
id = modules.length;
@@ -92,7 +92,7 @@ contract moduleHandler is multiOwner, announcementTypes {
*/
(bool _success, bool _found, uint256 _id) = getModuleIDByName(name);
if ( _success && _found ) { return (true, true, modules[_id].addr); }
- return (true, false, 0x00);
+ return (true, false, address(0x00));
}
function getModuleIDByHash(bytes32 hashOfName) public constant returns( bool success, bool found, uint256 id ) {
/*
diff --git a/test/compilationTests/corion/owned.sol b/test/compilationTests/corion/owned.sol
index bd187775..4a5ba673 100644
--- a/test/compilationTests/corion/owned.sol
+++ b/test/compilationTests/corion/owned.sol
@@ -20,7 +20,7 @@ contract ownedDB {
@bool Owner has called the contract or not
*/
- if ( owner == 0x00 ) {
+ if ( owner == address(0x00) ) {
return true;
}
return owner == msg.sender;
diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol
index 2cf76088..843a2d16 100644
--- a/test/compilationTests/corion/premium.sol
+++ b/test/compilationTests/corion/premium.sol
@@ -53,7 +53,7 @@ contract premium is module, safeMath {
@genesisValue Array of the balance of the genesis addresses
*/
super.registerModuleHandler(moduleHandler);
- require( dbAddress != 0x00 );
+ require( dbAddress != address(0x00) );
db = ptokenDB(dbAddress);
if ( ! forReplace ) {
require( db.replaceOwner(this) );
@@ -273,7 +273,7 @@ contract premium is module, safeMath {
@to For who?
@amount Amount
*/
- require( from != 0x00 && to != 0x00 && to != 0xa636a97578d26a3b76b060bbc18226d954cf3757 );
+ require( from != address(0x00) && to != address(0x00) && to != 0xa636A97578d26A3b76B060Bbc18226d954cf3757 );
require( ( ! isICO) || genesis[from] );
require( db.decrease(from, amount) );
require( db.increase(to, amount) );
diff --git a/test/compilationTests/corion/provider.sol b/test/compilationTests/corion/provider.sol
index 2cdd760d..b3b8169d 100644
--- a/test/compilationTests/corion/provider.sol
+++ b/test/compilationTests/corion/provider.sol
@@ -161,7 +161,7 @@ contract provider is module, safeMath, announcementTypes {
if ( schellingRound == 0 ) {
schellingRound = currentSchellingRound;
}
- if ( clients[addr].providerAddress != 0 ) {
+ if ( clients[addr].providerAddress != address(0x00) ) {
ProviderAddress = clients[addr].providerAddress;
ProviderHeight = clients[addr].providerHeight;
ConnectedOn = clients[addr].providerConnected;
@@ -233,7 +233,7 @@ contract provider is module, safeMath, announcementTypes {
@admin The admin’s address
*/
require( ! providers[msg.sender].data[providers[msg.sender].currentHeight].valid );
- require( clients[msg.sender].providerAddress == 0x00 );
+ require( clients[msg.sender].providerAddress == address(0x00) );
require( ! checkICO() );
if ( priv ) {
require( getTokenBalance(msg.sender) >= minFundsForPrivate );
@@ -245,7 +245,7 @@ contract provider is module, safeMath, announcementTypes {
providers[msg.sender].currentHeight++;
uint256 currHeight = providers[msg.sender].currentHeight;
providers[msg.sender].data[currHeight].valid = true;
- if ( admin == 0x00 ) {
+ if ( admin == address(0x00) ) {
providers[msg.sender].data[currHeight].admin = msg.sender;
} else {
providers[msg.sender].data[currHeight].admin = admin;
@@ -288,7 +288,7 @@ contract provider is module, safeMath, announcementTypes {
require( providers[addr].data[currHeight].valid );
require( checkCorrectRate(providers[addr].data[currHeight].priv, rate) );
require( providers[addr].data[currHeight].admin == msg.sender || msg.sender == addr );
- if ( admin != 0x00 ) {
+ if ( admin != address(0x00) ) {
require( msg.sender == addr );
providers[addr].data[currHeight].admin = admin;
}
@@ -419,7 +419,7 @@ contract provider is module, safeMath, announcementTypes {
*/
uint256 currHeight = providers[provider].currentHeight;
require( ! providers[msg.sender].data[currHeight].valid );
- require( clients[msg.sender].providerAddress == 0x00 );
+ require( clients[msg.sender].providerAddress == address(0x00) );
require( providers[provider].data[currHeight].valid );
if ( providers[provider].data[currHeight].priv ) {
require( providers[provider].data[currHeight].allowedUsers[msg.sender] &&
@@ -446,7 +446,7 @@ contract provider is module, safeMath, announcementTypes {
It is only possible to disconnect those providers who were connected by us before.
*/
address provider = clients[msg.sender].providerAddress;
- require( provider != 0x0 );
+ require( provider != address(0x00) );
uint256 currHeight = clients[msg.sender].providerHeight;
bool providerHasClosed = false;
if ( providers[provider].data[currHeight].close > 0 ) {
@@ -479,7 +479,7 @@ contract provider is module, safeMath, announcementTypes {
if ( providers[addr].data[providers[addr].currentHeight].valid ) {
uint256 a;
(reward, a) = getProviderReward(addr, 0);
- } else if ( clients[addr].providerAddress != 0x0 ) {
+ } else if ( clients[addr].providerAddress != address(0x00) ) {
reward = getClientReward(0);
}
}
@@ -504,14 +504,14 @@ contract provider is module, safeMath, announcementTypes {
address _beneficiary = beneficiary;
address _provider = provider;
if ( _limit == 0 ) { _limit = gasProtectMaxRounds; }
- if ( _beneficiary == 0x00 ) { _beneficiary = msg.sender; }
- if ( _provider == 0x00 ) { _provider = msg.sender; }
+ if ( _beneficiary == address(0x00) ) { _beneficiary = msg.sender; }
+ if ( _provider == address(0x00) ) { _provider = msg.sender; }
uint256 clientReward;
uint256 providerReward;
if ( providers[_provider].data[providers[_provider].currentHeight].valid ) {
require( providers[_provider].data[providers[_provider].currentHeight].admin == msg.sender || msg.sender == _provider );
(providerReward, clientReward) = getProviderReward(_provider, _limit);
- } else if ( clients[msg.sender].providerAddress != 0x00 ) {
+ } else if ( clients[msg.sender].providerAddress != address(0x00) ) {
clientReward = getClientReward(_limit);
} else {
throw;
@@ -745,7 +745,7 @@ contract provider is module, safeMath, announcementTypes {
@value Rate of the change.
@neg ype of the change. If it is TRUE then the balance has been decreased if it is FALSE then it has been increased.
*/
- if ( clients[addr].providerAddress != 0 ) {
+ if ( clients[addr].providerAddress != address(0x00) ) {
checkFloatingSupply(clients[addr].providerAddress, providers[clients[addr].providerAddress].currentHeight, ! neg, value);
if (clients[addr].lastSupplyID != currentSchellingRound) {
clients[addr].supply[currentSchellingRound] = TEMath(clients[addr].supply[clients[addr].lastSupplyID], value, neg);
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol
index 8f38ec64..51133d73 100644
--- a/test/compilationTests/corion/schelling.sol
+++ b/test/compilationTests/corion/schelling.sol
@@ -37,7 +37,7 @@ contract schellingDB is safeMath, schellingVars {
*/
address private owner;
function replaceOwner(address newOwner) external returns(bool) {
- require( owner == 0x00 || msg.sender == owner );
+ require( owner == address(0x00) || msg.sender == owner );
owner = newOwner;
return true;
}
@@ -407,7 +407,7 @@ contract schelling is module, announcementTypes, schellingVars {
uint256 funds = getFunds(msg.sender);
address _beneficiary = msg.sender;
- if (beneficiary != 0x0) { _beneficiary = beneficiary; }
+ if (beneficiary != address(0x00)) { _beneficiary = beneficiary; }
uint256 reward;
require( voter.rewards > 0 );
require( voter.status == voterStatus.base );
diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol
index 3a6a4598..468e3e79 100644
--- a/test/compilationTests/corion/token.sol
+++ b/test/compilationTests/corion/token.sol
@@ -63,9 +63,9 @@ contract token is safeMath, module, announcementTypes {
@genesisValue Array of balance of genesis addresses
*/
super.registerModuleHandler(moduleHandler);
- require( dbAddr != 0x00 );
- require( icoContractAddr != 0x00 );
- require( exchangeContractAddress != 0x00 );
+ require( dbAddr != address(0x00) );
+ require( icoContractAddr != address(0x00) );
+ require( exchangeContractAddress != address(0x00) );
db = tokenDB(dbAddr);
icoAddr = icoContractAddr;
exchangeAddress = exchangeContractAddress;
@@ -325,7 +325,7 @@ contract token is safeMath, module, announcementTypes {
require( success );
require( db.balanceOf(from) >= amount + _fee );
}
- require( from != 0x00 && to != 0x00 && to != 0xa636a97578d26a3b76b060bbc18226d954cf3757 );
+ require( from != address(0x00) && to != address(0x00) && to != 0xa636A97578d26A3b76B060Bbc18226d954cf3757 );
require( ( ! isICO) || genesis[from] );
require( db.decrease(from, amount) );
require( db.increase(to, amount) );
@@ -374,7 +374,7 @@ contract token is safeMath, module, announcementTypes {
address _schellingAddr;
(_success, _found, _schellingAddr) = moduleHandler(moduleHandlerAddress).getModuleAddressByName('Schelling');
require( _success );
- if ( _schellingAddr != 0x00 && _found) {
+ if ( _schellingAddr != address(0x00) && _found) {
require( db.decrease(owner, _forSchelling) );
require( db.increase(_schellingAddr, _forSchelling) );
_burn(owner, _forBurn);
@@ -424,7 +424,7 @@ contract token is safeMath, module, announcementTypes {
@value Quantity
*/
require( db.increase(owner, value) );
- require( moduleHandler(moduleHandlerAddress).broadcastTransfer(0x00, owner, value) );
+ require( moduleHandler(moduleHandlerAddress).broadcastTransfer(address(0x00), owner, value) );
if ( isICO ) {
require( ico(icoAddr).setInterestDB(owner, db.balanceOf(owner)) );
}
@@ -453,7 +453,7 @@ contract token is safeMath, module, announcementTypes {
@value Quantity
*/
require( db.decrease(owner, value) );
- require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, 0x00, value) );
+ require( moduleHandler(moduleHandlerAddress).broadcastTransfer(owner, address(0x00), value) );
Burn(owner, value);
}
diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol
index 9aa257c4..cb991447 100644
--- a/test/compilationTests/gnosis/Events/Event.sol
+++ b/test/compilationTests/gnosis/Events/Event.sol
@@ -37,7 +37,7 @@ contract Event {
public
{
// Validate input
- require(address(_collateralToken) != 0 && address(_oracle) != 0 && outcomeCount >= 2);
+ require(address(_collateralToken) != address(0) && address(_oracle) != address(0) && outcomeCount >= 2);
collateralToken = _collateralToken;
oracle = _oracle;
// Create an outcome token for each outcome
diff --git a/test/compilationTests/gnosis/Events/EventFactory.sol b/test/compilationTests/gnosis/Events/EventFactory.sol
index dfb1a579..4779c6e4 100644
--- a/test/compilationTests/gnosis/Events/EventFactory.sol
+++ b/test/compilationTests/gnosis/Events/EventFactory.sol
@@ -37,7 +37,7 @@ contract EventFactory {
{
bytes32 eventHash = keccak256(collateralToken, oracle, outcomeCount);
// Event should not exist yet
- require(address(categoricalEvents[eventHash]) == 0);
+ require(address(categoricalEvents[eventHash]) == address(0));
// Create event
eventContract = new CategoricalEvent(
collateralToken,
@@ -65,7 +65,7 @@ contract EventFactory {
{
bytes32 eventHash = keccak256(collateralToken, oracle, lowerBound, upperBound);
// Event should not exist yet
- require(address(scalarEvents[eventHash]) == 0);
+ require(address(scalarEvents[eventHash]) == address(0));
// Create event
eventContract = new ScalarEvent(
collateralToken,
diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol
index 9aee1033..15d7010a 100644
--- a/test/compilationTests/gnosis/Markets/Campaign.sol
+++ b/test/compilationTests/gnosis/Markets/Campaign.sol
@@ -81,9 +81,9 @@ contract Campaign {
public
{
// Validate input
- require( address(_eventContract) != 0
- && address(_marketFactory) != 0
- && address(_marketMaker) != 0
+ require( address(_eventContract) != address(0)
+ && address(_marketFactory) != address(0)
+ && address(_marketMaker) != address(0)
&& _fee < FEE_RANGE
&& _funding > 0
&& now < _deadline);
diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol
index b973119a..4273655a 100644
--- a/test/compilationTests/gnosis/Markets/StandardMarket.sol
+++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol
@@ -42,7 +42,7 @@ contract StandardMarket is Market {
public
{
// Validate inputs
- require(address(_eventContract) != 0 && address(_marketMaker) != 0 && _fee < FEE_RANGE);
+ require(address(_eventContract) != address(0) && address(_marketMaker) != address(0) && _fee < FEE_RANGE);
creator = _creator;
createdAtBlock = block.number;
eventContract = _eventContract;
diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol
index 62eab4f0..dbb0a487 100644
--- a/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol
+++ b/test/compilationTests/gnosis/Oracles/FutarchyOracleFactory.sol
@@ -36,7 +36,7 @@ contract FutarchyOracleFactory {
function FutarchyOracleFactory(EventFactory _eventFactory)
public
{
- require(address(_eventFactory) != 0);
+ require(address(_eventFactory) != address(0));
eventFactory = _eventFactory;
}
diff --git a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
index 4b02c2de..5c0ab103 100644
--- a/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/MajorityOracle.sol
@@ -23,7 +23,7 @@ contract MajorityOracle is Oracle {
require(_oracles.length > 2);
for (uint i = 0; i < _oracles.length; i++)
// Oracle address cannot be null
- require(address(_oracles[i]) != 0);
+ require(address(_oracles[i]) != address(0));
oracles = _oracles;
}
diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
index fe8b4ec7..9ed61aef 100644
--- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
@@ -57,8 +57,8 @@ contract UltimateOracle is Oracle {
public
{
// Validate inputs
- require( address(_forwardedOracle) != 0
- && address(_collateralToken) != 0
+ require( address(_forwardedOracle) != address(0)
+ && address(_collateralToken) != address(0)
&& _spreadMultiplier >= 2
&& _challengePeriod > 0
&& _challengeAmount > 0
diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol
index 4425b7a5..4c62a0b4 100644
--- a/test/compilationTests/zeppelin/Bounty.sol
+++ b/test/compilationTests/zeppelin/Bounty.sol
@@ -48,7 +48,7 @@ contract Bounty is PullPayment, Destructible {
*/
function claim(Target target) {
address researcher = researchers[target];
- if (researcher == 0) {
+ if (researcher == address(0)) {
throw;
}
// Check Target contract invariants
diff --git a/test/compilationTests/zeppelin/MultisigWallet.sol b/test/compilationTests/zeppelin/MultisigWallet.sol
index 939e70f2..8fcdb63e 100644
--- a/test/compilationTests/zeppelin/MultisigWallet.sol
+++ b/test/compilationTests/zeppelin/MultisigWallet.sol
@@ -67,7 +67,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
}
// determine our operation hash.
_r = keccak256(msg.data, block.number);
- if (!confirm(_r) && txs[_r].to == 0) {
+ if (!confirm(_r) && txs[_r].to == address(0)) {
txs[_r].to = _to;
txs[_r].value = _value;
txs[_r].data = _data;
@@ -81,7 +81,7 @@ contract MultisigWallet is Multisig, Shareable, DayLimit {
* @param _h The transaction hash to approve.
*/
function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
- if (txs[_h].to != 0) {
+ if (txs[_h].to != address(0)) {
if (!txs[_h].to.call.value(txs[_h].value)(txs[_h].data)) {
throw;
}
diff --git a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
index bee1efd2..21d36840 100644
--- a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
+++ b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol
@@ -44,7 +44,7 @@ contract Crowdsale {
require(_startBlock >= block.number);
require(_endBlock >= _startBlock);
require(_rate > 0);
- require(_wallet != 0x0);
+ require(_wallet != address(0x0));
token = createTokenContract();
startBlock = _startBlock;
@@ -67,7 +67,7 @@ contract Crowdsale {
// low level token purchase function
function buyTokens(address beneficiary) payable {
- require(beneficiary != 0x0);
+ require(beneficiary != address(0x0));
require(validPurchase());
uint256 weiAmount = msg.value;
diff --git a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
index cc92ff9f..d88f035f 100644
--- a/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
+++ b/test/compilationTests/zeppelin/crowdsale/RefundVault.sol
@@ -23,7 +23,7 @@ contract RefundVault is Ownable {
event Refunded(address indexed beneficiary, uint256 weiAmount);
function RefundVault(address _wallet) {
- require(_wallet != 0x0);
+ require(_wallet != address(0x0));
wallet = _wallet;
state = State.Active;
}
diff --git a/test/compilationTests/zeppelin/ownership/Claimable.sol b/test/compilationTests/zeppelin/ownership/Claimable.sol
index d063502d..14d0ac6a 100644
--- a/test/compilationTests/zeppelin/ownership/Claimable.sol
+++ b/test/compilationTests/zeppelin/ownership/Claimable.sol
@@ -35,6 +35,6 @@ contract Claimable is Ownable {
*/
function claimOwnership() onlyPendingOwner {
owner = pendingOwner;
- pendingOwner = 0x0;
+ pendingOwner = address(0x0);
}
}
diff --git a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
index f5fee614..93177dc6 100644
--- a/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
+++ b/test/compilationTests/zeppelin/ownership/DelayedClaimable.sol
@@ -36,7 +36,7 @@ contract DelayedClaimable is Claimable {
if ((block.number > end) || (block.number < start))
throw;
owner = pendingOwner;
- pendingOwner = 0x0;
+ pendingOwner = address(0x0);
end = 0;
}
diff --git a/test/contracts/AuctionRegistrar.cpp b/test/contracts/AuctionRegistrar.cpp
index 33b392d4..ef84efed 100644
--- a/test/contracts/AuctionRegistrar.cpp
+++ b/test/contracts/AuctionRegistrar.cpp
@@ -123,7 +123,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
record.renewalDate = now + c_renewalInterval;
record.owner = auction.highestBidder;
Changed(_name);
- if (previousOwner != 0) {
+ if (previousOwner != 0x0000000000000000000000000000000000000000) {
if (!record.owner.send(auction.sumOfBids - auction.highestBid / 100))
throw;
} else {
@@ -143,7 +143,7 @@ contract GlobalRegistrar is Registrar, AuctionSystem {
bid(_name, msg.sender, msg.value);
} else {
Record record = m_toRecord[_name];
- if (record.owner != 0)
+ if (record.owner != 0x0000000000000000000000000000000000000000)
throw;
m_toRecord[_name].owner = msg.sender;
Changed(_name);
diff --git a/test/contracts/FixedFeeRegistrar.cpp b/test/contracts/FixedFeeRegistrar.cpp
index a3a27c37..1fd58403 100644
--- a/test/contracts/FixedFeeRegistrar.cpp
+++ b/test/contracts/FixedFeeRegistrar.cpp
@@ -76,7 +76,7 @@ contract FixedFeeRegistrar is Registrar {
function reserve(string _name) payable {
Record rec = m_record(_name);
- if (rec.owner == 0 && msg.value >= c_fee) {
+ if (rec.owner == 0x0000000000000000000000000000000000000000 && msg.value >= c_fee) {
rec.owner = msg.sender;
Changed(_name);
}
diff --git a/test/contracts/Wallet.cpp b/test/contracts/Wallet.cpp
index 1031e8f1..f8ee007d 100644
--- a/test/contracts/Wallet.cpp
+++ b/test/contracts/Wallet.cpp
@@ -399,7 +399,7 @@ contract Wallet is multisig, multiowned, daylimit {
}
// determine our operation hash.
_r = keccak256(msg.data, block.number);
- if (!confirm(_r) && m_txs[_r].to == 0) {
+ if (!confirm(_r) && m_txs[_r].to == 0x0000000000000000000000000000000000000000) {
m_txs[_r].to = _to;
m_txs[_r].value = _value;
m_txs[_r].data = _data;
@@ -410,7 +410,7 @@ contract Wallet is multisig, multiowned, daylimit {
// confirm a transaction through just the hash. we use the previous transactions map, m_txs, in order
// to determine the body of the transaction from the hash provided.
function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) {
- if (m_txs[_h].to != 0) {
+ if (m_txs[_h].to != 0x0000000000000000000000000000000000000000) {
m_txs[_h].to.call.value(m_txs[_h].value)(m_txs[_h].data);
MultiTransact(msg.sender, _h, m_txs[_h].value, m_txs[_h].to, m_txs[_h].data);
delete m_txs[_h];
diff --git a/test/externalTests.sh b/test/externalTests.sh
index 3125f92f..f2839083 100755
--- a/test/externalTests.sh
+++ b/test/externalTests.sh
@@ -61,6 +61,13 @@ function test_truffle
# Replace fixed-version pragmas in Gnosis (part of Consensys best practice)
find contracts test -name '*.sol' -type f -print0 | xargs -0 sed -i -e 's/pragma solidity 0/pragma solidity ^0/'
fi
+ assertsol="node_modules/truffle/build/Assert.sol"
+ if [ -f "$assertsol" ]
+ then
+ echo "Replace Truffle's Assert.sol with a known good version"
+ rm "$assertsol"
+ wget https://raw.githubusercontent.com/trufflesuite/truffle-core/ef31bcaa15dbd9bd0f6a0070a5c63f271cde2dbc/lib/testing/Assert.sol -o "$assertsol"
+ fi
npm run test
)
rm -rf "$DIR"
diff --git a/test/libsolidity/ABIEncoderTests.cpp b/test/libsolidity/ABIEncoderTests.cpp
index 227eadb5..c5ece5df 100644
--- a/test/libsolidity/ABIEncoderTests.cpp
+++ b/test/libsolidity/ABIEncoderTests.cpp
@@ -279,9 +279,9 @@ BOOST_AUTO_TEST_CASE(storage_array_dyn)
address[] addr;
event E(address[] a);
function f() public {
- addr.push(1);
- addr.push(2);
- addr.push(3);
+ addr.push(0x0000000000000000000000000000000000000001);
+ addr.push(0x0000000000000000000000000000000000000002);
+ addr.push(0x0000000000000000000000000000000000000003);
E(addr);
}
}
diff --git a/test/libsolidity/SMTChecker.cpp b/test/libsolidity/SMTChecker.cpp
index 18c8c025..57f414db 100644
--- a/test/libsolidity/SMTChecker.cpp
+++ b/test/libsolidity/SMTChecker.cpp
@@ -433,15 +433,15 @@ BOOST_AUTO_TEST_CASE(storage_value_vars)
function f(uint x) public {
if (x == 0)
{
- a = 100;
+ a = 0x0000000000000000000000000000000000000100;
b = true;
}
else
{
- a = 200;
+ a = 0x0000000000000000000000000000000000000200;
b = false;
}
- assert(a > 0 && b);
+ assert(a > 0x0000000000000000000000000000000000000000 && b);
}
}
)";
@@ -464,19 +464,19 @@ BOOST_AUTO_TEST_CASE(storage_value_vars)
function f(uint x) public {
if (x == 0)
{
- a = 100;
+ a = 0x0000000000000000000000000000000000000100;
b = true;
}
else
{
- a = 200;
+ a = 0x0000000000000000000000000000000000000200;
b = false;
}
- assert(b == (a < 200));
+ assert(b == (a < 0x0000000000000000000000000000000000000200));
}
function g() public view {
- require(a < 100);
+ require(a < 0x0000000000000000000000000000000000000100);
assert(c >= 0);
}
address a;
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 65473f0d..42b5d417 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -9460,8 +9460,8 @@ BOOST_AUTO_TEST_CASE(failing_ecrecover_invalid_input_proper)
0, // invalid v value
0x6944c77849b18048f6abe0db8084b0d0d0689cdddb53d2671c36967b58691ad4,
0xef4f06ba4f78319baafd0424365777241af4dfd3da840471b4b4b087b7750d0d,
- 0xca35b7d915458ef540ade6068dfe2f44e8fa733c,
- 0xca35b7d915458ef540ade6068dfe2f44e8fa733c
+ 0x00ca35b7d915458ef540ade6068dfe2f44e8fa733c,
+ 0x00ca35b7d915458ef540ade6068dfe2f44e8fa733c
);
}
function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s, uint blockExpired, bytes32 salt)
diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp
index ad26ce6b..ce8f4fe4 100644
--- a/test/libsolidity/SolidityExpressionCompiler.cpp
+++ b/test/libsolidity/SolidityExpressionCompiler.cpp
@@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(intermediately_overflowing_literals)
// have been applied
char const* sourceCode = R"(
contract test {
- function f() { var x = (0xffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
+ function f() { var x = (0x00ffffffffffffffffffffffffffffffffffffffff * 0xffffffffffffffffffffffffff01) & 0xbf; }
}
)";
bytes code = compileFirstExpression(sourceCode);
diff --git a/test/libsolidity/syntaxTests/deprecated_functions.sol b/test/libsolidity/syntaxTests/deprecated_functions.sol
index ff3af7d2..99ca4542 100644
--- a/test/libsolidity/syntaxTests/deprecated_functions.sol
+++ b/test/libsolidity/syntaxTests/deprecated_functions.sol
@@ -4,9 +4,9 @@ contract test {
x;
}
function g() public {
- suicide(1);
+ suicide(0x0000000000000000000000000000000000000001);
}
}
// ----
// TypeError: (58-64): "sha3" has been deprecated in favour of "keccak256"
-// TypeError: (99-109): "suicide" has been deprecated in favour of "selfdestruct"
+// TypeError: (99-150): "suicide" has been deprecated in favour of "selfdestruct"
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol
index 8084e0d1..fe4691c2 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/406_invalid_address_checksum.sol
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
-// Warning: (64-106): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
+// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol
index 51521fe6..6f4ac730 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/407_invalid_address_no_checksum.sol
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
-// Warning: (64-106): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
+// SyntaxError: (64-106): This looks like an address but has an invalid checksum. Correct checksummed address: "0xfA0bFc97E48458494Ccd857e1A85DC91F7F0046E". If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol
index 4dd93c63..da5dc380 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/408_invalid_address_length_short.sol
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
-// Warning: (64-105): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. Correct checksummed address: '0x0A0BfC97E48458494ccD857e1A85Dc91f7f0046e'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
+// SyntaxError: (64-105): This looks like an address but is not exactly 40 hex digits. It is 39 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol
index 37c6aa05..749612c9 100644
--- a/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol
+++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/409_invalid_address_length_long.sol
@@ -5,5 +5,4 @@ contract C {
}
}
// ----
-// Warning: (64-107): This looks like an address but has an invalid checksum. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
-// TypeError: (52-107): Type int_const 2284...(42 digits omitted)...9360 is not implicitly convertible to expected type address.
+// SyntaxError: (64-107): This looks like an address but is not exactly 40 hex digits. It is 41 hex digits. If this is not used as an address, please prepend '00'. For more information please see https://solidity.readthedocs.io/en/develop/types.html#address-literals
diff --git a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
index 727e6115..37763697 100644
--- a/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
+++ b/test/libsolidity/syntaxTests/parsing/else_if_statement.sol
@@ -1,8 +1,8 @@
contract test {
- function fun(uint256 a) returns (address b) {
+ function fun(uint256 a) returns (uint8 b) {
if (a < 0) b = 0x67; else if (a == 0) b = 0x12; else b = 0x78;
}
}
// ----
-// Warning: (20-142): No visibility specified. Defaulting to "public".
-// Warning: (20-142): Function state mutability can be restricted to pure
+// Warning: (20-140): No visibility specified. Defaulting to "public".
+// Warning: (20-140): Function state mutability can be restricted to pure
diff --git a/test/libsolidity/syntaxTests/parsing/modifier.sol b/test/libsolidity/syntaxTests/parsing/modifier.sol
index 3e659dcf..b995ce89 100644
--- a/test/libsolidity/syntaxTests/parsing/modifier.sol
+++ b/test/libsolidity/syntaxTests/parsing/modifier.sol
@@ -1,3 +1,3 @@
contract c {
- modifier mod { if (msg.sender == 0) _; }
+ modifier mod { if (msg.sender == 0x0000000000000000000000000000000000000000) _; }
}