Merge pull request #11287 from ethereum/isoltest-minor

Small refactorings for isoltest
This commit is contained in:
Harikrishnan Mulackal 2021-04-22 10:11:50 +02:00 committed by GitHub
commit 1eff128b6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -83,13 +83,18 @@ string TestFunctionCall::format(
stream << _linePrefix << newline << ws << m_call.signature;
if (m_call.value.value > u256(0))
{
if (m_call.value.unit == FunctionValueUnit::Ether)
switch (m_call.value.unit)
{
case FunctionValueUnit::Ether:
stream << comma << ws << (m_call.value.value / exp256(10, 18)) << ws << ether;
else if (m_call.value.unit == FunctionValueUnit::Wei)
break;
case FunctionValueUnit::Wei:
stream << comma << ws << m_call.value.value << ws << wei;
else
break;
default:
soltestAssert(false, "");
}
}
if (!m_call.arguments.rawBytes().empty())
{
string output = formatRawParameters(m_call.arguments.parameters, _linePrefix);
@ -360,6 +365,7 @@ void TestFunctionCall::reset()
{
m_rawBytes = bytes{};
m_failure = true;
m_contractABI = Json::Value{};
m_calledNonExistingFunction = false;
}

View File

@ -150,7 +150,7 @@ private:
bool m_failure = true;
/// JSON object which holds the contract ABI and that is used to set the output formatting
/// in the interactive update routine.
Json::Value m_contractABI;
Json::Value m_contractABI = Json::Value{};
/// Flags that the test failed because the called function is not known to exist on the contract.
bool m_calledNonExistingFunction = false;
};

View File

@ -151,7 +151,6 @@ bool TestTool::m_exitRequested = false;
TestTool::Result TestTool::process()
{
bool formatted{!m_options.noColor};
std::stringstream outputMessages;
try
{
@ -168,6 +167,8 @@ TestTool::Result TestTool::process()
m_options.enforceGasTestMinValue
});
if (m_test->shouldRun())
{
std::stringstream outputMessages;
switch (TestCase::TestResult result = m_test->run(outputMessages, " ", formatted))
{
case TestCase::TestResult::Success:
@ -183,6 +184,7 @@ TestTool::Result TestTool::process()
cout << endl << outputMessages.str() << endl;
return result == TestCase::TestResult::FatalError ? Result::Exception : Result::Failure;
}
}
else
{
AnsiColorized(cout, formatted, {BOLD, YELLOW}) << "NOT RUN" << endl;