diff --git a/test/libevmasm/EVMAssemblyTest.cpp b/test/libevmasm/EVMAssemblyTest.cpp index 0c1dbb07ed7c..3bc43b188294 100644 --- a/test/libevmasm/EVMAssemblyTest.cpp +++ b/test/libevmasm/EVMAssemblyTest.cpp @@ -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); @@ -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(); diff --git a/test/libevmasm/EVMAssemblyTest.h b/test/libevmasm/EVMAssemblyTest.h index 9059fd716d81..9a276ddeb6b4 100644 --- a/test/libevmasm/EVMAssemblyTest.h +++ b/test/libevmasm/EVMAssemblyTest.h @@ -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{}; }; }