aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-02-06 06:43:36 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-02-24 08:17:45 +0800
commit16e48219d3071038bf7f696f234b50f6370a1171 (patch)
treea35eeadb0d9b69255df2ab3ce03c412baece602c /test
parent4264625c69a30c4534e977ce3ca709bb95103dad (diff)
downloaddexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.tar
dexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.tar.gz
dexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.tar.bz2
dexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.tar.lz
dexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.tar.xz
dexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.tar.zst
dexon-solidity-16e48219d3071038bf7f696f234b50f6370a1171.zip
Add test for address.transfer()
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp36
1 files changed, 36 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"(