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

Support validating initcode containers in eofparse #934

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
13 changes: 11 additions & 2 deletions test/eofparse/eofparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright 2023 The evmone Authors.
// SPDX-License-Identifier: Apache-2.0

#include <CLI/CLI.hpp>
#include <evmc/evmc.hpp>
#include <evmone/eof.hpp>
#include <iostream>
Expand Down Expand Up @@ -35,10 +36,18 @@ std::optional<evmc::bytes> from_hex_skip_nonalnum(InputIterator begin, InputIter

} // namespace

int main()
int main(int argc, char* argv[])
{
try
{
CLI::App app{"evmone eofparse tool"};
const auto& initcode_flag =
*app.add_flag("--initcode", "Validate code as initcode containers");

app.parse(argc, argv);
const auto container_kind =
initcode_flag ? evmone::ContainerKind::initcode : evmone::ContainerKind::runtime;

int num_errors = 0;
for (std::string line; std::getline(std::cin, line);)
{
Expand All @@ -54,7 +63,7 @@ int main()
}

const auto& eof = *o;
const auto err = evmone::validate_eof(EVMC_PRAGUE, evmone::ContainerKind::runtime, eof);
const auto err = evmone::validate_eof(EVMC_PRAGUE, container_kind, eof);
if (err != evmone::EOFValidationError::success)
{
std::cout << "err: " << evmone::get_error_message(err) << "\n";
Expand Down