Yul interpreter: Smaller execution timeout for tests and additional test cases

This commit is contained in:
Bhargava Shastry 2020-07-22 22:59:15 +02:00
parent 7ad27188a0
commit 0b1d0e0bd2
4 changed files with 40 additions and 10 deletions

View File

@ -87,8 +87,8 @@ bool YulInterpreterTest::parse(ostream& _stream, string const& _linePrefix, bool
string YulInterpreterTest::interpret() string YulInterpreterTest::interpret()
{ {
InterpreterState state; InterpreterState state;
state.maxTraceSize = 10000; state.maxTraceSize = 10;
state.maxSteps = 10000; state.maxSteps = 150;
try try
{ {
Interpreter::run(state, EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}), *m_ast); Interpreter::run(state, EVMDialect::strictAssemblyForEVMObjects(langutil::EVMVersion{}), *m_ast);

View File

@ -0,0 +1,11 @@
{
function f() {
f()
}
f()
}
// ----
// Trace:
// Interpreter execution step limit reached.
// Memory dump:
// Storage dump:

View File

@ -0,0 +1,22 @@
{
function f() {
log0(0x0, 0x0)
f()
}
f()
}
// ----
// Trace:
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// LOG0(0, 0)
// Trace size limit reached.
// Memory dump:
// Storage dump:

View File

@ -91,25 +91,22 @@ DEFINE_PROTO_FUZZER(Program const& _input)
ostringstream os1; ostringstream os1;
ostringstream os2; ostringstream os2;
yulFuzzerUtil::TerminationReason termReason = yulFuzzerUtil::interpret( yulFuzzerUtil::interpret(
os1, os1,
stack.parserResult()->code, stack.parserResult()->code,
EVMDialect::strictAssemblyForEVMObjects(version) EVMDialect::strictAssemblyForEVMObjects(version)
); );
if (
termReason == yulFuzzerUtil::TerminationReason::StepLimitReached ||
termReason == yulFuzzerUtil::TerminationReason::TraceLimitReached
)
return;
stack.optimize(); stack.optimize();
yulFuzzerUtil::interpret( yulFuzzerUtil::TerminationReason termReason = yulFuzzerUtil::interpret(
os2, os2,
stack.parserResult()->code, stack.parserResult()->code,
EVMDialect::strictAssemblyForEVMObjects(version) EVMDialect::strictAssemblyForEVMObjects(version)
); );
if (termReason == yulFuzzerUtil::TerminationReason::StepLimitReached)
return;
bool isTraceEq = (os1.str() == os2.str()); bool isTraceEq = (os1.str() == os2.str());
yulAssert(isTraceEq, "Interpreted traces for optimized and unoptimized code differ."); yulAssert(isTraceEq, "Interpreted traces for optimized and unoptimized code differ.");
return; return;