From b931199386f86624609ba0a71c3f831fd9e97f42 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Wed, 12 Feb 2020 20:36:54 +0100 Subject: [PATCH] fixed initialization --- src/wallet/plain_wallet_api.cpp | 10 +- src/wallet/wallets_manager.cpp | 2 +- .../core_concurrency_test.cpp | 2 +- tests/functional_tests/plain_wallet_tests.cpp | 278 +++++++++--------- 4 files changed, 149 insertions(+), 143 deletions(-) diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 713636e1..3e261269 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -27,6 +27,10 @@ namespace plain_wallet std::string get_bundle_root_dir() { +#ifdef WIN32 + return "undefined"; +#endif // WIN32 + char buffer[1000] = {0}; strcpy(buffer, getenv("HOME")); return buffer; @@ -60,9 +64,11 @@ namespace plain_wallet initialize_logs(); - std::string argss_1 = std::string("--remote-nodes=") + ip + ":" + port; - char * args[] = {"", 0}; + std::string argss_1 = std::string("--remote-node=") + ip + ":" + port; + char * args[3]; + args[0] = "stub"; args[1] = const_cast(argss_1.c_str()); + args[2] = nullptr; if (!gwm.init(2, args, nullptr)) { LOG_ERROR("Failed to init wallets_manager"); diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 2d137f66..cb3ee4dc 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -94,7 +94,7 @@ bool wallets_manager::init(int argc, char* argv[], view::i_view* pview_handler) view::daemon_status_info dsi = AUTO_VAL_INIT(dsi); dsi.pos_difficulty = dsi.pow_difficulty = "---"; - pview_handler->update_daemon_status(dsi); + m_pview->update_daemon_status(dsi); log_space::get_set_log_detalisation_level(true, LOG_LEVEL_0); log_space::get_set_need_thread_id(true, true); diff --git a/tests/functional_tests/core_concurrency_test.cpp b/tests/functional_tests/core_concurrency_test.cpp index d72cf983..52ff1b8c 100644 --- a/tests/functional_tests/core_concurrency_test.cpp +++ b/tests/functional_tests/core_concurrency_test.cpp @@ -13,7 +13,7 @@ using namespace epee; #include "currency_core/currency_core.h" #include "rpc/core_rpc_server.h" -#include "gui/qt-daemon/application/core_fast_rpc_proxy.h" +#include "wallet/core_fast_rpc_proxy.h" #include "version.h" #include "common/command_line.h" #include "common/boost_serialization_helper.h" diff --git a/tests/functional_tests/plain_wallet_tests.cpp b/tests/functional_tests/plain_wallet_tests.cpp index c843c3fe..caf30eec 100644 --- a/tests/functional_tests/plain_wallet_tests.cpp +++ b/tests/functional_tests/plain_wallet_tests.cpp @@ -19,143 +19,143 @@ using namespace epee; void run_plain_wallet_api_test() { LOG_PRINT_L0("Creating instance..."); - plain_wallet::hwallet hw = plain_wallet::create_instance("127.0.0.1", "11211"); - LOG_PRINT_L0("Creating instance..." << std::hex << hw); - - LOG_PRINT_L0("Generating wallet..."); - std::string rsp = plain_wallet::open(hw, std::string("E:\\tmp\\zano_testwallet_74565030.zan"), ""); - LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); - epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - epee::serialization::load_t_from_json(ok_response, rsp); - - plain_wallet::start_sync_thread(hw); - LOG_PRINT_L0("Started sync thread."); - - while (true) - { - std::string prog = plain_wallet::get_sync_status(hw); - plain_wallet::sync_status_response ssr = AUTO_VAL_INIT(ssr); - epee::serialization::load_t_from_json(ssr, prog); - LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); - if (ssr.finished) - break; - epee::misc_utils::sleep_no_w(1000); - } - LOG_PRINT_L0("Sync finished OK"); - - { - //request get wallet info: - epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); - gbreq.method = "get_wallet_info"; - epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); - std::string req_str = epee::serialization::store_t_to_json(gbreq); - - std::string res = plain_wallet::invoke(hw, req_str); - epee::serialization::load_t_from_json(gbres, res); - - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " - << ENDL << res); - } - - { - //request balance - epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); - gbreq.method = "getbalance"; - epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); - std::string req_str = epee::serialization::store_t_to_json(gbreq); - - std::string res = plain_wallet::invoke(hw, req_str); - epee::serialization::load_t_from_json(gbres, res); - - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], balance: " - << gbres.result.balance << ", unlocked_balance: " << gbres.result.unlocked_balance); - } - - { - //request balance - epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); - gbreq.method = "store"; - epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); - std::string req_str = epee::serialization::store_t_to_json(gbreq); - - std::string res = plain_wallet::invoke(hw, req_str); - epee::serialization::load_t_from_json(gbres, res); - - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " - << ENDL << res); - } - - plain_wallet::destroy_instance(hw); - - - return; - //------- - { - LOG_PRINT_L0("Creating instance..."); - plain_wallet::hwallet hw = plain_wallet::create_instance("127.0.0.1", "11211"); - LOG_PRINT_L0("Creating instance..." << std::hex << hw); - - LOG_PRINT_L0("Generating wallet..."); - std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\zano_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", ""); - LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); - epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); - epee::serialization::load_t_from_json(ok_response, rsp); - - plain_wallet::start_sync_thread(hw); - LOG_PRINT_L0("Started sync thread."); - - while (true) - { - std::string prog = plain_wallet::get_sync_status(hw); - plain_wallet::sync_status_response ssr = AUTO_VAL_INIT(ssr); - epee::serialization::load_t_from_json(ssr, prog); - LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); - if (ssr.finished) - break; - epee::misc_utils::sleep_no_w(1000); - } - LOG_PRINT_L0("Sync finished OK"); - - { - //request get wallet info: - epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); - gbreq.method = "get_wallet_info"; - epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); - std::string req_str = epee::serialization::store_t_to_json(gbreq); - - std::string res = plain_wallet::invoke(hw, req_str); - epee::serialization::load_t_from_json(gbres, res); - - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " - << ENDL << res); - } - - { - //request balance - epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); - gbreq.method = "getbalance"; - epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); - std::string req_str = epee::serialization::store_t_to_json(gbreq); - - std::string res = plain_wallet::invoke(hw, req_str); - epee::serialization::load_t_from_json(gbres, res); - - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], balance: " - << gbres.result.balance << ", unlocked_balance: " << gbres.result.unlocked_balance); - } - - { - //request balance - epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); - gbreq.method = "store"; - epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); - std::string req_str = epee::serialization::store_t_to_json(gbreq); - - std::string res = plain_wallet::invoke(hw, req_str); - epee::serialization::load_t_from_json(gbres, res); - - LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " - << ENDL << res); - } - } + std::string s = plain_wallet::init("127.0.0.1", "11211"); +// LOG_PRINT_L0("Creating instance..." << std::hex << hw); +// +// LOG_PRINT_L0("Generating wallet..."); +// std::string rsp = plain_wallet::open(hw, std::string("E:\\tmp\\zano_testwallet_74565030.zan"), ""); +// LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); +// epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); +// epee::serialization::load_t_from_json(ok_response, rsp); +// +// plain_wallet::start_sync_thread(hw); +// LOG_PRINT_L0("Started sync thread."); +// +// while (true) +// { +// std::string prog = plain_wallet::get_sync_status(hw); +// plain_wallet::sync_status_response ssr = AUTO_VAL_INIT(ssr); +// epee::serialization::load_t_from_json(ssr, prog); +// LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); +// if (ssr.finished) +// break; +// epee::misc_utils::sleep_no_w(1000); +// } +// LOG_PRINT_L0("Sync finished OK"); +// +// { +// //request get wallet info: +// epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); +// gbreq.method = "get_wallet_info"; +// epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); +// std::string req_str = epee::serialization::store_t_to_json(gbreq); +// +// std::string res = plain_wallet::invoke(hw, req_str); +// epee::serialization::load_t_from_json(gbres, res); +// +// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " +// << ENDL << res); +// } +// +// { +// //request balance +// epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); +// gbreq.method = "getbalance"; +// epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); +// std::string req_str = epee::serialization::store_t_to_json(gbreq); +// +// std::string res = plain_wallet::invoke(hw, req_str); +// epee::serialization::load_t_from_json(gbres, res); +// +// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], balance: " +// << gbres.result.balance << ", unlocked_balance: " << gbres.result.unlocked_balance); +// } +// +// { +// //request balance +// epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); +// gbreq.method = "store"; +// epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); +// std::string req_str = epee::serialization::store_t_to_json(gbreq); +// +// std::string res = plain_wallet::invoke(hw, req_str); +// epee::serialization::load_t_from_json(gbres, res); +// +// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " +// << ENDL << res); +// } +// +// plain_wallet::destroy_instance(hw); +// +// +// return; +// //------- +// { +// LOG_PRINT_L0("Creating instance..."); +// plain_wallet::hwallet hw = plain_wallet::create_instance("127.0.0.1", "11211"); +// LOG_PRINT_L0("Creating instance..." << std::hex << hw); +// +// LOG_PRINT_L0("Generating wallet..."); +// std::string rsp = plain_wallet::generate(hw, std::string("E:\\tmp\\zano_testwallet_") + std::to_string(epee::misc_utils::get_tick_count()) + ".zan", ""); +// LOG_PRINT_L0("RESPONSE:" << ENDL << rsp); +// epee::json_rpc::response ok_response = AUTO_VAL_INIT(ok_response); +// epee::serialization::load_t_from_json(ok_response, rsp); +// +// plain_wallet::start_sync_thread(hw); +// LOG_PRINT_L0("Started sync thread."); +// +// while (true) +// { +// std::string prog = plain_wallet::get_sync_status(hw); +// plain_wallet::sync_status_response ssr = AUTO_VAL_INIT(ssr); +// epee::serialization::load_t_from_json(ssr, prog); +// LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished); +// if (ssr.finished) +// break; +// epee::misc_utils::sleep_no_w(1000); +// } +// LOG_PRINT_L0("Sync finished OK"); +// +// { +// //request get wallet info: +// epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); +// gbreq.method = "get_wallet_info"; +// epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); +// std::string req_str = epee::serialization::store_t_to_json(gbreq); +// +// std::string res = plain_wallet::invoke(hw, req_str); +// epee::serialization::load_t_from_json(gbres, res); +// +// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " +// << ENDL << res); +// } +// +// { +// //request balance +// epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); +// gbreq.method = "getbalance"; +// epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); +// std::string req_str = epee::serialization::store_t_to_json(gbreq); +// +// std::string res = plain_wallet::invoke(hw, req_str); +// epee::serialization::load_t_from_json(gbres, res); +// +// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], balance: " +// << gbres.result.balance << ", unlocked_balance: " << gbres.result.unlocked_balance); +// } +// +// { +// //request balance +// epee::json_rpc::request gbreq = AUTO_VAL_INIT(gbreq); +// gbreq.method = "store"; +// epee::json_rpc::response gbres = AUTO_VAL_INIT(gbres); +// std::string req_str = epee::serialization::store_t_to_json(gbreq); +// +// std::string res = plain_wallet::invoke(hw, req_str); +// epee::serialization::load_t_from_json(gbres, res); +// +// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: " +// << ENDL << res); +// } +// } } \ No newline at end of file