aboutsummaryrefslogtreecommitdiffstats
path: root/test/libsolidity/SolidityEndToEndTest.cpp
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-12-30 20:48:07 +0800
committerchriseth <chris@ethereum.org>2018-04-12 19:09:37 +0800
commita06249c98484f8ca3772b09f66bc68dd30c13c4d (patch)
tree7d6a2032f144832d1b1e2f0911a4da88a782bfdb /test/libsolidity/SolidityEndToEndTest.cpp
parent012ab37fe3984a692dcdda6ef516e4588a8721b3 (diff)
downloaddexon-solidity-a06249c98484f8ca3772b09f66bc68dd30c13c4d.tar.gz
dexon-solidity-a06249c98484f8ca3772b09f66bc68dd30c13c4d.tar.zst
dexon-solidity-a06249c98484f8ca3772b09f66bc68dd30c13c4d.zip
Tests for revert with reason string.
Diffstat (limited to 'test/libsolidity/SolidityEndToEndTest.cpp')
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index f7f1062d..82ad2917 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -10419,6 +10419,43 @@ BOOST_AUTO_TEST_CASE(revert)
ABI_CHECK(callContractFunction("a()"), encodeArgs(u256(42)));
}
+BOOST_AUTO_TEST_CASE(revert_with_cause)
+{
+ char const* sourceCode = R"(
+ contract D {
+ function f() public {
+ revert("test123");
+ }
+ function g() public {
+ revert("test1234567890123456789012345678901234567890");
+ }
+ }
+ 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);
+ }
+ function g() 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, "test123"));
+ ABI_CHECK(callContractFunction("g()"), encodeArgs(0, 0x40, 0xa0, 0, 0x40, 44, "test1234567890123456789012345678901234567890"));
+}
+
BOOST_AUTO_TEST_CASE(negative_stack_height)
{
// This code was causing negative stack height during code generation