-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
569 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// evmone: Fast Ethereum Virtual Machine implementation | ||
// Copyright 2024 The evmone Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "eof_validation.hpp" | ||
|
||
namespace evmone::test | ||
{ | ||
void eof_validation::TearDown() | ||
{ | ||
for (const auto& test_case : test_cases) | ||
{ | ||
EXPECT_EQ(evmone::validate_eof(rev, test_case.container), test_case.error) | ||
<< test_case.name << "\n" | ||
<< hex(test_case.container); | ||
} | ||
} | ||
} // namespace evmone::test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// evmone: Fast Ethereum Virtual Machine implementation | ||
// Copyright 2024 The evmone Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#pragma once | ||
|
||
#include <evmc/evmc.hpp> | ||
#include <evmone/eof.hpp> | ||
#include <evmone/evmone.h> | ||
#include <gtest/gtest.h> | ||
#include <test/utils/bytecode.hpp> | ||
|
||
namespace evmone::test | ||
{ | ||
using evmc::bytes; | ||
|
||
/// Fixture for defining test cases for EOF validation. | ||
/// | ||
/// Each test contains multiple cases, which are validated during test teardown. | ||
class eof_validation : public testing::Test | ||
{ | ||
protected: | ||
/// EOF validation test case. | ||
struct TestCase | ||
{ | ||
/// Container to be validated. | ||
bytes container; | ||
/// Expected error if container is expected to be invalid, | ||
/// or EOFValidationError::success if it is expected to be valid. | ||
EOFValidationError error = EOFValidationError::success; | ||
/// (Optional) Test case description. | ||
std::string name; | ||
}; | ||
|
||
evmc_revision rev = EVMC_PRAGUE; | ||
std::vector<TestCase> test_cases; | ||
|
||
/// Adds the case to test cases. | ||
/// | ||
/// Can be called as add_test_case(string_view hex, error, name) | ||
/// or add_test_case(bytes_view cont, error, name). | ||
void add_test_case(bytecode container, EOFValidationError error, std::string name = {}) | ||
{ | ||
test_cases.push_back({std::move(container), error, std::move(name)}); | ||
} | ||
|
||
/// The test runner. | ||
void TearDown() override; | ||
}; | ||
|
||
} // namespace evmone::test |
Oops, something went wrong.