Merge pull request #10807 from ethereum/fixIRReasonStrings

Properly omit require revert strings in IR code generator if requested.
This commit is contained in:
Leonardo
2021-01-19 10:31:15 +01:00
committed by GitHub
2 changed files with 28 additions and 22 deletions
+24 -21
View File
@@ -5516,29 +5516,32 @@ BOOST_AUTO_TEST_CASE(strip_reason_strings)
}
}
)";
m_revertStrings = RevertStrings::Default;
compileAndRun(sourceCode, 0, "C");
ALSO_VIA_YUL(
DISABLE_EWASM_TESTRUN()
m_revertStrings = RevertStrings::Default;
compileAndRun(sourceCode, 0, "C");
if (
m_optimiserSettings == OptimiserSettings::minimal() ||
m_optimiserSettings == OptimiserSettings::none()
if (
m_optimiserSettings == OptimiserSettings::minimal() ||
m_optimiserSettings == OptimiserSettings::none()
)
// check that the reason string IS part of the binary.
BOOST_CHECK(toHex(m_output).find("736f6d6520726561736f6e") != std::string::npos);
m_revertStrings = RevertStrings::Strip;
compileAndRun(sourceCode, 0, "C");
// check that the reason string is NOT part of the binary.
BOOST_CHECK(toHex(m_output).find("736f6d6520726561736f6e") == std::string::npos);
ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(7));
ABI_CHECK(callContractFunction("f(bool)", false), encodeArgs());
ABI_CHECK(callContractFunction("g(bool)", true), encodeArgs(8));
ABI_CHECK(callContractFunction("g(bool)", false), encodeArgs());
ABI_CHECK(callContractFunction("f1(bool)", true), encodeArgs(9));
ABI_CHECK(callContractFunction("f1(bool)", false), encodeArgs());
ABI_CHECK(callContractFunction("g1(bool)", true), encodeArgs(10));
ABI_CHECK(callContractFunction("g1(bool)", false), encodeArgs());
)
// check that the reason string IS part of the binary.
BOOST_CHECK(toHex(m_output).find("736f6d6520726561736f6e") != std::string::npos);
m_revertStrings = RevertStrings::Strip;
compileAndRun(sourceCode, 0, "C");
// check that the reason string is NOT part of the binary.
BOOST_CHECK(toHex(m_output).find("736f6d6520726561736f6e") == std::string::npos);
ABI_CHECK(callContractFunction("f(bool)", true), encodeArgs(7));
ABI_CHECK(callContractFunction("f(bool)", false), encodeArgs());
ABI_CHECK(callContractFunction("g(bool)", true), encodeArgs(8));
ABI_CHECK(callContractFunction("g(bool)", false), encodeArgs());
ABI_CHECK(callContractFunction("f1(bool)", true), encodeArgs(9));
ABI_CHECK(callContractFunction("f1(bool)", false), encodeArgs());
ABI_CHECK(callContractFunction("g1(bool)", true), encodeArgs(10));
ABI_CHECK(callContractFunction("g1(bool)", false), encodeArgs());
}
BOOST_AUTO_TEST_SUITE_END()