Skip to content

Commit

Permalink
Fix tests for the requirement of non-returning 0 section
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Jul 10, 2023
1 parent 7111f5c commit ae5d732
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 642 deletions.
23 changes: 14 additions & 9 deletions test/unittests/eof_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <evmone/eof.hpp>
#include <gtest/gtest.h>
#include <test/utils/bytecode.hpp>
#include <test/utils/utils.hpp>

using namespace evmone;
Expand Down Expand Up @@ -41,20 +42,24 @@ TEST(eof, read_valid_eof1_header)
for (int i = 0; i < 256; ++i)
section_size_1_256 += "0001";

std::string section_types_256;
for (int i = 0; i < 256; ++i)
section_types_256 += "00800000";

const TestCase test_cases[] = {
{"EF00 01 010004 0200010001 030000 00 00000000 00", 4, 0, {1}},
{"EF00 01 010004 0200010006 030000 00 00000002 600160005500", 4, 0, {6}},
{"EF00 01 010004 0200010001 030001 00 00000000 00 AA", 4, 1, {1}},
{"EF00 01 010004 0200010006 030004 00 00000002 600160005500 AABBCCDD", 4, 4, {6}},
{"EF00 01 01000C 020003000100020003 030000 00 000000000000000000000000 00 5B00 5B5B00", 12,
{"EF00 01 010004 0200010001 030000 00 00800000 00", 4, 0, {1}},
{"EF00 01 010004 0200010006 030000 00 00800002 600160005500", 4, 0, {6}},
{"EF00 01 010004 0200010001 030001 00 00800000 00 AA", 4, 1, {1}},
{"EF00 01 010004 0200010006 030004 00 00800002 600160005500 AABBCCDD", 4, 4, {6}},
{"EF00 01 01000C 020003000100020003 030000 00 008000000080000000800000 00 5B00 5B5B00", 12,
0, {1, 2, 3}},
{"EF00 01 01000C 020003000100020003 030004 00 000000000000000000000000 00 5B00 5B5B00 "
{"EF00 01 01000C 020003000100020003 030004 00 008000000080000000800000 00 5B00 5B5B00 "
"FFFFFFFF",
12, 4, {1, 2, 3}},
{"EF00 01 010004 0200010100 031000 00 00000000" + nops_255 + "00" + std::string(8192, 'F'),
{"EF00 01 010004 0200010100 031000 00 00800000 " + nops_255 + "00" + std::string(8192, 'F'),
4, 4096, {256}},
{"EF00 01 010400 020100" + section_size_1_256 + " 031000 00 " +
std::string(4 * 256 * 2, '0') + std::string(512, '0') + std::string(8192, 'F'),
{"EF00 01 010400 020100" + section_size_1_256 + " 031000 00 " + section_types_256 +
std::string(512, '0') + std::string(8192, 'F'),
4 * 256, 4096, std::vector<uint16_t>(256, 1)},
};

Expand Down
Loading

0 comments on commit ae5d732

Please sign in to comment.