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

fix unittests #576

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion silkrpc/commands/engine_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ boost::asio::awaitable<void> EngineRpcApi::handle_engine_forkchoice_updated_v1(c
#ifndef BUILD_COVERAGE
try {
#endif
auto zero_hash = 0_bytes32;
auto zero_hash = 00_bytes32;
const ForkchoiceState forkchoice_state = params[0].get<ForkchoiceState>();

if (forkchoice_state.safe_block_hash == zero_hash) {
Expand Down
16 changes: 8 additions & 8 deletions silkrpc/core/rawdb/util_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ namespace silkrpc {
using evmc::literals::operator""_address, evmc::literals::operator""_bytes32;

TEST_CASE("all-zero composite key", "[silkrpc][core][rawdb][util]") {
auto zero_address = 0_address;
auto zero_hash = 0_bytes32;
auto zero_address = 00_address;
auto zero_hash = 00_bytes32;

const auto ckey{composite_storage_key(zero_address, 0, zero_hash.bytes)};
CHECK(ckey == silkworm::Bytes(60, '\0'));
}

TEST_CASE("non-zero address composite key", "[silkrpc][core][rawdb][util]") {
constexpr auto address = 0x79a4d418f7887dd4d5123a41b6c8c186686ae8cb_address;
auto zero_hash = 0_bytes32;
auto zero_hash = 00_bytes32;

const auto ckey{composite_storage_key(address, 0, zero_hash.bytes)};
CHECK(ckey == silkworm::from_hex(
Expand All @@ -45,8 +45,8 @@ TEST_CASE("non-zero address composite key", "[silkrpc][core][rawdb][util]") {
}

TEST_CASE("non-zero incarnation composite key", "[silkrpc][core][rawdb][util]") {
auto zero_address = 0_address;
auto zero_hash = 0_bytes32;
auto zero_address = 00_address;
auto zero_hash = 00_bytes32;

const auto ckey{composite_storage_key(zero_address, 37, zero_hash.bytes)};
CHECK(ckey == silkworm::from_hex(
Expand All @@ -57,7 +57,7 @@ TEST_CASE("non-zero incarnation composite key", "[silkrpc][core][rawdb][util]")
}

TEST_CASE("non-zero hash composite key", "[silkrpc][core][rawdb][util]") {
auto zero_address = 0_address;
auto zero_address = 00_address;
constexpr auto hash = 0xb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6_bytes32;

const auto ckey{composite_storage_key(zero_address, 0, hash.bytes)};
Expand All @@ -81,8 +81,8 @@ TEST_CASE("non-zero composite key", "[silkrpc][core][rawdb][util]") {
}

TEST_CASE("max incarnation composite key", "[silkrpc][core][rawdb][util]") {
auto zero_address = 0_address;
auto zero_hash = 0_bytes32;
auto zero_address = 00_address;
auto zero_hash = 00_bytes32;

const auto ckey{composite_storage_key(zero_address, std::numeric_limits<uint64_t>::max(), zero_hash.bytes)};
CHECK(ckey == silkworm::from_hex(
Expand Down
6 changes: 3 additions & 3 deletions silkrpc/core/state_reader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ TEST_CASE_METHOD(StateReaderTest, "StateReader::read_storage") {
EXPECT_CALL(database_reader_, get(db::table::kStorageHistory, _)).WillOnce(InvokeWithoutArgs(
[]() -> boost::asio::awaitable<KeyValue> { co_return KeyValue{}; }
));
// 2. DatabaseReader::get_one call on kPlainState returns the storage location value
EXPECT_CALL(database_reader_, get_one(db::table::kPlainState, _)).WillOnce(InvokeWithoutArgs(
[]() -> boost::asio::awaitable<silkworm::Bytes> { co_return kStorageLocation; }
// 2. DatabaseReader::get_both_range call on kPlainState returns the storage location value
EXPECT_CALL(database_reader_, get_both_range(db::table::kPlainState, _, _)).WillOnce(InvokeWithoutArgs(
[]() -> boost::asio::awaitable<std::optional<silkworm::Bytes>> { co_return kStorageLocation; }
));

// Execute the test: calling read_storage should return expected storage location
Expand Down
20 changes: 10 additions & 10 deletions silkrpc/json/types_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ TEST_CASE("serialize empty block header", "[silkrpc][to_json]") {
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(00000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty":"0x",
"difficulty":"0x0",
"nonce":"0x0000000000000000",
"number":"0x0",
"gasLimit":"0x0",
Expand Down Expand Up @@ -192,7 +192,7 @@ TEST_CASE("serialize block header", "[silkrpc][to_json]") {
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(00000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty":"0x",
"difficulty":"0x0",
"number":"0x5",
"gasLimit":"0xf4240",
"gasUsed":"0xf4240",
Expand Down Expand Up @@ -237,7 +237,7 @@ TEST_CASE("serialize block header with baseFeePerGas", "[silkrpc][to_json]") {
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(00000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty":"0x",
"difficulty":"0x0",
"number":"0x5",
"gasLimit":"0xf4240",
"gasUsed":"0xf4240",
Expand Down Expand Up @@ -329,7 +329,7 @@ TEST_CASE("serialize block with baseFeePerGas", "[silkrpc][to_json]") {
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(00000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty":"0x",
"difficulty":"0x0",
"number":"0x5",
"hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit":"0xf4240",
Expand All @@ -340,7 +340,7 @@ TEST_CASE("serialize block with baseFeePerGas", "[silkrpc][to_json]") {
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000001",
"nonce":"0x00000000000000ff",
"baseFeePerGas":"0x244428",
"totalDifficulty":"0x",
"totalDifficulty":"0x0",
"transactions":[],
"uncles":[]
})"_json);
Expand All @@ -363,7 +363,7 @@ TEST_CASE("serialize empty block", "[silkrpc][to_json]") {
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(000000000000000000000000000000000000000000000000000000000000000000000000)"
R"(00000000000000000000000000000000000000000000000000000000000000000000000000000000",
"difficulty":"0x",
"difficulty":"0x0",
"nonce":"0x0000000000000000",
"number":"0x0",
"gasLimit":"0x0",
Expand All @@ -373,7 +373,7 @@ TEST_CASE("serialize empty block", "[silkrpc][to_json]") {
"mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"hash":"0x0000000000000000000000000000000000000000000000000000000000000000",
"size":"0x1f5",
"totalDifficulty":"0x",
"totalDifficulty":"0x0",
"transactions":[],
"uncles":[]
})"_json);
Expand Down Expand Up @@ -426,7 +426,7 @@ TEST_CASE("serialize EIP-2718 block", "[silkrpc][to_json]") {
"size":"0x31c",
"stateRoot":"0xef1552a40b7165c3cd773806b9e0c165b75356e0314bf0706f279c729f51e017",
"timestamp":"0x5506eb07",
"totalDifficulty":"0x",
"totalDifficulty":"0x0",
"transactions":[
"0x77b19baa4de67e45a7b26e4a220bccdbb6731885aa9927064e239ca232023215",
"0x554af720acf477830f996f1bc5d11e54c38aa40042aeac6f66cb66f9084a959d"
Expand Down Expand Up @@ -607,7 +607,7 @@ TEST_CASE("serialize block body with ommers", "[silkrpc][to_json]") {

nlohmann::json rpc_block_json = rpc_block;
CHECK(rpc_block_json == R"({
"difficulty":"0x",
"difficulty":"0x0",
"extraData":"0x",
"gasLimit":"0x0",
"gasUsed":"0x0",
Expand All @@ -629,7 +629,7 @@ TEST_CASE("serialize block body with ommers", "[silkrpc][to_json]") {
"size":"0x40c",
"stateRoot":"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp":"0x0",
"totalDifficulty":"0x",
"totalDifficulty":"0x0",
"transactions":[],
"transactionsRoot":"0x0000000000000000000000000000000000000000000000000000000000000000",
"uncles":["0x5cd50096dbb856a6d1befa6de8f9c20decb299f375154427d90761dc0b101109"]
Expand Down