aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-16 22:13:56 +0800
committerGitHub <noreply@github.com>2016-08-16 22:13:56 +0800
commit480cf384bbe923bdb3c5e1a16fb4670a2db6c03c (patch)
tree314a8489030bdd9c2c8f0f6496a259eaaa6259e2 /test/libsolidity/SolidityEndToEndTest.cpp
parent70994f49960dd7066ad5de6fe835ccb1201269a6 (diff)
parent2a560b798b5f5ece6dfb500a8e03409c62332e41 (diff)
downloaddexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.tar
dexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.tar.gz
dexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.tar.bz2
dexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.tar.lz
dexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.tar.xz
dexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.tar.zst
dexon-solidity-480cf384bbe923bdb3c5e1a16fb4670a2db6c03c.zip
Merge pull request #710 from chriseth/throwFailedCreate
BREAKING: Throw if contract creation fails.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 1b7c5ea4..46756493 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -6839,6 +6839,33 @@ BOOST_AUTO_TEST_CASE(skip_dynamic_types_for_structs)
BOOST_CHECK(callContractFunction("g()") == encodeArgs(u256(2), u256(6)));
}
+BOOST_AUTO_TEST_CASE(failed_create)
+{
+ char const* sourceCode = R"(
+ contract D { }
+ contract C {
+ uint public x;
+ function f(uint amount) returns (address) {
+ x++;
+ return (new D).value(amount)();
+ }
+ function stack(uint depth) returns (address) {
+ if (depth < 1024)
+ return this.stack(depth - 1);
+ else
+ return f(0);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 20, "C");
+ BOOST_CHECK(callContractFunction("f(uint256)", 20) != encodeArgs(u256(0)));
+ BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(1)));
+ BOOST_CHECK(callContractFunction("f(uint256)", 20) == encodeArgs());
+ BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(1)));
+ BOOST_CHECK(callContractFunction("stack(uint256)", 1023) == encodeArgs());
+ BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(1)));
+}
+
BOOST_AUTO_TEST_CASE(create_dynamic_array_with_zero_length)
{
char const* sourceCode = R"(