Tests after making all explicit address conversions as non-payable

This commit is contained in:
hrkrshnn 2020-12-14 16:51:07 +01:00
parent f30c7cbac8
commit 7438c4dc16
26 changed files with 119 additions and 31 deletions

View File

@ -438,7 +438,7 @@ operations as long as there is enough gas passed on to it.
// results in test.x becoming == 1 and test.y becoming 1.
// If someone sends Ether to that contract, the receive function in TestPayable will be called.
require(address(test).send(2 ether));
require(payable(test).send(2 ether));
// results in test.x becoming == 2 and test.y becoming 2 ether.
return true;

View File

@ -90,10 +90,10 @@ contract module {
@newModuleAddress New module handler address
*/
require( moduleStatus != status.New && moduleStatus != status.Disconnected);
(bool _success, uint256 _balance) = abstractModuleHandler(moduleHandlerAddress).balanceOf(address(this));
(bool _success, uint256 _balance) = abstractModuleHandler(moduleHandlerAddress).balanceOf(payable(this));
require( _success );
if ( _balance > 0 ) {
require( abstractModuleHandler(moduleHandlerAddress).transfer(address(this), newModuleAddress, _balance, false) );
require( abstractModuleHandler(moduleHandlerAddress).transfer(payable(this), newModuleAddress, _balance, false) );
}
if ( address(this).balance > 0 ) {
require( newModuleAddress.send(address(this).balance) );

View File

@ -724,11 +724,11 @@ contract DAO is DAOInterface, Token, TokenCreation {
reward = address(DAOrewardAccount).balance < reward ? address(DAOrewardAccount).balance : reward;
if(_toMembers) {
if (!DAOrewardAccount.payOut(address(dao.rewardAccount()), reward))
if (!DAOrewardAccount.payOut(payable(dao.rewardAccount()), reward))
revert();
}
else {
if (!DAOrewardAccount.payOut(address(dao), reward))
if (!DAOrewardAccount.payOut(payable(dao), reward))
revert();
}
DAOpaidOut[msg.sender] += reward;

View File

@ -124,7 +124,7 @@ override returns (bool success) {
if (block.timestamp > closingTime && !isFueled) {
// Get extraBalance - will only succeed when called for the first time
if (address(extraBalance).balance >= extraBalance.accumulatedInput())
extraBalance.payOut(address(this), extraBalance.accumulatedInput());
extraBalance.payOut(payable(this), extraBalance.accumulatedInput());
// Execute refund
(bool success,) = msg.sender.call{value: weiGiven[msg.sender]}("");

View File

@ -1328,7 +1328,7 @@ BOOST_AUTO_TEST_CASE(contracts_as_addresses)
}
contract test {
helper h;
constructor() payable { h = new helper(); address(h).send(5); }
constructor() payable { h = new helper(); payable(h).send(5); }
function getBalance() public returns (uint256 myBalance, uint256 helperBalance) {
myBalance = address(this).balance;
helperBalance = address(h).balance;
@ -4640,7 +4640,7 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer)
revert("message");
}
function f() public {
address(this).transfer(0);
payable(this).transfer(0);
}
}
contract C {

View File

@ -18,7 +18,7 @@ contract C {
assembly {
y := x
}
address payable z = address(y);
address payable z = payable(y);
assembly {
r := z
}

View File

@ -1,7 +1,7 @@
contract TransferTest {
fallback() external payable {
// This used to cause an ICE
address(this).transfer;
payable(this).transfer;
}
function f() pure public {}

View File

@ -10,7 +10,7 @@ contract Main {
function s() public returns (bool) {
Receiver r = new Receiver();
return address(r).send(0);
return payable(r).send(0);
}
}

View File

@ -8,13 +8,13 @@ contract C {
A a = new A();
receive() external payable {}
function f() public {
address(a).transfer(1 wei);
payable(a).transfer(1 wei);
}
function h() public {
address(a).transfer(100 ether);
payable(a).transfer(100 ether);
}
function g() public view returns (uint) {
return address(this).balance;
return payable(this).balance;
}
}
// ====

View File

@ -1,5 +1,5 @@
contract C {
function f() public returns (address payable) {
function f() public returns (address) {
return msg.sender;
}
}

View File

@ -1,5 +1,5 @@
contract C {
function f() public returns (address payable) {
function f() public returns (address) {
return tx.origin;
}
}

View File

@ -9,7 +9,7 @@ contract B {
A a;
fallback() external {
address(a).transfer(100);
payable(a).transfer(100);
}
}
// ----

View File

@ -4,7 +4,7 @@ contract C {
return 1;
}
function transfer(uint amount) public {
address(this).transfer(amount); // to avoid pureness warning
payable(this).transfer(amount); // to avoid pureness warning
}
receive() payable external {
}

View File

@ -13,7 +13,7 @@ contract B {
}
S s;
function f() public {
s.a = address(this);
s.a = payable(this);
}
receive() external payable {
}

View File

@ -1,6 +1,6 @@
contract C {
function f() public pure returns (C c) {
c = C(payable(2));
c = C(payable(address(2)));
}
receive() external payable {
}

View File

@ -0,0 +1,23 @@
contract C {
function f() public view {
address a1 = address(uint160(0));
address a2 = address(bytes20(0));
address a3 = address(this);
address payable a4 = payable(uint160(0));
address payable a5 = payable(bytes20(0));
address payable a6 = payable(this);
// Trivial conversions
address payable a7 = payable(address(uint160(0)));
address payable a8 = payable(address(bytes20(0)));
address payable a9 = payable(address(this));
a1; a2; a3; a4; a5; a6; a7; a8; a9;
}
// to make payable(this) work
receive() payable external {
}
}
// ----

View File

@ -0,0 +1,11 @@
contract C {
function f() public pure {
address payable a = address(uint160(0));
address payable b = address(bytes20(0));
address payable c = address(this);
}
}
// ----
// TypeError 9574: (52-91): Type address is not implicitly convertible to expected type address payable.
// TypeError 9574: (101-140): Type address is not implicitly convertible to expected type address payable.
// TypeError 9574: (150-183): Type address is not implicitly convertible to expected type address payable.

View File

@ -1,5 +1,5 @@
contract C {
function f(bytes20 x) public pure returns (address payable) {
return address(x);
return payable(x);
}
}

View File

@ -1,6 +1,6 @@
contract C {
function f() public view {
address payable a = address(this);
address payable a = payable(this);
a;
}
fallback() external payable {

View File

@ -1,6 +1,6 @@
contract C {
function f() public view {
address payable a = address(this);
address payable a = payable(this);
a;
}
receive() external payable {

View File

@ -0,0 +1,29 @@
contract C {
function f() public {
address payable a = payable(address(new D()));
address payable b = payable(new E());
address payable c = payable(new F());
a;
b;
c;
}
}
// A contract that cannot receive Ether
contract D {}
// A contract that can receive Ether
contract E {
receive() external payable {
}
}
// A contract that can receive Ether using the fallback
contract F {
fallback() external payable {
}
}
// ----

View File

@ -0,0 +1,17 @@
contract C {
function f() public {
address payable a = address(new D());
// This conversion makes no sense anyway.
address payable b = address(D);
}
}
contract D {
receive() external payable {
}
}
// ----
// TypeError 9574: (47-83): Type address is not implicitly convertible to expected type address payable.
// TypeError 9640: (164-174): Explicit type conversion not allowed from "type(contract D)" to "address".
// TypeError 9574: (144-174): Type address is not implicitly convertible to expected type address payable.

View File

@ -0,0 +1,8 @@
contract C {
function f() public pure returns (C c) {
c = C(payable(2));
}
receive() external payable {
}
}
// ----

View File

@ -1,5 +1,5 @@
contract C {
function f(uint x) public pure returns (address payable) {
return address(uint160(x));
return payable(uint160(x));
}
}

View File

@ -1,8 +1,8 @@
contract C {
function f() public {
address(this).transfer(1);
require(address(this).send(2));
selfdestruct(address(this));
payable(this).transfer(1);
require(payable(this).send(2));
selfdestruct(payable(this));
(bool success,) = address(this).delegatecall("");
require(success);
(success,) = address(this).call("");

View File

@ -1,12 +1,12 @@
contract C {
function f() view public {
address(this).transfer(1);
payable(this).transfer(1);
}
function g() view public {
require(address(this).send(2));
require(payable(this).send(2));
}
function h() view public {
selfdestruct(address(this));
selfdestruct(payable(this));
}
function i() view public {
(bool success,) = address(this).delegatecall("");