diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2016-08-04 23:47:46 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-09-06 03:28:18 +0800 |
commit | 34a6afbd77f499ca4883a62a8de642db1c062e53 (patch) | |
tree | afba0d5c78bc5ac285b192b053ab10aab39d00f3 /test | |
parent | 75d556a2cfb6ae043b6d9fa375e4a6410145e4d1 (diff) | |
download | dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.tar dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.tar.gz dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.tar.bz2 dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.tar.lz dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.tar.xz dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.tar.zst dexon-solidity-34a6afbd77f499ca4883a62a8de642db1c062e53.zip |
Include EndToEnd test for payable keyword
Diffstat (limited to 'test')
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index f3fdef15..f855c2a3 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -7087,6 +7087,63 @@ BOOST_AUTO_TEST_CASE(calling_nonexisting_contract_throws) BOOST_CHECK(callContractFunction("h()") == encodeArgs(u256(7))); } +BOOST_AUTO_TEST_CASE(payable_accept_explicit_constructor) +{ + char const* sourceCode = R"( + contract C { + function () payable { } + } + )"; + compileAndRun(sourceCode, 27, "C"); +} + + +BOOST_AUTO_TEST_CASE(payable_accept_explicit) +{ + char const* sourceCode = R"( + contract C { + function f() payable returns (uint) { + return msg.value; + } + function() payable returns (uint) { + return msg.value; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunctionWithValue("f()", 27) == encodeArgs(u256(27))); + BOOST_CHECK(callContractFunctionWithValue("", 27) == encodeArgs(u256(27))); +} + +BOOST_AUTO_TEST_CASE(non_payable_throw_constructor) +{ + char const* sourceCode = R"( + contract C { + function() { } + } + )"; + compileAndRun(sourceCode, 27, "C"); +} + +BOOST_AUTO_TEST_CASE(non_payable_throw) +{ + char const* sourceCode = R"( + contract C { + string public a; + function f() returns (uint) { + return msg.value; + } + function() returns (uint) { + return msg.value; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunctionWithValue("f()", 27) == encodeArgs()); + BOOST_CHECK(callContractFunctionWithValue("", 27) == encodeArgs()); + BOOST_CHECK(callContractFunctionWithValue("a()", 27) == encodeArgs()); +} + BOOST_AUTO_TEST_SUITE_END() } |