Skip to content

Commit

Permalink
statetest: print time and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Jun 6, 2024
1 parent 97bbf26 commit a66479f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/statetest/statetest_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ void run_state_test(const StateTransitionTest& test, evmc::VM& vm, bool trace_su
const auto tx = test.multi_tx.get(expected.indexes);
auto state = test.pre_state;

const auto start_time = std::chrono::steady_clock::now();

const auto res = state::transition(state, test.block, tx, rev, vm, test.block.gas_limit,
state::BlockInfo::MAX_BLOB_GAS_PER_BLOCK);

const auto exec_duration = std::chrono::steady_clock::now() - start_time;

// Finalize block with reward 0.
state::finalize(state, rev, test.block.coinbase, 0, {}, {});

Expand All @@ -46,8 +50,22 @@ void run_state_test(const StateTransitionTest& test, evmc::VM& vm, bool trace_su
else
std::clog << R"("pass":false,"error":")" << r.status << '"';
std::clog << R"(,"gasUsed":"0x)" << std::hex << r.gas_used << R"(",)";

if (r.status == EVMC_SUCCESS)

Check warning on line 54 in test/statetest/statetest_runner.cpp

View check run for this annotation

Codecov / codecov/patch

test/statetest/statetest_runner.cpp#L54

Added line #L54 was not covered by tests
{
std::clog << "LOGS:\n";
for (const auto& log : r.logs)

Check warning on line 57 in test/statetest/statetest_runner.cpp

View check run for this annotation

Codecov / codecov/patch

test/statetest/statetest_runner.cpp#L56-L57

Added lines #L56 - L57 were not covered by tests
{
std::clog << log.addr << ": " << hex(log.data) << "\n";

Check warning on line 59 in test/statetest/statetest_runner.cpp

View check run for this annotation

Codecov / codecov/patch

test/statetest/statetest_runner.cpp#L59

Added line #L59 was not covered by tests
}
}
}
std::clog << R"("stateRoot":"0x)" << hex(state_root) << "\"}\n";

std::clog
<< "time: " << std::dec
<< std::chrono::duration_cast<std::chrono::microseconds>(exec_duration).count()
<< "us\n";

Check warning on line 68 in test/statetest/statetest_runner.cpp

View check run for this annotation

Codecov / codecov/patch

test/statetest/statetest_runner.cpp#L66-L68

Added lines #L66 - L68 were not covered by tests
}

if (expected.exception)
Expand Down

0 comments on commit a66479f

Please sign in to comment.