From 00d5900cfb57020bbda19058c6bdd8933f7e91d9 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Tue, 10 Jul 2018 09:05:20 +0300 Subject: [PATCH 01/18] fixed issue #1050 --- .../wallet/include/graphene/wallet/wallet.hpp | 11 ++++++++ libraries/wallet/wallet.cpp | 19 +++++++++++++ tests/cli/main.cpp | 28 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index aeebb64eb8..688aed7bb0 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -663,6 +663,16 @@ class wallet_api */ bool load_wallet_file(string wallet_filename = ""); + /** Exits from BitShares wallet. + * + * @param wallet_filename the filename of the wallet JSON file to load. + * If \c wallet_filename is empty, it reloads the + * existing wallet file + * + * The current wallet will be closed. + */ + void quit(); + /** Saves the current wallet to the given filename. * * @warning This does not change the wallet filename that will be used for future @@ -1848,4 +1858,5 @@ FC_API( graphene::wallet::wallet_api, (blind_history) (receive_blind_transfer) (get_order_book) + (quit) ) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 8b61b74cf2..6d0ad0e565 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -774,6 +774,20 @@ class wallet_api_impl return true; } + + void quit() + { + ilog( "Exiting Wallet ..." ); + + try { + save_wallet_file(); + } catch (...) { + FC_THROW("Got error while saving wallet file in quit command."); + } + + exit(0); + } + void save_wallet_file(string wallet_filename = "") { // @@ -3781,6 +3795,11 @@ bool wallet_api::load_wallet_file( string wallet_filename ) return my->load_wallet_file( wallet_filename ); } +void wallet_api::quit() +{ + my->quit(); +} + void wallet_api::save_wallet_file( string wallet_filename ) { my->save_wallet_file( wallet_filename ); diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 672a8b8600..d3714c4296 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -483,3 +483,31 @@ BOOST_AUTO_TEST_CASE( cli_confidential_tx_test ) } app1->shutdown(); } + +//////////////// +// Start a server and connect using the same calls as the CLI +// Quit wallet and be sure that file was saved correctly +//////////////// +BOOST_AUTO_TEST_CASE( cli_quit ) +{ + using namespace graphene::chain; + using namespace graphene::app; + std::shared_ptr app1; + try { + BOOST_TEST_MESSAGE("Testing wallet connection and quit command."); + + fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() ); + + int server_port_number = 0; + app1 = start_application(app_dir, server_port_number); + + // connect to the server + client_connection con(app1, app_dir, server_port_number); + + BOOST_CHECK_NO_THROW( con.wallet_api_ptr->quit() ); + } catch( fc::exception& e ) { + edump((e.to_detail_string())); + throw; + } + app1->shutdown(); +} \ No newline at end of file From ed4ef3866d55dd4d9fe4576dcb3696516f78a8b5 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Tue, 10 Jul 2018 22:56:45 +0300 Subject: [PATCH 02/18] removed non-meaningful test, wallet file isn't saving in quit() command, using _Exit(0) instead of exit(0) http://www.cplusplus.com/reference/cstdlib/_Exit/ --- .../wallet/include/graphene/wallet/wallet.hpp | 4 --- libraries/wallet/wallet.cpp | 11 +++----- tests/cli/main.cpp | 28 ------------------- 3 files changed, 4 insertions(+), 39 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 688aed7bb0..9beffeb508 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -664,10 +664,6 @@ class wallet_api bool load_wallet_file(string wallet_filename = ""); /** Exits from BitShares wallet. - * - * @param wallet_filename the filename of the wallet JSON file to load. - * If \c wallet_filename is empty, it reloads the - * existing wallet file * * The current wallet will be closed. */ diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 6d0ad0e565..c68aefd9bf 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -74,6 +74,9 @@ #include #include +#include +using namespace std; + #ifndef WIN32 # include # include @@ -779,13 +782,7 @@ class wallet_api_impl { ilog( "Exiting Wallet ..." ); - try { - save_wallet_file(); - } catch (...) { - FC_THROW("Got error while saving wallet file in quit command."); - } - - exit(0); + _Exit(0); } void save_wallet_file(string wallet_filename = "") diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index d3714c4296..5bd29274bb 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -482,32 +482,4 @@ BOOST_AUTO_TEST_CASE( cli_confidential_tx_test ) throw; } app1->shutdown(); -} - -//////////////// -// Start a server and connect using the same calls as the CLI -// Quit wallet and be sure that file was saved correctly -//////////////// -BOOST_AUTO_TEST_CASE( cli_quit ) -{ - using namespace graphene::chain; - using namespace graphene::app; - std::shared_ptr app1; - try { - BOOST_TEST_MESSAGE("Testing wallet connection and quit command."); - - fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() ); - - int server_port_number = 0; - app1 = start_application(app_dir, server_port_number); - - // connect to the server - client_connection con(app1, app_dir, server_port_number); - - BOOST_CHECK_NO_THROW( con.wallet_api_ptr->quit() ); - } catch( fc::exception& e ) { - edump((e.to_detail_string())); - throw; - } - app1->shutdown(); } \ No newline at end of file From aed3acf7f2a9345ab180481e03e6678acb3d41ab Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Tue, 17 Jul 2018 22:57:25 +0300 Subject: [PATCH 03/18] added back cli_quit test --- tests/cli/main.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 5bd29274bb..c6f1e1791e 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -221,6 +221,34 @@ BOOST_AUTO_TEST_CASE( cli_connect ) app1->shutdown(); } +//////////////// +// Start a server and connect using the same calls as the CLI +// Quit wallet and be sure that file was saved correctly +//////////////// +BOOST_AUTO_TEST_CASE( cli_quit ) +{ + using namespace graphene::chain; + using namespace graphene::app; + std::shared_ptr app1; + try { + BOOST_TEST_MESSAGE("Testing wallet connection and quit command."); + + fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() ); + + int server_port_number = 0; + app1 = start_application(app_dir, server_port_number); + + // connect to the server + client_connection con(app1, app_dir, server_port_number); + + BOOST_CHECK_NO_THROW( con.wallet_api_ptr->quit() ); + } catch( fc::exception& e ) { + edump((e.to_detail_string())); + throw; + } + app1->shutdown(); + } + /////////////////////// // Start a server and connect using the same calls as the CLI // Vote for two witnesses, and make sure they both stay there From 12aeb3be2446f837752d42c04a86047ffc4c940d Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Wed, 18 Jul 2018 18:05:51 +0300 Subject: [PATCH 04/18] removed exit call --- libraries/wallet/wallet.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index c68aefd9bf..99bc278acd 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -780,9 +780,7 @@ class wallet_api_impl void quit() { - ilog( "Exiting Wallet ..." ); - - _Exit(0); + ilog( "Quiting Wallet ..." ); } void save_wallet_file(string wallet_filename = "") From 2b79efbc3309e2d6a8ad6bcb9aeab78da155b768 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Wed, 18 Jul 2018 18:06:44 +0300 Subject: [PATCH 05/18] merging changes from fc library --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 0dbf7ffc23..cfcff07e46 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 0dbf7ffc23162155fa59968e191c52c94ee11032 +Subproject commit cfcff07e46cb0d755d0894169ff3c160e7a4f6a3 From f40463370547dc6b0c57a827875f91ee5aa857ad Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Thu, 19 Jul 2018 09:55:16 +0300 Subject: [PATCH 06/18] changed return value in quit command --- .../wallet/include/graphene/wallet/wallet.hpp | 4 +++- libraries/wallet/wallet.cpp | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 9beffeb508..ba061d09c5 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -666,8 +666,10 @@ class wallet_api /** Exits from BitShares wallet. * * The current wallet will be closed. + * + * @returns SIGNAL */ - void quit(); + int quit(); /** Saves the current wallet to the given filename. * diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 99bc278acd..c55dc574a6 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -82,6 +82,12 @@ using namespace std; # include #endif +#ifdef WIN32 +# include +#else +# include +#endif + // explicit instantiation for later use namespace fc { template class api; @@ -778,9 +784,11 @@ class wallet_api_impl return true; } - void quit() + int quit() { ilog( "Quiting Wallet ..." ); + + return SIGQUIT; } void save_wallet_file(string wallet_filename = "") @@ -3790,9 +3798,9 @@ bool wallet_api::load_wallet_file( string wallet_filename ) return my->load_wallet_file( wallet_filename ); } -void wallet_api::quit() +int wallet_api::quit() { - my->quit(); + return my->quit(); } void wallet_api::save_wallet_file( string wallet_filename ) From e7c891d0fef7ad07caead0f7c512ee178b70e7b4 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Thu, 19 Jul 2018 09:55:39 +0300 Subject: [PATCH 07/18] merged changes from fc library --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index cfcff07e46..535fc869b5 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit cfcff07e46cb0d755d0894169ff3c160e7a4f6a3 +Subproject commit 535fc869b505af528043760adbe5a9424ca2c485 From 72aa2d92c7da7fd63998ddf9f15552b15e2da3aa Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 20 Jul 2018 16:45:57 +0300 Subject: [PATCH 08/18] throwing fc:canceled_exception for quit cli wallet command --- .../wallet/include/graphene/wallet/wallet.hpp | 2 +- libraries/wallet/wallet.cpp | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index ba061d09c5..64779cdb8c 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -669,7 +669,7 @@ class wallet_api * * @returns SIGNAL */ - int quit(); + void quit(); /** Saves the current wallet to the given filename. * diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index c55dc574a6..c4a28a160f 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -82,12 +82,6 @@ using namespace std; # include #endif -#ifdef WIN32 -# include -#else -# include -#endif - // explicit instantiation for later use namespace fc { template class api; @@ -784,11 +778,11 @@ class wallet_api_impl return true; } - int quit() + void quit() { - ilog( "Quiting Wallet ..." ); - - return SIGQUIT; + ilog( "Quiting Cli Wallet ..." ); + + throw fc::canceled_exception(); } void save_wallet_file(string wallet_filename = "") @@ -3798,9 +3792,9 @@ bool wallet_api::load_wallet_file( string wallet_filename ) return my->load_wallet_file( wallet_filename ); } -int wallet_api::quit() +void wallet_api::quit() { - return my->quit(); + my->quit(); } void wallet_api::save_wallet_file( string wallet_filename ) From a99cb5582720a0745aea9d96d8d44ac11a058cde Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 20 Jul 2018 16:46:46 +0300 Subject: [PATCH 09/18] merge fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 535fc869b5..18206552fc 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 535fc869b505af528043760adbe5a9424ca2c485 +Subproject commit 18206552fc60450a628056646eeabd0618868e61 From a53916b87a43d4f806536bcc12127b473215e75f Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Sun, 22 Jul 2018 09:09:31 +0300 Subject: [PATCH 10/18] little improvements --- libraries/wallet/include/graphene/wallet/wallet.hpp | 2 +- libraries/wallet/wallet.cpp | 3 --- tests/cli/main.cpp | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 64779cdb8c..09633be018 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -667,7 +667,7 @@ class wallet_api * * The current wallet will be closed. * - * @returns SIGNAL + * @throws fc::canceled_exception */ void quit(); diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index c4a28a160f..78da23a317 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -74,9 +74,6 @@ #include #include -#include -using namespace std; - #ifndef WIN32 # include # include diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index c6f1e1791e..e21b90b783 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -510,4 +510,4 @@ BOOST_AUTO_TEST_CASE( cli_confidential_tx_test ) throw; } app1->shutdown(); -} \ No newline at end of file +} From b9bcf596d451cee37934f449e4b84d64c1bbec29 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Sun, 22 Jul 2018 23:44:56 +0300 Subject: [PATCH 11/18] fixed test for quit command --- tests/cli/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index e21b90b783..9d0e82cb06 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -235,13 +235,13 @@ BOOST_AUTO_TEST_CASE( cli_quit ) fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() ); - int server_port_number = 0; - app1 = start_application(app_dir, server_port_number); + int server_port_number = 0; + app1 = start_application(app_dir, server_port_number); // connect to the server - client_connection con(app1, app_dir, server_port_number); + client_connection con(app1, app_dir, server_port_number); - BOOST_CHECK_NO_THROW( con.wallet_api_ptr->quit() ); + BOOST_CHECK_THROW( con.wallet_api_ptr->quit(), fc::canceled_exception ); } catch( fc::exception& e ) { edump((e.to_detail_string())); throw; From 96e9290f7177bc0171b58c24ae04b05584ca5303 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Sun, 22 Jul 2018 23:49:37 +0300 Subject: [PATCH 12/18] improved indentation after VSC wrong formatting --- tests/cli/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 9d0e82cb06..88a4ef9884 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -235,11 +235,11 @@ BOOST_AUTO_TEST_CASE( cli_quit ) fc::temp_directory app_dir ( graphene::utilities::temp_directory_path() ); - int server_port_number = 0; - app1 = start_application(app_dir, server_port_number); + int server_port_number = 0; + app1 = start_application(app_dir, server_port_number); // connect to the server - client_connection con(app1, app_dir, server_port_number); + client_connection con(app1, app_dir, server_port_number); BOOST_CHECK_THROW( con.wallet_api_ptr->quit(), fc::canceled_exception ); } catch( fc::exception& e ) { From 206de01d459aaeb5e2ed649e0c30ba2fd56f4232 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Wed, 25 Jul 2018 18:25:46 +0300 Subject: [PATCH 13/18] fixed typo --- libraries/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 78da23a317..d6d222e065 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -777,7 +777,7 @@ class wallet_api_impl void quit() { - ilog( "Quiting Cli Wallet ..." ); + ilog( "Quitting Cli Wallet ..." ); throw fc::canceled_exception(); } From 22f55b932e5df11f2f9a09eaa1b37837becf114d Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Wed, 25 Jul 2018 18:26:07 +0300 Subject: [PATCH 14/18] merged rebased fc --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 18206552fc..8f077140bd 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 18206552fc60450a628056646eeabd0618868e61 +Subproject commit 8f077140bdcd7cb11af8f6ed26242bef43baeb73 From a8a2619758aa00455bb945ab09c1e29c2c8c1344 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Wed, 25 Jul 2018 19:09:41 +0300 Subject: [PATCH 15/18] bumped fc library --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 8f077140bd..5469bb960a 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 8f077140bdcd7cb11af8f6ed26242bef43baeb73 +Subproject commit 5469bb960acc06c5fbe5941653fb526a762444a6 From b561c9821cbd45dd54e6ba3f942bdbe8041ae877 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Thu, 26 Jul 2018 19:05:45 +0300 Subject: [PATCH 16/18] fixed docker build issue with @throw in cli_wallet API documentatioin --- libraries/wallet/include/graphene/wallet/wallet.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 09633be018..a82aa2500e 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -663,11 +663,11 @@ class wallet_api */ bool load_wallet_file(string wallet_filename = ""); - /** Exits from BitShares wallet. + /** Quitting from BitShares wallet. * * The current wallet will be closed. * - * @throws fc::canceled_exception + * @return fc::canceled_exception */ void quit(); From 997a9630e6def57adb3d598c7cded07f66e630ff Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Thu, 26 Jul 2018 19:36:41 +0300 Subject: [PATCH 17/18] removed @return comment for cli_wallet quit command --- libraries/wallet/include/graphene/wallet/wallet.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index a82aa2500e..da06a23598 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -666,8 +666,6 @@ class wallet_api /** Quitting from BitShares wallet. * * The current wallet will be closed. - * - * @return fc::canceled_exception */ void quit(); From af5ee4d8203af29315fe6ab995868b9c91ea5fb9 Mon Sep 17 00:00:00 2001 From: Valera Cogut Date: Fri, 27 Jul 2018 16:45:42 +0300 Subject: [PATCH 18/18] bump FC --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 5469bb960a..e310159ede 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 5469bb960acc06c5fbe5941653fb526a762444a6 +Subproject commit e310159ede5a62a14ec6a17d2d45d83d065af2cf