Test for negative stack height.

This commit is contained in:
chriseth 2017-06-23 17:27:57 +02:00 committed by Alex Beregszaszi
parent 79d1336687
commit 46caff4597

View File

@ -9501,6 +9501,27 @@ BOOST_AUTO_TEST_CASE(revert)
BOOST_CHECK(callContractFunction("a()") == encodeArgs(u256(42)));
}
BOOST_AUTO_TEST_CASE(negative_stack_height)
{
// This code was causing negative stack height during code generation
// because the stack height was not adjusted at the beginning of functions.
char const* sourceCode = R"(
contract C {
mapping(uint => Invoice) public invoices;
struct Invoice {
uint AID;
bool Aboola;
bool Aboolc;
bool exists;
}
function nredit(uint startindex) public constant returns(uint[500] CIDs, uint[500] dates, uint[500] RIDs, bool[500] Cboolas, uint[500] amounts){}
function return500InvoicesByDates(uint begindate, uint enddate, uint startindex) public constant returns(uint[500] AIDs, bool[500] Aboolas, uint[500] dates, bytes32[3][500] Abytesas, bytes32[3][500] bytesbs, bytes32[2][500] bytescs, uint[500] amounts, bool[500] Aboolbs, bool[500] Aboolcs){}
function return500PaymentsByDates(uint begindate, uint enddate, uint startindex) public constant returns(uint[500] BIDs, uint[500] dates, uint[500] RIDs, bool[500] Bboolas, bytes32[3][500] bytesbs,bytes32[2][500] bytescs, uint[500] amounts, bool[500] Bboolbs){}
}
)";
compileAndRun(sourceCode, 0, "C");
}
BOOST_AUTO_TEST_CASE(literal_empty_string)
{
char const* sourceCode = R"(