34namespace po = boost::program_options;
39 req2.do_not_relay =
true;
55 std::vector<std::string> exclusive_nodes{
"127.0.0.1:65525"};
63 const char *test_mainnet = getenv(
"TEST_MAINNET");
64 if (!test_mainnet || atoi(test_mainnet) == 0)
70 const char *test_p2p_port = getenv(
"TEST_P2P_PORT");
71 auto p2p_port = std::string(test_p2p_port && strlen(test_p2p_port) > 0 ? test_p2p_port :
"61340");
74 const char *test_rpc_port = getenv(
"TEST_RPC_PORT");
75 auto rpc_port = std::string(test_rpc_port && strlen(test_rpc_port) > 0 ? test_rpc_port :
"61341");
78 const char *test_zmq_port = getenv(
"TEST_ZMQ_PORT");
79 auto zmq_port = std::string(test_zmq_port && strlen(test_zmq_port) > 0 ? test_zmq_port :
"61342");
154 MERROR(
"Failed to deinitialize RPC server...");
165 MERROR(
"Failed to deinitialize p2p...");
176 MERROR(
"Failed to stop cryptonote protocol!");
196 const unsigned max_attempts = 3;
197 for(
unsigned attempts=0; attempts < max_attempts; ++attempts)
211 catch(
const std::exception &e)
213 MWARNING(
"Could not init and start, attempt: " << attempts <<
", reason: " << e.what());
214 if (attempts + 1 >= max_attempts)
231 boost::thread stop_thread = boost::thread([
this] {
258 MINFO(
"Starting ZMQ server...");
280 catch (std::exception
const & ex)
282 MFATAL(
"Uncaught exception! " << ex.what());
287 MFATAL(
"Uncaught exception!");
314 bool blocks_mined =
false;
316 const auto mining_timeout = std::chrono::seconds(30);
317 MDEBUG(
"Current height before mining: " << start_height);
320 auto mining_started = std::chrono::system_clock::now();
328 MDEBUG(
"Cur blocks: " << cur_height <<
" start: " << start_height);
333 auto current_time = std::chrono::system_clock::now();
334 if (mining_timeout < current_time - mining_started)
349 req.miner_address = miner_address;
350 req.threads_count = threads_count;
351 req.do_background_mining = do_background_mining;
352 req.ignore_battery = ignore_battery;
373 return m_core->get_blockchain_storage().get_current_blockchain_height();
uint64_t num_blocks(const std::vector< test_event_entry > &events)
epee::net_utils::connection_context_base connection_context
bool on_send_raw_tx(const COMMAND_RPC_SEND_RAW_TX::request &req, COMMAND_RPC_SEND_RAW_TX::response &res, const connection_context *ctx=NULL)
static void init_options(boost::program_options::options_description &desc)
static const command_line::arg_descriptor< std::string, false, true, 2 > arg_rpc_bind_port
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
bool addTCPSocket(boost::string_ref address, boost::string_ref port)
void try_init_and_run(boost::optional< unsigned > initial_port=boost::none)
void mine_blocks(size_t num_blocks, const std::string &miner_address)
std::string rpc_addr() const
std::atomic< bool > m_deinitalized
boost::program_options::variables_map m_vm
std::atomic< bool > m_terminated
std::string m_zmq_bind_port
std::atomic< bool > m_stopped
std::string m_rpc_bind_port
t_protocol_raw m_protocol
static void default_options(boost::program_options::variables_map &vm)
cryptonote::network_type m_network_type
epee::net_utils::http::http_simple_client m_http_client
boost::thread m_run_thread
static void set_ports(boost::program_options::variables_map &vm, unsigned initial_port)
void load_params(boost::program_options::variables_map const &vm)
void start_mining(const std::string &miner_address, uint64_t threads_count=1, bool do_background_mining=false, bool ignore_battery=true)
std::string m_p2p_bind_port
mock_rpc_daemon m_rpc_server
static void init_options(boost::program_options::options_description &option_spec)
static constexpr const std::chrono::seconds rpc_timeout
cryptonote::core * m_core
bool on_send_raw_tx_2(const cryptonote::COMMAND_RPC_SEND_RAW_TX::request &req, cryptonote::COMMAND_RPC_SEND_RAW_TX::response &res, const cryptonote::core_rpc_server::connection_context *ctx)
#define CORE_RPC_STATUS_OK
#define CORE_RPC_STATUS_BUSY
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
void add_arg(boost::program_options::options_description &description, const arg_descriptor< T, required, dependent, NUM_DEPS > &arg, bool unique=true)
T get_arg(const boost::program_options::variables_map &vm, const arg_descriptor< T, false, true > &arg)
const command_line::arg_descriptor< bool > arg_offline
const command_line::arg_descriptor< bool, false > arg_testnet_on
const command_line::arg_descriptor< std::string, false, true, 2 > arg_zmq_rpc_bind_port
const command_line::arg_descriptor< std::string > arg_zmq_rpc_bind_ip
boost::shared_ptr< call_befor_die_base > auto_scope_leave_caller
auto_scope_leave_caller create_scope_leave_handler(t_scope_leave_handler f)
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct, t_transport &transport, std::chrono::milliseconds timeout=std::chrono::seconds(15), const boost::string_ref method="GET")
unsigned __int64 uint64_t
epee::misc_utils::struct_init< response_t > response
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< request_t > request
epee::misc_utils::struct_init< response_t > response
epee::misc_utils::struct_init< response_t > response
epee::misc_utils::struct_init< request_t > request