aboutsummaryrefslogtreecommitdiffstats
path: root/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-08 05:54:56 +0800
committerChristian <c@ethdev.com>2015-01-10 01:31:36 +0800
commit4b11eea653edf2361fad58a97e2010eeffca9832 (patch)
treea093d62de2e482e9feb3cf02a0d1260ccbb1dc9e /SolidityEndToEndTest.cpp
parent3d896c74e605dd160994f0f1c84ec72d29484fac (diff)
downloaddexon-solidity-4b11eea653edf2361fad58a97e2010eeffca9832.tar.gz
dexon-solidity-4b11eea653edf2361fad58a97e2010eeffca9832.tar.zst
dexon-solidity-4b11eea653edf2361fad58a97e2010eeffca9832.zip
Contracts are Addresses.
Diffstat (limited to 'SolidityEndToEndTest.cpp')
-rw-r--r--SolidityEndToEndTest.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp
index baad4b42..9f2e0d42 100644
--- a/SolidityEndToEndTest.cpp
+++ b/SolidityEndToEndTest.cpp
@@ -844,9 +844,9 @@ BOOST_AUTO_TEST_CASE(type_conversions_cleanup)
function test() returns (uint ret) { return uint(address(Test(address(0x11223344556677889900112233445566778899001122)))); }
})";
compileAndRun(sourceCode);
- BOOST_REQUIRE(callContractFunction(0) == bytes({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22,
- 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22}));
+ BOOST_REQUIRE(callContractFunction("test()") == bytes({0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22,
+ 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22}));
}
@@ -1277,6 +1277,24 @@ BOOST_AUTO_TEST_CASE(functions_called_by_constructor)
BOOST_REQUIRE(callContractFunction("getName()") == bytes({'a', 'b', 'c'}));
}
+BOOST_AUTO_TEST_CASE(contracts_as_addresses)
+{
+ char const* sourceCode = R"(
+ contract helper {
+ }
+ contract test {
+ helper h;
+ function test() { h = new helper(); h.send(5); }
+ function getBalance() returns (uint256 myBalance, uint256 helperBalance) {
+ myBalance = this.balance;
+ helperBalance = h.balance;
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 20);
+ BOOST_REQUIRE(callContractFunction("getBalance()") == toBigEndian(u256(20 - 5)) + toBigEndian(u256(5)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}