aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-07-13 02:07:16 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-08-01 18:04:35 +0800
commitb800bfb02138f843538bca55a40d6a4e0d1be60f (patch)
tree4d0162665f6f185e368e0831359d336e8251e438
parentc8232d9759458d5f6e1442533457d8529686eea7 (diff)
downloaddexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.tar
dexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.tar.gz
dexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.tar.bz2
dexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.tar.lz
dexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.tar.xz
dexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.tar.zst
dexon-solidity-b800bfb02138f843538bca55a40d6a4e0d1be60f.zip
Fix tests regarding contract type conversion.
-rw-r--r--docs/frequently-asked-questions.rst2
-rw-r--r--docs/types.rst2
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol2
-rw-r--r--test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol2
-rw-r--r--test/compilationTests/corion/premium.sol2
-rw-r--r--test/compilationTests/corion/schelling.sol2
-rw-r--r--test/compilationTests/corion/token.sol2
-rw-r--r--test/compilationTests/gnosis/Events/Event.sol2
-rw-r--r--test/compilationTests/gnosis/Markets/Campaign.sol8
-rw-r--r--test/compilationTests/gnosis/Markets/StandardMarket.sol20
-rw-r--r--test/compilationTests/gnosis/Oracles/FutarchyOracle.sol8
-rw-r--r--test/compilationTests/gnosis/Oracles/UltimateOracle.sol4
-rw-r--r--test/compilationTests/zeppelin/Bounty.sol6
-rw-r--r--test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol2
-rw-r--r--test/compilationTests/zeppelin/ownership/HasNoTokens.sol2
-rw-r--r--test/compilationTests/zeppelin/token/TokenTimelock.sol2
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp2
-rw-r--r--test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol3
18 files changed, 37 insertions, 36 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index cb46dea6..c2df0d3a 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -379,7 +379,7 @@ In this example::
}
contract A {
- address child;
+ B child;
function test() public {
child = (new B).value(10)(); //construct a new B with 10 wei
diff --git a/docs/types.rst b/docs/types.rst
index 3aad413d..566c4c19 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -901,7 +901,7 @@ for each ``_KeyType``, recursively.
function f() public returns (uint) {
MappingExample m = new MappingExample();
m.update(100);
- return m.balances(this);
+ return m.balances(address(this));
}
}
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol
index 16219aa2..8d0c1a3f 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWalletFactory.sol
@@ -15,7 +15,7 @@ contract MultiSigWalletFactory is Factory {
public
returns (address wallet)
{
- wallet = new MultiSigWallet(_owners, _required);
+ wallet = address(new MultiSigWallet(_owners, _required));
register(wallet);
}
}
diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol
index e4cfc031..f897d938 100644
--- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol
+++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol
@@ -16,7 +16,7 @@ contract MultiSigWalletWithDailyLimitFactory is Factory {
public
returns (address wallet)
{
- wallet = new MultiSigWalletWithDailyLimit(_owners, _required, _dailyLimit);
+ wallet = address(new MultiSigWalletWithDailyLimit(_owners, _required, _dailyLimit));
register(wallet);
}
}
diff --git a/test/compilationTests/corion/premium.sol b/test/compilationTests/corion/premium.sol
index 45fe7666..31b492f1 100644
--- a/test/compilationTests/corion/premium.sol
+++ b/test/compilationTests/corion/premium.sol
@@ -56,7 +56,7 @@ contract premium is module, safeMath {
require( dbAddress != address(0x00) );
db = ptokenDB(dbAddress);
if ( ! forReplace ) {
- require( db.replaceOwner(this) );
+ require( db.replaceOwner(address(this)) );
isICO = true;
icoAddr = icoContractAddr;
assert( genesisAddr.length == genesisValue.length );
diff --git a/test/compilationTests/corion/schelling.sol b/test/compilationTests/corion/schelling.sol
index 3905e300..bea53680 100644
--- a/test/compilationTests/corion/schelling.sol
+++ b/test/compilationTests/corion/schelling.sol
@@ -259,7 +259,7 @@ contract schelling is module, announcementTypes, schellingVars {
db = schellingDB(_db);
super.registerModuleHandler(_moduleHandler);
if ( ! _forReplace ) {
- require( db.replaceOwner(this) );
+ require( db.replaceOwner(address(this)) );
}
}
function configure(announcementType a, uint256 b) external returns(bool) {
diff --git a/test/compilationTests/corion/token.sol b/test/compilationTests/corion/token.sol
index 6c8f6f24..be6e914b 100644
--- a/test/compilationTests/corion/token.sol
+++ b/test/compilationTests/corion/token.sol
@@ -71,7 +71,7 @@ contract token is safeMath, module, announcementTypes {
exchangeAddress = exchangeContractAddress;
isICO = ! forReplace;
if ( ! forReplace ) {
- require( db.replaceOwner(this) );
+ require( db.replaceOwner(address(this)) );
assert( genesisAddr.length == genesisValue.length );
require( address(this).balance >= genesisAddr.length * 0.2 ether );
for ( uint256 a=0 ; a<genesisAddr.length ; a++ ) {
diff --git a/test/compilationTests/gnosis/Events/Event.sol b/test/compilationTests/gnosis/Events/Event.sol
index 5b1a550c..0a40cf7e 100644
--- a/test/compilationTests/gnosis/Events/Event.sol
+++ b/test/compilationTests/gnosis/Events/Event.sol
@@ -54,7 +54,7 @@ contract Event {
public
{
// Transfer collateral tokens to events contract
- require(collateralToken.transferFrom(msg.sender, this, collateralTokenCount));
+ require(collateralToken.transferFrom(msg.sender, address(this), collateralTokenCount));
// Issue new outcome tokens to sender
for (uint8 i = 0; i < outcomeTokens.length; i++)
outcomeTokens[i].issue(msg.sender, collateralTokenCount);
diff --git a/test/compilationTests/gnosis/Markets/Campaign.sol b/test/compilationTests/gnosis/Markets/Campaign.sol
index f99ede53..119f8df2 100644
--- a/test/compilationTests/gnosis/Markets/Campaign.sol
+++ b/test/compilationTests/gnosis/Markets/Campaign.sol
@@ -102,12 +102,12 @@ contract Campaign {
timedTransitions
atStage(Stages.AuctionStarted)
{
- uint raisedAmount = eventContract.collateralToken().balanceOf(this);
+ uint raisedAmount = eventContract.collateralToken().balanceOf(address(this));
uint maxAmount = funding.sub(raisedAmount);
if (maxAmount < amount)
amount = maxAmount;
// Collect collateral tokens
- require(eventContract.collateralToken().transferFrom(msg.sender, this, amount));
+ require(eventContract.collateralToken().transferFrom(msg.sender, address(this), amount));
contributions[msg.sender] = contributions[msg.sender].add(amount);
if (amount == maxAmount)
stage = Stages.AuctionSuccessful;
@@ -138,7 +138,7 @@ contract Campaign {
returns (Market)
{
market = marketFactory.createMarket(eventContract, marketMaker, fee);
- require(eventContract.collateralToken().approve(market, funding));
+ require(eventContract.collateralToken().approve(address(market), funding));
market.fund(funding);
stage = Stages.MarketCreated;
emit MarketCreation(market);
@@ -156,7 +156,7 @@ contract Campaign {
market.close();
market.withdrawFees();
eventContract.redeemWinnings();
- finalBalance = eventContract.collateralToken().balanceOf(this);
+ finalBalance = eventContract.collateralToken().balanceOf(address(this));
stage = Stages.MarketClosed;
emit MarketClosing();
}
diff --git a/test/compilationTests/gnosis/Markets/StandardMarket.sol b/test/compilationTests/gnosis/Markets/StandardMarket.sol
index 0a9f77db..2f52a896 100644
--- a/test/compilationTests/gnosis/Markets/StandardMarket.sol
+++ b/test/compilationTests/gnosis/Markets/StandardMarket.sol
@@ -60,8 +60,8 @@ contract StandardMarket is Market {
atStage(Stages.MarketCreated)
{
// Request collateral tokens and allow event contract to transfer them to buy all outcomes
- require( eventContract.collateralToken().transferFrom(msg.sender, this, _funding)
- && eventContract.collateralToken().approve(eventContract, _funding));
+ require( eventContract.collateralToken().transferFrom(msg.sender, address(this), _funding)
+ && eventContract.collateralToken().approve(address(eventContract), _funding));
eventContract.buyAllOutcomes(_funding);
funding = _funding;
stage = Stages.MarketFunded;
@@ -76,7 +76,7 @@ contract StandardMarket is Market {
{
uint8 outcomeCount = eventContract.getOutcomeCount();
for (uint8 i = 0; i < outcomeCount; i++)
- require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(this)));
+ require(eventContract.outcomeTokens(i).transfer(creator, eventContract.outcomeTokens(i).balanceOf(address(this))));
stage = Stages.MarketClosed;
emit MarketClosing();
}
@@ -88,7 +88,7 @@ contract StandardMarket is Market {
isCreator
returns (uint fees)
{
- fees = eventContract.collateralToken().balanceOf(this);
+ fees = eventContract.collateralToken().balanceOf(address(this));
// Transfer fees
require(eventContract.collateralToken().transfer(creator, fees));
emit FeeWithdrawal(fees);
@@ -112,8 +112,8 @@ contract StandardMarket is Market {
// Check cost doesn't exceed max cost
require(cost > 0 && cost <= maxCost);
// Transfer tokens to markets contract and buy all outcomes
- require( eventContract.collateralToken().transferFrom(msg.sender, this, cost)
- && eventContract.collateralToken().approve(eventContract, outcomeTokenCost));
+ require( eventContract.collateralToken().transferFrom(msg.sender, address(this), cost)
+ && eventContract.collateralToken().approve(address(eventContract), outcomeTokenCost));
// Buy all outcomes
eventContract.buyAllOutcomes(outcomeTokenCost);
// Transfer outcome tokens to buyer
@@ -142,7 +142,7 @@ contract StandardMarket is Market {
// Check profit is not too low
require(profit > 0 && profit >= minProfit);
// Transfer outcome tokens to markets contract to sell all outcomes
- require(eventContract.outcomeTokens(outcomeTokenIndex).transferFrom(msg.sender, this, outcomeTokenCount));
+ require(eventContract.outcomeTokens(outcomeTokenIndex).transferFrom(msg.sender, address(this), outcomeTokenCount));
// Sell all outcomes
eventContract.sellAllOutcomes(outcomeTokenProfit);
// Transfer profit to seller
@@ -164,11 +164,11 @@ contract StandardMarket is Market {
returns (uint cost)
{
// Buy all outcomes
- require( eventContract.collateralToken().transferFrom(msg.sender, this, outcomeTokenCount)
- && eventContract.collateralToken().approve(eventContract, outcomeTokenCount));
+ require( eventContract.collateralToken().transferFrom(msg.sender, address(this), outcomeTokenCount)
+ && eventContract.collateralToken().approve(address(eventContract), outcomeTokenCount));
eventContract.buyAllOutcomes(outcomeTokenCount);
// Short sell selected outcome
- eventContract.outcomeTokens(outcomeTokenIndex).approve(this, outcomeTokenCount);
+ eventContract.outcomeTokens(outcomeTokenIndex).approve(address(this), outcomeTokenCount);
uint profit = this.sell(outcomeTokenIndex, outcomeTokenCount, minProfit);
cost = outcomeTokenCount - profit;
// Transfer outcome tokens to buyer
diff --git a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
index cf851f5b..83d10b2e 100644
--- a/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/FutarchyOracle.sol
@@ -95,14 +95,14 @@ contract FutarchyOracle is Oracle {
isCreator
{
// Buy all outcomes
- require( categoricalEvent.collateralToken().transferFrom(creator, this, funding)
- && categoricalEvent.collateralToken().approve(categoricalEvent, funding));
+ require( categoricalEvent.collateralToken().transferFrom(creator, address(this), funding)
+ && categoricalEvent.collateralToken().approve(address(categoricalEvent), funding));
categoricalEvent.buyAllOutcomes(funding);
// Fund each market with outcome tokens from categorical event
for (uint8 i = 0; i < markets.length; i++) {
Market market = markets[i];
// Approve funding for market
- require(market.eventContract().collateralToken().approve(market, funding));
+ require(market.eventContract().collateralToken().approve(address(market), funding));
market.fund(funding);
}
emit FutarchyFunding(funding);
@@ -122,7 +122,7 @@ contract FutarchyOracle is Oracle {
market.withdrawFees();
// Redeem collateral token for winning outcome tokens and transfer collateral tokens to creator
categoricalEvent.redeemWinnings();
- require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(this)));
+ require(categoricalEvent.collateralToken().transfer(creator, categoricalEvent.collateralToken().balanceOf(address(this))));
emit FutarchyClosing();
}
diff --git a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
index b7cc231c..452a34ec 100644
--- a/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
+++ b/test/compilationTests/gnosis/Oracles/UltimateOracle.sol
@@ -92,7 +92,7 @@ contract UltimateOracle is Oracle {
// There was no challenge yet or the challenge period expired
require( !isChallenged()
&& !isChallengePeriodOver()
- && collateralToken.transferFrom(msg.sender, this, challengeAmount));
+ && collateralToken.transferFrom(msg.sender, address(this), challengeAmount));
outcomeAmounts[msg.sender][_outcome] = challengeAmount;
totalOutcomeAmounts[_outcome] = challengeAmount;
totalAmount = challengeAmount;
@@ -113,7 +113,7 @@ contract UltimateOracle is Oracle {
// Outcome is challenged and front runner period is not over yet and tokens can be transferred
require( isChallenged()
&& !isFrontRunnerPeriodOver()
- && collateralToken.transferFrom(msg.sender, this, amount));
+ && collateralToken.transferFrom(msg.sender, address(this), amount));
outcomeAmounts[msg.sender][_outcome] = outcomeAmounts[msg.sender][_outcome].add(amount);
totalOutcomeAmounts[_outcome] = totalOutcomeAmounts[_outcome].add(amount);
totalAmount = totalAmount.add(amount);
diff --git a/test/compilationTests/zeppelin/Bounty.sol b/test/compilationTests/zeppelin/Bounty.sol
index 55e64071..1b5d05b4 100644
--- a/test/compilationTests/zeppelin/Bounty.sol
+++ b/test/compilationTests/zeppelin/Bounty.sol
@@ -31,8 +31,8 @@ contract Bounty is PullPayment, Destructible {
*/
function createTarget() public returns(Target) {
Target target = Target(deployContract());
- researchers[target] = msg.sender;
- emit TargetCreated(target);
+ researchers[address(target)] = msg.sender;
+ emit TargetCreated(address(target));
return target;
}
@@ -47,7 +47,7 @@ contract Bounty is PullPayment, Destructible {
* @param target contract
*/
function claim(Target target) public {
- address researcher = researchers[target];
+ address researcher = researchers[address(target)];
if (researcher == address(0)) {
revert();
}
diff --git a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
index 51f6b68e..c8b773ef 100644
--- a/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
+++ b/test/compilationTests/zeppelin/lifecycle/TokenDestructible.sol
@@ -26,7 +26,7 @@ contract TokenDestructible is Ownable {
// Transfer tokens to owner
for(uint256 i = 0; i < tokens.length; i++) {
ERC20Basic token = ERC20Basic(tokens[i]);
- uint256 balance = token.balanceOf(this);
+ uint256 balance = token.balanceOf(address(this));
token.transfer(owner, balance);
}
diff --git a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol
index df4284f1..87e0c6df 100644
--- a/test/compilationTests/zeppelin/ownership/HasNoTokens.sol
+++ b/test/compilationTests/zeppelin/ownership/HasNoTokens.sol
@@ -28,7 +28,7 @@ contract HasNoTokens is Ownable {
*/
function reclaimToken(address tokenAddr) external onlyOwner {
ERC20Basic tokenInst = ERC20Basic(tokenAddr);
- uint256 balance = tokenInst.balanceOf(this);
+ uint256 balance = tokenInst.balanceOf(address(this));
tokenInst.transfer(owner, balance);
}
}
diff --git a/test/compilationTests/zeppelin/token/TokenTimelock.sol b/test/compilationTests/zeppelin/token/TokenTimelock.sol
index fa1af025..a1722ebf 100644
--- a/test/compilationTests/zeppelin/token/TokenTimelock.sol
+++ b/test/compilationTests/zeppelin/token/TokenTimelock.sol
@@ -33,7 +33,7 @@ contract TokenTimelock {
require(msg.sender == beneficiary);
require(now >= releaseTime);
- uint amount = token.balanceOf(this);
+ uint amount = token.balanceOf(address(this));
require(amount > 0);
token.transfer(beneficiary, amount);
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index f52d270d..e9e7c93b 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -9428,7 +9428,7 @@ BOOST_AUTO_TEST_CASE(failed_create)
if (depth < 1024)
return this.stack(depth - 1);
else
- return f(0);
+ return address(f(0));
}
}
)";
diff --git a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol
index ea2ec8f6..17cb701d 100644
--- a/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol
+++ b/test/libsolidity/syntaxTests/constructor/inconstructible_internal_constructor_inverted.sol
@@ -7,6 +7,7 @@ contract B {
}
}
contract A {
- constructor(address) public {}
+ constructor(address) internal {}
}
// ----
+// TypeError: (141-146): Contract with internal constructor cannot be created directly.