Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix state test format benchmarking #1043

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion test/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@
std::vector<BenchmarkCase::Input> inputs;
inputs.reserve(state_test.multi_tx.inputs.size());
for (size_t i = 0; i < state_test.multi_tx.inputs.size(); ++i)
inputs.emplace_back(state_test.input_labels.at(i), state_test.multi_tx.inputs[i]);
{
const auto it = state_test.input_labels.find(i);
if (it != state_test.input_labels.end())
inputs.emplace_back(it->second, state_test.multi_tx.inputs[i]);

Check warning on line 56 in test/bench/bench.cpp

View check run for this annotation

Codecov / codecov/patch

test/bench/bench.cpp#L54-L56

Added lines #L54 - L56 were not covered by tests
else
inputs.emplace_back(std::to_string(i), state_test.multi_tx.inputs[i]);

Check warning on line 58 in test/bench/bench.cpp

View check run for this annotation

Codecov / codecov/patch

test/bench/bench.cpp#L58

Added line #L58 was not covered by tests
}

return inputs;
}

Expand Down
8 changes: 6 additions & 2 deletions test/bench/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0
#pragma once

#include "test/state/host.hpp"
#include "test/utils/utils.hpp"
#include <benchmark/benchmark.h>
#include <evmc/evmc.hpp>
Expand All @@ -17,7 +18,7 @@
{
extern std::map<std::string_view, evmc::VM> registered_vms;

constexpr auto default_revision = EVMC_ISTANBUL;
constexpr auto default_revision = EVMC_PRAGUE;
constexpr auto default_gas_limit = std::numeric_limits<int64_t>::max();


Expand Down Expand Up @@ -102,7 +103,10 @@
constexpr auto gas_limit = default_gas_limit;

const auto analysis = analyse_fn(rev, code);
evmc::MockedHost host;
state::State ss;
state::BlockInfo blockInfo = {.gas_limit = gas_limit};
state::Transaction tx = {.gas_limit = gas_limit};
state::Host host{rev, vm, ss, blockInfo, tx};

Check warning on line 109 in test/bench/helpers.hpp

View check run for this annotation

Codecov / codecov/patch

test/bench/helpers.hpp#L106-L109

Added lines #L106 - L109 were not covered by tests
ExecutionStateT exec_state;
evmc_message msg{};
msg.kind = EVMC_CALL;
Expand Down