aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-02-24 22:42:52 +0800
committerGitHub <noreply@github.com>2017-02-24 22:42:52 +0800
commit673268a6f8345e9276764f13e105869f5be92adc (patch)
tree24fca84a746ec5b56d97070529212b1c76f114bb /test
parentbec3c6fab6bf02aea5664be4423f45e98db22e8e (diff)
parent4d290e551c2d563671f9d56744883d3f3dff98ec (diff)
downloaddexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.tar
dexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.tar.gz
dexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.tar.bz2
dexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.tar.lz
dexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.tar.xz
dexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.tar.zst
dexon-solidity-673268a6f8345e9276764f13e105869f5be92adc.zip
Merge pull request #1651 from ethereum/transfer-method
Add address.transfer(value)
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp36
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp18
2 files changed, 54 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 68f8fbef..cb0cc168 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -1681,6 +1681,42 @@ BOOST_AUTO_TEST_CASE(send_ether)
BOOST_CHECK_EQUAL(balanceAt(address), amount);
}
+BOOST_AUTO_TEST_CASE(transfer_ether)
+{
+ char const* sourceCode = R"(
+ contract A {
+ function A() payable {}
+ function a(address addr, uint amount) returns (uint) {
+ addr.transfer(amount);
+ return this.balance;
+ }
+ function b(address addr, uint amount) {
+ addr.transfer(amount);
+ }
+ }
+
+ contract B {
+ }
+
+ contract C {
+ function () payable {
+ throw;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "B");
+ u160 const nonPayableRecipient = m_contractAddress;
+ compileAndRun(sourceCode, 0, "C");
+ u160 const oogRecipient = m_contractAddress;
+ compileAndRun(sourceCode, 20, "A");
+ u160 payableRecipient(23);
+ BOOST_CHECK(callContractFunction("a(address,uint256)", payableRecipient, 10) == encodeArgs(10));
+ BOOST_CHECK_EQUAL(balanceAt(payableRecipient), 10);
+ BOOST_CHECK_EQUAL(balanceAt(m_contractAddress), 10);
+ BOOST_CHECK(callContractFunction("b(address,uint256)", nonPayableRecipient, 10) == encodeArgs());
+ BOOST_CHECK(callContractFunction("b(address,uint256)", oogRecipient, 10) == encodeArgs());
+}
+
BOOST_AUTO_TEST_CASE(log0)
{
char const* sourceCode = R"(
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index a1ebc300..bb274614 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -5108,6 +5108,24 @@ BOOST_AUTO_TEST_CASE(early_exit_on_fatal_errors)
CHECK_ERROR(text, DeclarationError, "Identifier not found or not unique");
}
+BOOST_AUTO_TEST_CASE(address_methods)
+{
+ char const* text = R"(
+ contract C {
+ function f() {
+ address addr;
+ uint balance = addr.balance;
+ bool callRet = addr.call();
+ bool callcodeRet = addr.callcode();
+ bool delegatecallRet = addr.delegatecall();
+ bool sendRet = addr.send(1);
+ addr.transfer(1);
+ }
+ }
+ )";
+ CHECK_SUCCESS(text);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}