MCPcopy Create free account
hub / github.com/argotorg/solidity / formatGasExpectations

Method formatGasExpectations

test/libsolidity/util/TestFunctionCall.cpp:371–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371std::string TestFunctionCall::formatGasExpectations(
372 std::string const& _linePrefix,
373 bool _useActualCost,
374 bool _showDifference
375) const
376{
377 using ranges::views::keys;
378 using ranges::views::set_symmetric_difference;
379
380 soltestAssert(set_symmetric_difference(m_codeDepositGasCosts | keys, m_gasCostsExcludingCode | keys).empty());
381 soltestAssert(set_symmetric_difference(m_call.expectations.gasUsedForCodeDeposit | keys, m_call.expectations.gasUsedExcludingCode | keys).empty());
382
383 std::stringstream os;
384 for (auto const& [runType, gasUsedExcludingCode]: (_useActualCost ? m_gasCostsExcludingCode : m_call.expectations.gasUsedExcludingCode))
385 {
386 soltestAssert(runType != "");
387
388 u256 gasUsedForCodeDeposit = (_useActualCost ? m_codeDepositGasCosts : m_call.expectations.gasUsedForCodeDeposit).at(runType);
389
390 os << std::endl << _linePrefix << "// gas " << runType << ": " << gasUsedExcludingCode.str();
391 std::string gasDiff = formatGasDiff(
392 gasOrNullopt(m_gasCostsExcludingCode, runType),
393 gasOrNullopt(m_call.expectations.gasUsedExcludingCode, runType)
394 );
395 if (_showDifference && !gasDiff.empty() && _useActualCost)
396 os << " [" << gasDiff << "]";
397
398 if (gasUsedForCodeDeposit != 0)
399 {
400 os << std::endl << _linePrefix << "// gas " << runType << " code: " << gasUsedForCodeDeposit.str();
401 std::string codeGasDiff = formatGasDiff(
402 gasOrNullopt(m_codeDepositGasCosts, runType),
403 gasOrNullopt(m_call.expectations.gasUsedForCodeDeposit, runType)
404 );
405 if (_showDifference && !codeGasDiff.empty() && _useActualCost)
406 os << " [" << codeGasDiff << "]";
407 }
408 }
409 return os.str();
410}
411
412void TestFunctionCall::reset()
413{

Callers

nothing calls this directly

Calls 5

formatGasDiffFunction · 0.85
gasOrNulloptFunction · 0.85
atMethod · 0.80
strMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected