Merge pull request #9125

0c545f6 epee/test: remove levin_protocol_handler and core_proxy tests (jeffro256)
This commit is contained in:
luigi1111 2024-02-24 09:59:50 -05:00
commit c12ee59ebd
No known key found for this signature in database
GPG Key ID: F4ACA0183641E010
6 changed files with 0 additions and 659 deletions

View File

@ -1,193 +0,0 @@
// Copyright (c) 2006-2013, Andrey N. Sabelnikov, www.sabelnikov.net
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of the Andrey N. Sabelnikov nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef _LEVIN_PROTOCOL_HANDLER_H_
#define _LEVIN_PROTOCOL_HANDLER_H_
#include <boost/uuid/uuid_generators.hpp>
#include "levin_base.h"
#include "int-util.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
namespace epee
{
namespace levin
{
template<class t_connection_context = net_utils::connection_context_base>
struct protocl_handler_config
{
levin_commands_handler<t_connection_context>* m_pcommands_handler;
void (*m_pcommands_handler_destroy)(levin_commands_handler<t_connection_context>*);
~protocl_handler_config() { if (m_pcommands_handler && m_pcommands_handler_destroy) (*m_pcommands_handler_destroy)(m_pcommands_handler); }
};
template<class t_connection_context = net_utils::connection_context_base>
class protocol_handler
{
public:
typedef t_connection_context connection_context;
typedef protocl_handler_config<t_connection_context> config_type;
protocol_handler(net_utils::i_service_endpoint* psnd_hndlr, config_type& config, t_connection_context& conn_context);
virtual ~protocol_handler(){}
virtual bool handle_recv(const void* ptr, size_t cb);
bool after_init_connection(){return true;}
private:
enum connection_data_state
{
conn_state_reading_head,
conn_state_reading_body
};
config_type& m_config;
t_connection_context& m_conn_context;
net_utils::i_service_endpoint* m_psnd_hndlr;
std::string m_cach_in_buffer;
connection_data_state m_state;
bucket_head m_current_head;
};
template<class t_connection_context>
protocol_handler<t_connection_context>::protocol_handler(net_utils::i_service_endpoint* psnd_hndlr, config_type& config, t_connection_context& conn_context):
m_config(config),
m_conn_context(conn_context),
m_psnd_hndlr(psnd_hndlr),
m_state(conn_state_reading_head),
m_current_head(bucket_head())
{}
template<class t_connection_context>
bool protocol_handler<t_connection_context>::handle_recv(const void* ptr, size_t cb)
{
if(!m_config.m_pcommands_handler)
{
LOG_ERROR_CC(m_conn_context, "Command handler not set!");
return false;
}
m_cach_in_buffer.append((const char*)ptr, cb);
bool is_continue = true;
while(is_continue)
{
switch(m_state)
{
case conn_state_reading_head:
if(m_cach_in_buffer.size() < sizeof(bucket_head))
{
if(m_cach_in_buffer.size() >= sizeof(uint64_t) && *((uint64_t*)m_cach_in_buffer.data()) != SWAP64LE(LEVIN_SIGNATURE))
{
LOG_ERROR_CC(m_conn_context, "Signature mismatch on accepted connection");
return false;
}
is_continue = false;
break;
}
{
#if BYTE_ORDER == LITTLE_ENDIAN
bucket_head &phead = *(bucket_head*)m_cach_in_buffer.data();
#else
bucket_head phead = *(bucket_head*)m_cach_in_buffer.data();
phead.m_signature = SWAP64LE(phead.m_signature);
phead.m_cb = SWAP64LE(phead.m_cb);
phead.m_command = SWAP32LE(phead.m_command);
phead.m_return_code = SWAP32LE(phead.m_return_code);
phead.m_reservedA = SWAP32LE(phead.m_reservedA);
phead.m_reservedB = SWAP32LE(phead.m_reservedB);
#endif
if(LEVIN_SIGNATURE != phead.m_signature)
{
LOG_ERROR_CC(m_conn_context, "Signature mismatch on accepted connection");
return false;
}
m_current_head = phead;
}
m_cach_in_buffer.erase(0, sizeof(bucket_head));
m_state = conn_state_reading_body;
break;
case conn_state_reading_body:
if(m_cach_in_buffer.size() < m_current_head.m_cb)
{
is_continue = false;
break;
}
{
std::string buff_to_invoke;
if(m_cach_in_buffer.size() == m_current_head.m_cb)
buff_to_invoke.swap(m_cach_in_buffer);
else
{
buff_to_invoke.assign(m_cach_in_buffer, 0, (std::string::size_type)m_current_head.m_cb);
m_cach_in_buffer.erase(0, (std::string::size_type)m_current_head.m_cb);
}
if(m_current_head.m_have_to_return_data)
{
std::string return_buff;
m_current_head.m_return_code = m_config.m_pcommands_handler->invoke(m_current_head.m_command, buff_to_invoke, return_buff, m_conn_context);
m_current_head.m_cb = return_buff.size();
m_current_head.m_have_to_return_data = 0;
return_buff.insert(0, (const char*)&m_current_head, sizeof(m_current_head));
if(!m_psnd_hndlr->do_send(byte_slice{std::move(return_buff)}))
return false;
}
else
m_config.m_pcommands_handler->notify(m_current_head.m_command, buff_to_invoke, m_conn_context);
}
m_state = conn_state_reading_head;
break;
default:
LOG_ERROR_CC(m_conn_context, "Undefined state in levin_server_impl::connection_handler, m_state=" << m_state);
return false;
}
}
return true;
}
}
}
#endif //_LEVIN_PROTOCOL_HANDLER_H_

