@@ -123,7 +123,12 @@ void SemanticTest::initializeBuiltins()
123
123
solAssert (m_builtins.count (" smokeTest" ) == 0 , " " );
124
124
m_builtins[" smokeTest" ] = [](FunctionCall const &) -> std::optional<bytes>
125
125
{
126
- return util::toBigEndian (u256 (0x1234 ));
126
+ return util::toBigEndian (u256 (0x1234 ));
127
+ };
128
+ solAssert (m_builtins.count (" effectsTest" ) == 0 , " " );
129
+ m_builtins[" effectsTest" ] = [](FunctionCall const &) -> std::optional<bytes>
130
+ {
131
+ return util::toBigEndian (u256 (0x2345 ));
127
132
};
128
133
soltestAssert (m_builtins.count (" balance" ) == 0 , " " );
129
134
m_builtins[" balance" ] = [this ](FunctionCall const & _call) -> std::optional<bytes>
@@ -142,6 +147,31 @@ void SemanticTest::initializeBuiltins()
142
147
soltestAssert (_call.arguments .parameters .empty (), " No arguments expected." );
143
148
return toBigEndian (u256 (storageEmpty (m_contractAddress) ? 1 : 0 ));
144
149
};
150
+ m_hooks.emplace_back (
151
+ [](FunctionCall const & _call) -> std::vector<std::string>
152
+ {
153
+ if (_call.signature .find (" effectsTest" ) != string::npos)
154
+ return {_call.signature + " 0" };
155
+ return {};
156
+ }
157
+ );
158
+ m_hooks.emplace_back (
159
+ [](FunctionCall const & _call) -> std::vector<std::string>
160
+ {
161
+ if (_call.signature .find (" effectsTest" ) != string::npos)
162
+ return {_call.signature + " 1" , _call.signature + " 2" };
163
+ return {};
164
+ }
165
+ );
166
+ }
167
+
168
+ vector<string> SemanticTest::effectsOfCall (FunctionCall const & _call) const
169
+ {
170
+ vector<string> effects;
171
+ for (auto const & hook: m_hooks)
172
+ for (auto const & effect: hook (_call))
173
+ effects.emplace_back (effect);
174
+ return effects;
145
175
}
146
176
147
177
TestCase::TestResult SemanticTest::run (ostream& _stream, string const & _linePrefix, bool _formatted)
@@ -299,6 +329,8 @@ TestCase::TestResult SemanticTest::runTest(
299
329
test.setRawBytes (std::move (output));
300
330
test.setContractABI (m_compiler.contractABI (m_compiler.lastContractName (m_sources.mainSourceFile )));
301
331
}
332
+
333
+ success &= test.call ().effects == effectsOfCall (test.call ());
302
334
}
303
335
304
336
if (!m_testCaseWantsYulRun && _isYulRun)
@@ -361,7 +393,8 @@ TestCase::TestResult SemanticTest::runTest(
361
393
_linePrefix,
362
394
m_gasCostFailure ? TestFunctionCall::RenderMode::ExpectedValuesActualGas : TestFunctionCall::RenderMode::ActualValuesExpectedGas,
363
395
_formatted,
364
- /* _interactivePrint */ true
396
+ /* _interactivePrint */ true ,
397
+ effectsOfCall (test.call ())
365
398
) << endl;
366
399
_stream << errorReporter.format (_linePrefix, _formatted);
367
400
}
@@ -483,7 +516,8 @@ void SemanticTest::printUpdatedExpectations(ostream& _stream, string const&) con
483
516
_stream << test.format (
484
517
" " ,
485
518
m_gasCostFailure ? TestFunctionCall::RenderMode::ExpectedValuesActualGas : TestFunctionCall::RenderMode::ActualValuesExpectedGas,
486
- /* _highlight = */ false
519
+ /* _highlight = */ false ,
520
+ effectsOfCall (test.call ())
487
521
) << endl;
488
522
}
489
523
0 commit comments