Skip to content

Commit

Permalink
Fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Jan 26, 2023
1 parent a4a3684 commit 58c3b2f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
14 changes: 5 additions & 9 deletions test/statetest/secret_sender_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ using namespace evmc;

evmc::address sender_address(const bytes32& secret_key)
{
static const std::map<bytes32, address> map =
{
{
0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8_bytes32,
0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b_address
}
};
static const std::map<bytes32, address> map = {
{0x45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8_bytes32,
0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b_address}};

assert(map.contains(secret_key)); // If it fails add new entry to the map.
assert(map.contains(secret_key)); // If it fails add new entry to the map.
return map.at(secret_key);
}

} // namespace evmone::test
} // namespace evmone::test
2 changes: 1 addition & 1 deletion test/statetest/secret_sender_map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ namespace evmone::test
{
evmc::address sender_address(const evmc::bytes32& secret_key);

} // namespace evmone::test
} // namespace evmone::test
2 changes: 1 addition & 1 deletion test/statetest/statetest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,6 @@ inline std::string hex(uint64_t v)

return str;
}
} // namespace evmone::test::utils
} // namespace utils

} // namespace evmone::test
4 changes: 2 additions & 2 deletions test/statetest/statetest_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Copyright 2022 The evmone Authors.
// SPDX-License-Identifier: Apache-2.0

#include "statetest.hpp"
#include "secret_sender_map.hpp"
#include "statetest.hpp"
#include <nlohmann/json.hpp>
#include <fstream>

Expand Down Expand Up @@ -212,7 +212,7 @@ static void from_json(const json::json& j, StateTransitionTest& o)
}
}

template<>
template <>
state::Transaction from_json<state::Transaction>(const json::json& j)
{
state::Transaction o;
Expand Down
22 changes: 13 additions & 9 deletions test/t8n/t8n.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "../state/mpt_hash.hpp"
#include "../state/rlp.hpp"
#include "../statetest/statetest.hpp"
#include <nlohmann/json.hpp>
#include <evmone/evmone.h>
#include <nlohmann/json.hpp>
#include <filesystem>
#include <fstream>
#include <iostream>
Expand Down Expand Up @@ -76,7 +76,7 @@ int main(int argc, const char* argv[])
state::BlockInfo block;
state::State pre_state;

try // FIXME: Remove and use non-excepting json::parse function
try // FIXME: Remove and use non-excepting json::parse function
{
if (!alloc_file.empty())
{
Expand All @@ -99,7 +99,7 @@ int main(int argc, const char* argv[])
std::vector<std::pair<std::string, state::Transaction>> hash_txs;

json::json j_result;
j_result["currentDifficulty"] = "0x20000";/* + current_difficulty;*/
j_result["currentDifficulty"] = "0x20000"; /* + current_difficulty;*/

if (!txs_file.empty())
{
Expand All @@ -118,7 +118,7 @@ int main(int argc, const char* argv[])
{
j_result["receipts"] = json::json::array();
j_result["rejected"] = json::json::array();
for (auto& j_tx: j_txs)
for (auto& j_tx : j_txs)
{
state::Transaction tx = test::from_json<state::Transaction>(j_tx);
auto const tx_logs = state::transition(state, block, tx, rev, vm);
Expand All @@ -127,9 +127,11 @@ int main(int argc, const char* argv[])
txs_logs.insert(txs_logs.begin(), (*tx_logs).begin(), (*tx_logs).end());
auto& j_receipt = j_result["receipts"][j_result["receipts"].size()];
j_receipt["transactionHash"] = j_tx["hash"];
j_receipt["blockHash"] = "0x0000000000000000000000000000000000000000000000000000000000000000";
j_receipt["blockHash"] =
"0x0000000000000000000000000000000000000000000000000000000000000000";
j_receipt["contractAddress"] = "0x0000000000000000000000000000000000000000";
j_receipt["gasUsed"] = "0xa868"; // FIXME: Get it from transaction execution.
j_receipt["gasUsed"] =
"0xa868"; // FIXME: Get it from transaction execution.
j_receipt["cumulativeGasUsed"] = j_receipt["gasUsed"];
j_receipt["logs"] = json::json::array(); // FIXME: Add to_json<state:Log>
j_receipt["logsBloom"] = "0x" + std::string(512, '0');
Expand All @@ -147,7 +149,8 @@ int main(int argc, const char* argv[])
}

j_result["logsBloom"] = "0x" + std::string(512, '0');
j_result["receiptsRoot"] = "0x0000000000000000000000000000000000000000000000000000000000000000";
j_result["receiptsRoot"] =
"0x0000000000000000000000000000000000000000000000000000000000000000";
j_result["txRoot"] = "0x0000000000000000000000000000000000000000000000000000000000000000";

std::ofstream{output_dir / output_result_file} << j_result;
Expand All @@ -157,14 +160,15 @@ int main(int argc, const char* argv[])
for (const auto& [addr, acc] : state.get_accounts())
{
j_alloc["0x" + hex(addr)]["nonce"] = "0x" + test::utils::hex(acc.nonce);
for (const auto& [key, val]: acc.storage)
for (const auto& [key, val] : acc.storage)
j_alloc["0x" + hex(addr)]["storage"]["0x" + hex(key)] = "0x" + hex(val.current);
}

std::ofstream{output_dir / output_alloc_file} << j_alloc;
std::cerr << "---\nALLOC:\n" << std::setw(2) << j_alloc << "\n";
}
catch (...) {}
catch (...)
{}

return 0;
}

0 comments on commit 58c3b2f

Please sign in to comment.