diff options
author | Christian <c@ethdev.com> | 2015-01-14 01:12:19 +0800 |
---|---|---|
committer | Christian <c@ethdev.com> | 2015-01-14 01:12:30 +0800 |
commit | e1559df82e16737e694613e8ffd2065a0bc21fa1 (patch) | |
tree | d23dc16e08c00d9585d59a8836168e170965fa89 | |
parent | 522a7709e8fa65f57a4213d4dda875e04af0c64e (diff) | |
download | dexon-solidity-e1559df82e16737e694613e8ffd2065a0bc21fa1.tar.gz dexon-solidity-e1559df82e16737e694613e8ffd2065a0bc21fa1.tar.zst dexon-solidity-e1559df82e16737e694613e8ffd2065a0bc21fa1.zip |
Specify value for contract creation.
-rw-r--r-- | SolidityEndToEndTest.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/SolidityEndToEndTest.cpp b/SolidityEndToEndTest.cpp index 774df3d9..16787c8e 100644 --- a/SolidityEndToEndTest.cpp +++ b/SolidityEndToEndTest.cpp @@ -1376,6 +1376,34 @@ BOOST_AUTO_TEST_CASE(value_insane) BOOST_REQUIRE(callContractFunction("sendAmount(uint256)", 5) == encodeArgs(8)); } +BOOST_AUTO_TEST_CASE(value_for_constructor) +{ + char const* sourceCode = R"( + contract Helper { + string3 name; + bool flag; + function Helper(string3 x, bool f) { + name = x; + flag = f; + } + function getName() returns (string3 ret) { return name; } + function getFlag() returns (bool ret) { return flag; } + } + contract Main { + Helper h; + function Main() { + h = new Helper.value(10)("abc", true); + } + function getFlag() returns (bool ret) { return h.getFlag(); } + function getName() returns (string3 ret) { return h.getName(); } + function getBalances() returns (uint me, uint them) { me = this.balance; them = h.balance;} + })"; + compileAndRun(sourceCode, 22, "Main"); + BOOST_REQUIRE(callContractFunction("getFlag()") == encodeArgs(true)); + BOOST_REQUIRE(callContractFunction("getName()") == encodeArgs("abc")); + BOOST_REQUIRE(callContractFunction("getBalances()") == encodeArgs(12, 10)); +} + BOOST_AUTO_TEST_SUITE_END() } |