Skip to content

Disallow non-default expectedExecutionsPerDeployment in evmasm tests when only a creation object is present #16023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: subassemblies-in-evm-assembly-tests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/libevmasm/EVMAssemblyTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ EVMAssemblyTest::EVMAssemblyTest(std::string const& _filename):
"none"
);
m_optimizerSettings = Assembly::OptimiserSettings::translateSettings(OptimiserSettings::preset(optimizationPreset));
size_t defaultExpectedExecutionsPerDeployment = m_optimizerSettings.expectedExecutionsPerDeployment;
m_optimizerSettings.expectedExecutionsPerDeployment = m_reader.sizetSetting(
"optimizer.expectedExecutionsPerDeployment",
m_optimizerSettings.expectedExecutionsPerDeployment
);
m_usingDefaultExpectedExecutionsPerDeployment =
m_optimizerSettings.expectedExecutionsPerDeployment == defaultExpectedExecutionsPerDeployment;

auto const optimizerComponentSetting = [&](std::string const& _component, bool& _setting) {
_setting = m_reader.boolSetting("optimizer." + _component, _setting);
Expand Down Expand Up @@ -132,6 +135,14 @@ TestCase::TestResult EVMAssemblyTest::run(std::ostream& _stream, std::string con
return checkResult(_stream, _linePrefix, _formatted);
}

soltestAssert(evmAssemblyStack.evmAssembly());
if (!m_usingDefaultExpectedExecutionsPerDeployment && evmAssemblyStack.evmAssembly()->numSubs() == 0)
// This is a common mistake. We can't issue a warning here, so let's report it as an error.
BOOST_THROW_EXCEPTION(std::runtime_error(
"The custom value specified for optimizer.expectedExecutionsPerDeployment has no effect "
"on the creation assembly, which is the only assembly in the test."
));

try
{
evmAssemblyStack.assemble();
Expand Down
1 change: 1 addition & 0 deletions test/libevmasm/EVMAssemblyTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class EVMAssemblyTest: public frontend::test::EVMVersionRestrictedTestCase
AssemblyFormat m_assemblyFormat{};
std::string m_selectedOutputs;
evmasm::Assembly::OptimiserSettings m_optimizerSettings;
bool m_usingDefaultExpectedExecutionsPerDeployment{};
};

}