aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-01-03 22:07:25 +0800
committerchriseth <chris@ethereum.org>2018-04-12 19:09:38 +0800
commitaa715f8759934ac68b76a2bef84c460b68be636a (patch)
tree4df4151c8da9ee0da077f3217cd3461929aad79d /test
parent7a9ee69e986cf58c8b2a6cabec2c59b0eb2fbb57 (diff)
downloaddexon-solidity-aa715f8759934ac68b76a2bef84c460b68be636a.tar.gz
dexon-solidity-aa715f8759934ac68b76a2bef84c460b68be636a.tar.zst
dexon-solidity-aa715f8759934ac68b76a2bef84c460b68be636a.zip
Tests about error bubbling for create and transfer.
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp72
1 files changed, 70 insertions, 2 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 41ebe462..c7d8f917 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -10545,8 +10545,76 @@ BOOST_AUTO_TEST_CASE(bubble_up_error_messages)
}
)";
compileAndRun(sourceCode, 0, "C");
- ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 0x40, 0x80, 0, 0x40, 3, "message"));
- ABI_CHECK(callContractFunction("g()"), encodeArgs(0, 0x40, 0x80, 0, 0x40, 3, "message"));
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 0x40, 0x80, 0, 0x40, 7, "message"));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(0, 0x40, 0x80, 0, 0x40, 7, "message"));
+}
+
+BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_transfer)
+{
+ char const* sourceCode = R"(
+ contract D {
+ function() public payable {
+ revert("message");
+ }
+ function f() public {
+ this.transfer(0);
+ }
+ }
+ contract C {
+ D d = new D();
+ function forward(address target, bytes data) internal returns (bool success, bytes retval) {
+ uint retsize;
+ assembly {
+ success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0)
+ retsize := returndatasize()
+ }
+ retval = new bytes(retsize);
+ assembly {
+ returndatacopy(add(retval, 0x20), 0, returndatasize())
+ }
+ }
+ function f() public returns (bool, bytes) {
+ return forward(address(d), msg.data);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 0x40, 0x80, 0, 0x40, 7, "message"));
+}
+
+BOOST_AUTO_TEST_CASE(bubble_up_error_messages_through_create)
+{
+ char const* sourceCode = R"(
+ contract E {
+ function E() {
+ revert("message");
+ }
+ }
+ contract D {
+ function f() public {
+ var x = new E();
+ }
+ }
+ contract C {
+ D d = new D();
+ function forward(address target, bytes data) internal returns (bool success, bytes retval) {
+ uint retsize;
+ assembly {
+ success := call(not(0), target, 0, add(data, 0x20), mload(data), 0, 0)
+ retsize := returndatasize()
+ }
+ retval = new bytes(retsize);
+ assembly {
+ returndatacopy(add(retval, 0x20), 0, returndatasize())
+ }
+ }
+ function f() public returns (bool, bytes) {
+ return forward(address(d), msg.data);
+ }
+ }
+ )";
+ compileAndRun(sourceCode, 0, "C");
+ ABI_CHECK(callContractFunction("f()"), encodeArgs(0, 0x40, 0x80, 0, 0x40, 7, "message"));
}
BOOST_AUTO_TEST_CASE(negative_stack_height)