mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for revert with reason string.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user