View File

@ -48,7 +48,6 @@
#include "cryptonote_protocol/levin_notify.h" #include "cryptonote_protocol/levin_notify.h"
#include "warnings.h" #include "warnings.h"
#include "net/abstract_tcp_server2.h" #include "net/abstract_tcp_server2.h"
#include "net/levin_protocol_handler.h"
#include "net/levin_protocol_handler_async.h" #include "net/levin_protocol_handler_async.h"
#include "p2p_protocol_defs.h" #include "p2p_protocol_defs.h"
#include "storages/levin_abstract_invoke2.h" #include "storages/levin_abstract_invoke2.h"

View File

@ -83,7 +83,6 @@ else ()
add_subdirectory(crypto) add_subdirectory(crypto)
add_subdirectory(functional_tests) add_subdirectory(functional_tests)
add_subdirectory(performance_tests) add_subdirectory(performance_tests)
add_subdirectory(core_proxy)
add_subdirectory(unit_tests) add_subdirectory(unit_tests)
add_subdirectory(difficulty) add_subdirectory(difficulty)
add_subdirectory(block_weight) add_subdirectory(block_weight)
@ -159,7 +158,6 @@ set(enabled_tests
block_weight block_weight
hash hash
performance_tests performance_tests
core_proxy
fuzz fuzz
unit_tests) unit_tests)

View File

