Skip to content

Commit

Permalink
Support validating initcode containers in eofparse (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 authored Jun 25, 2024
1 parent b790bc7 commit 17ec114
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 17ec114

Please sign in to comment.