-
Notifications
You must be signed in to change notification settings - Fork 294
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
2 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// evmone: Fast Ethereum Virtual Machine implementation | ||
// Copyright 2023 The evmone Authors. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <gtest/gtest.h> | ||
#include <test/statetest/statetest.hpp> | ||
|
||
using namespace evmone; | ||
|
||
TEST(statetest_loader, block_info) | ||
{ | ||
constexpr std::string_view input = R"({ | ||
"currentCoinbase": "0x1111111111111111111111111111111111111111", | ||
"currentDifficulty": "0x0", | ||
"currentGasLimit": "0x0", | ||
"currentNumber": "0", | ||
"currentTimestamp": "0", | ||
"currentBaseFee": "7", | ||
"currentRandom": "0x00", | ||
"withdrawals": [] | ||
})"; | ||
|
||
const auto bi = test::from_json<state::BlockInfo>(json::json::parse(input)); | ||
EXPECT_EQ(bi.coinbase, 0x1111111111111111111111111111111111111111_address); | ||
EXPECT_EQ( | ||
bi.prev_randao, 0x0000000000000000000000000000000000000000000000000000000000000000_bytes32); | ||
EXPECT_EQ(bi.gas_limit, 0x0); | ||
EXPECT_EQ(bi.base_fee, 7); | ||
EXPECT_EQ(bi.timestamp, 0); | ||
EXPECT_EQ(bi.number, 0); | ||
} | ||
|
||
// TODO: Enable this test when this case will be properly handled. | ||
TEST(DISABLED_statetest_loader, block_info_0_random) | ||
{ | ||
constexpr std::string_view input = R"({ | ||
"currentCoinbase": "0x1111111111111111111111111111111111111111", | ||
"currentDifficulty": "0x0", | ||
"currentGasLimit": "0x0", | ||
"currentNumber": "0", | ||
"currentTimestamp": "0", | ||
"currentBaseFee": "7", | ||
"currentRandom": "0", | ||
"withdrawals": [] | ||
})"; | ||
|
||
const auto bi = test::from_json<state::BlockInfo>(json::json::parse(input)); | ||
EXPECT_EQ(bi.coinbase, 0x1111111111111111111111111111111111111111_address); | ||
EXPECT_EQ( | ||
bi.prev_randao, 0x0000000000000000000000000000000000000000000000000000000000000000_bytes32); | ||
EXPECT_EQ(bi.gas_limit, 0x0); | ||
EXPECT_EQ(bi.base_fee, 7); | ||
EXPECT_EQ(bi.timestamp, 0); | ||
EXPECT_EQ(bi.number, 0); | ||
} |