@ -1,49 +0,0 @@
# Copyright (c) 2014-2023, The Monero Project
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
# THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
set(core_proxy_sources
core_proxy.cpp)
set(core_proxy_headers
core_proxy.h)
monero_add_minimal_executable(core_proxy
${core_proxy_sources}
${core_proxy_headers})
target_link_libraries(core_proxy
PRIVATE
cryptonote_core
cryptonote_protocol
p2p
version
epee
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
set_property(TARGET core_proxy
PROPERTY
FOLDER "tests")

View File

@ -1,295 +0,0 @@
// Copyright (c) 2014-2023, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
// node.cpp : Defines the entry point for the console application.
//
#include "include_base_utils.h"
#include "version.h"
#include <iostream>
#include <sstream>
#include <boost/program_options.hpp>
#include "common/command_line.h"
#include "console_handler.h"
#include "p2p/net_node.h"
#include "p2p/net_node.inl"
//#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.inl"
#include "core_proxy.h"
#if defined(WIN32)
#include <crtdbg.h>
#endif
namespace po = boost::program_options;
using namespace std;
using namespace epee;
using namespace cryptonote;
using namespace crypto;
BOOST_CLASS_VERSION(nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> >, 1);
int main(int argc, char* argv[])
{
#ifdef WIN32
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
TRY_ENTRY();
tools::on_startup();
string_tools::set_module_name_and_folder(argv[0]);
//set up logging options
mlog_configure(mlog_get_default_log_path("core_proxy.log"), true);
mlog_set_log_level(2);
po::options_description desc("Allowed options");
command_line::add_arg(desc, cryptonote::arg_data_dir);
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> >::init_options(desc);
po::variables_map vm;
bool r = command_line::handle_error_helper(desc, [&]()
{
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
return true;
});
if (!r)
return 1;
MGINFO("Module folder: " << argv[0]);
MGINFO("Node starting ...");
//create objects and link them
tests::proxy_core pr_core;
cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> cprotocol(pr_core, NULL);
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> > p2psrv {
cprotocol
};
cprotocol.set_p2p_endpoint(&p2psrv);
//pr_core.set_cryptonote_protocol(&cprotocol);
//daemon_cmmands_handler dch(p2psrv);
//initialize objects
MGINFO("Initializing p2p server...");
bool res = p2psrv.init(vm);
CHECK_AND_ASSERT_MES(res, 1, "Failed to initialize p2p server.");
MGINFO("P2p server initialized OK");
MGINFO("Initializing cryptonote protocol...");
res = cprotocol.init(vm);
CHECK_AND_ASSERT_MES(res, 1, "Failed to initialize cryptonote protocol.");
MGINFO("Cryptonote protocol initialized OK");
//initialize core here
MGINFO("Initializing proxy core...");
res = pr_core.init(vm);
CHECK_AND_ASSERT_MES(res, 1, "Failed to initialize core");
MGINFO("Core initialized OK");
MGINFO("Starting p2p net loop...");
p2psrv.run();
MGINFO("p2p net loop stopped");
//deinitialize components
MGINFO("Deinitializing core...");
pr_core.deinit();
MGINFO("Deinitializing cryptonote_protocol...");
cprotocol.deinit();
MGINFO("Deinitializing p2p...");
p2psrv.deinit();
//pr_core.set_cryptonote_protocol(NULL);
cprotocol.set_p2p_endpoint(NULL);
MGINFO("Node stopped.");
return 0;
CATCH_ENTRY_L0("main", 1);
}
/*
string tx2str(const cryptonote::transaction& tx, const cryptonote::hash256& tx_hash, const cryptonote::hash256& tx_prefix_hash, const cryptonote::blobdata& blob) {
stringstream ss;
ss << "{" << endl;
ss << "\tversion:" << tx.version << endl;
ss << "\tunlock_time:" << tx.unlock_time << endl;
ss << "\t"
return ss.str();
}*/
bool tests::proxy_core::handle_incoming_tx(const cryptonote::tx_blob_entry& tx_blob, cryptonote::tx_verification_context& tvc, cryptonote::relay_method tx_relay, bool relayed) {
if (tx_relay != cryptonote::relay_method::block)
return true;
crypto::hash tx_hash = null_hash;
crypto::hash tx_prefix_hash = null_hash;
transaction tx;
if (tx_blob.prunable_hash != crypto::null_hash)
{
cerr << "WRONG TRANSACTION, pruned blob rejected" << endl;
return false;
}
if (!parse_and_validate_tx_from_blob(tx_blob.blob, tx, tx_hash, tx_prefix_hash)) {
cerr << "WRONG TRANSACTION BLOB, Failed to parse, rejected" << endl;
return false;
}
cout << "TX " << endl << endl;
cout << tx_hash << endl;
cout << tx_prefix_hash << endl;
cout << tx_blob.blob.size() << endl;
//cout << string_tools::buff_to_hex_nodelimer(tx_blob) << endl << endl;
cout << obj_to_json_str(tx) << endl;
cout << endl << "ENDTX" << endl;
return true;
}
bool tests::proxy_core::handle_incoming_txs(const std::vector<tx_blob_entry>& tx_blobs, std::vector<tx_verification_context>& tvc, cryptonote::relay_method tx_relay, bool relayed)
{
tvc.resize(tx_blobs.size());
size_t i = 0;
for (const auto &tx_blob: tx_blobs)
{
if (!handle_incoming_tx(tx_blob, tvc[i], tx_relay, relayed))
return false;
++i;
}
return true;
}
bool tests::proxy_core::handle_incoming_block(const cryptonote::blobdata& block_blob, const cryptonote::block *block_, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate) {
block b = AUTO_VAL_INIT(b);
if(!parse_and_validate_block_from_blob(block_blob, b)) {
cerr << "Failed to parse and validate new block" << endl;
return false;
}
crypto::hash h;
crypto::hash lh;
cout << "BLOCK" << endl << endl;
cout << (h = get_block_hash(b)) << endl;
cout << (lh = get_block_longhash(NULL, b, 0, 0)) << endl;
cout << get_transaction_hash(b.miner_tx) << endl;
cout << ::get_object_blobsize(b.miner_tx) << endl;
//cout << string_tools::buff_to_hex_nodelimer(block_blob) << endl;
cout << obj_to_json_str(b) << endl;
cout << endl << "ENDBLOCK" << endl << endl;
if (!add_block(h, lh, b, block_blob))
return false;
return true;
}
bool tests::proxy_core::get_short_chain_history(std::list<crypto::hash>& ids) {
build_short_history(ids, m_lastblk);
return true;
}
void tests::proxy_core::get_blockchain_top(uint64_t& height, crypto::hash& top_id) {
height = 0;
top_id = get_block_hash(m_genesis);
}
bool tests::proxy_core::init(const boost::program_options::variables_map& /*vm*/) {
generate_genesis_block(m_genesis, config::GENESIS_TX, config::GENESIS_NONCE);
crypto::hash h = get_block_hash(m_genesis);
add_block(h, get_block_longhash(NULL, m_genesis, 0, 0), m_genesis, block_to_blob(m_genesis));
return true;
}
bool tests::proxy_core::have_block_unlocked(const crypto::hash& id, int *where) {
if (m_hash2blkidx.end() == m_hash2blkidx.find(id))
return false;
if (where) *where = HAVE_BLOCK_MAIN_CHAIN;
return true;
}
bool tests::proxy_core::have_block(const crypto::hash& id, int *where) {
return have_block_unlocked(id, where);
}
void tests::proxy_core::build_short_history(std::list<crypto::hash> &m_history, const crypto::hash &m_start) {
m_history.push_front(get_block_hash(m_genesis));
/*std::unordered_map<crypto::hash, tests::block_index>::const_iterator cit = m_hash2blkidx.find(m_lastblk);
do {
m_history.push_front(cit->first);
size_t n = 1 << m_history.size();
while (m_hash2blkidx.end() != cit && crypto::null_hash != cit->second.blk.prev_id && n > 0) {
n--;
cit = m_hash2blkidx.find(cit->second.blk.prev_id);
}
} while (m_hash2blkidx.end() != cit && get_block_hash(cit->second.blk) != cit->first);*/
}
bool tests::proxy_core::add_block(const crypto::hash &_id, const crypto::hash &_longhash, const cryptonote::block &_blk, const cryptonote::blobdata &_blob) {
size_t height = 0;
if (crypto::null_hash != _blk.prev_id) {
std::unordered_map<crypto::hash, tests::block_index>::const_iterator cit = m_hash2blkidx.find(_blk.prev_id);
if (m_hash2blkidx.end() == cit) {
cerr << "ERROR: can't find previous block with id \"" << _blk.prev_id << "\"" << endl;
return false;
}
height = cit->second.height + 1;
}
m_known_block_list.push_back(_id);
block_index bi(height, _id, _longhash, _blk, _blob, txes);
m_hash2blkidx.insert(std::make_pair(_id, bi));
txes.clear();
m_lastblk = _id;
return true;
}

View File

@ -1,119 +0,0 @@
// Copyright (c) 2014-2023, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once
#include <boost/program_options/variables_map.hpp>
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/verification_context.h"
#include "cryptonote_core/i_core_events.h"
#include <unordered_map>
namespace tests
{
struct block_index {
size_t height;
crypto::hash id;
crypto::hash longhash;
cryptonote::block blk;
cryptonote::blobdata blob;
std::list<cryptonote::transaction> txes;
block_index() : height(0), id(crypto::null_hash), longhash(crypto::null_hash) { }
block_index(size_t _height, const crypto::hash &_id, const crypto::hash &_longhash, const cryptonote::block &_blk, const cryptonote::blobdata &_blob, const std::list<cryptonote::transaction> &_txes)
: height(_height), id(_id), longhash(_longhash), blk(_blk), blob(_blob), txes(_txes) { }
};
class proxy_core : public cryptonote::i_core_events
{
cryptonote::block m_genesis;
std::list<crypto::hash> m_known_block_list;
std::unordered_map<crypto::hash, block_index> m_hash2blkidx;
crypto::hash m_lastblk;
std::list<cryptonote::transaction> txes;
bool add_block(const crypto::hash &_id, const crypto::hash &_longhash, const cryptonote::block &_blk, const cryptonote::blobdata &_blob);
void build_short_history(std::list<crypto::hash> &m_history, const crypto::hash &m_start);
public:
virtual bool is_synchronized() const final { return true; }
void on_synchronized(){}
void safesyncmode(const bool){}
virtual uint64_t get_current_blockchain_height() const final {return 1;}
void set_target_blockchain_height(uint64_t) {}
bool init(const boost::program_options::variables_map& vm);
bool deinit(){return true;}
bool get_short_chain_history(std::list<crypto::hash>& ids);
bool have_block(const crypto::hash& id, int *where = NULL);
bool have_block_unlocked(const crypto::hash& id, int *where = NULL);
void get_blockchain_top(uint64_t& height, crypto::hash& top_id);
bool handle_incoming_tx(const cryptonote::tx_blob_entry& tx_blob, cryptonote::tx_verification_context& tvc, cryptonote::relay_method tx_relay, bool relayed);
bool handle_incoming_txs(const std::vector<cryptonote::tx_blob_entry>& tx_blobs, std::vector<cryptonote::tx_verification_context>& tvc, cryptonote::relay_method tx_relay, bool relayed);
bool handle_incoming_block(const cryptonote::blobdata& block_blob, const cryptonote::block *block, cryptonote::block_verification_context& bvc, bool update_miner_blocktemplate = true);
void pause_mine(){}
void resume_mine(){}
bool on_idle(){return true;}
bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, cryptonote::NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp){return true;}
bool handle_get_objects(cryptonote::NOTIFY_REQUEST_GET_OBJECTS::request& arg, cryptonote::NOTIFY_RESPONSE_GET_OBJECTS::request& rsp, cryptonote::cryptonote_connection_context& context){return true;}
cryptonote::Blockchain &get_blockchain_storage() { throw std::runtime_error("Called invalid member function: please never call get_blockchain_storage on the TESTING class proxy_core."); }
bool get_test_drop_download() {return true;}
bool get_test_drop_download_height() {return true;}
bool prepare_handle_incoming_blocks(const std::vector<cryptonote::block_complete_entry> &blocks_entry, std::vector<cryptonote::block> &blocks) { return true; }
bool cleanup_handle_incoming_blocks(bool force_sync = false) { return true; }
bool update_checkpoints(const bool skip_dns = false) { return true; }
uint64_t get_target_blockchain_height() const { return 1; }
size_t get_block_sync_size(uint64_t height) const { return BLOCKS_SYNCHRONIZING_DEFAULT_COUNT; }
virtual void on_transactions_relayed(epee::span<const cryptonote::blobdata> tx_blobs, cryptonote::relay_method tx_relay) {}
cryptonote::network_type get_nettype() const { return cryptonote::MAINNET; }
bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx_blob, cryptonote::relay_category tx_category) const { return false; }
bool pool_has_tx(const crypto::hash &txid) const { return false; }
bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata, cryptonote::block>>& blocks, std::vector<cryptonote::blobdata>& txs) const { return false; }
bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::transaction>& txs, std::vector<crypto::hash>& missed_txs) const { return false; }
bool get_block_by_hash(const crypto::hash &h, cryptonote::block &blk, bool *orphan = NULL) const { return false; }
uint8_t get_ideal_hard_fork_version() const { return 0; }
uint8_t get_ideal_hard_fork_version(uint64_t height) const { return 0; }
uint8_t get_hard_fork_version(uint64_t height) const { return 0; }
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const { return 0; }
cryptonote::difficulty_type get_block_cumulative_difficulty(uint64_t height) const { return 0; }
bool fluffy_blocks_enabled() const { return false; }
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes, const std::vector<uint64_t> &weights) { return 0; }
bool has_block_weights(uint64_t height, uint64_t nblocks) const { return false; }
bool is_within_compiled_block_hash_area(uint64_t height) const { return false; }
bool pad_transactions() const { return false; }
uint32_t get_blockchain_pruning_seed() const { return 0; }
bool prune_blockchain(uint32_t pruning_seed) const { return true; }
bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes) { return false; }
bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_unrelayed_txes = true) const { return false; }
crypto::hash get_block_id_by_height(uint64_t height) const { return crypto::null_hash; }
};
}