diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index fd4a3c40..9b3282c4 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1310,11 +1310,15 @@ class wallet_api * @param owner_account the name or id of the account which is creating the SON * @param url a URL to include in the SON record in the blockchain. Clients may * display this when showing a list of SONs. May be blank. + * @param deposit_id vesting balance id for SON deposit + * @param pay_vb_id vesting balance id for SON pay_vb * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering a SON */ signed_transaction create_son(string owner_account, string url, + vesting_balance_id_type deposit_id, + vesting_balance_id_type pay_vb_id, bool broadcast = false); /** @@ -1423,6 +1427,19 @@ class wallet_api bool broadcast = false ); + /** Creates a vesting deposit owned by the given account. + * + * @param owner_account the name or id of the account + * @param amount the amount to deposit + * @param vesting_type "normal", "gpos" or "son" + * @param broadcast true to broadcast the transaction on the network + * @returns the signed transaction registering a vesting object + */ + signed_transaction create_vesting(string owner_account, + string amount, + string vesting_type, + bool broadcast = false); + /** * Get information about a vesting balance object. * @@ -2101,6 +2118,7 @@ FC_API( graphene::wallet::wallet_api, (update_witness) (create_worker) (update_worker_votes) + (create_vesting) (get_vesting_balances) (withdraw_vesting) (vote_for_committee_member) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 4b4bbcf8..d77a2a94 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -1860,6 +1860,8 @@ public: signed_transaction create_son(string owner_account, string url, + vesting_balance_id_type deposit_id, + vesting_balance_id_type pay_vb_id, bool broadcast /* = false */) { try { account_object son_account = get_account(owner_account); @@ -1872,6 +1874,8 @@ public: son_create_op.owner_account = son_account.id; son_create_op.signing_key = son_public_key; son_create_op.url = url; + son_create_op.deposit = deposit_id; + son_create_op.pay_vb = pay_vb_id; if (_remote_db->get_son_by_account(son_create_op.owner_account)) FC_THROW("Account ${owner_account} is already a SON", ("owner_account", owner_account)); @@ -2102,6 +2106,38 @@ public: return sign_transaction( tx, broadcast ); } + signed_transaction create_vesting(string owner_account, + string amount, + string vesting_type, + bool broadcast /* = false */) + { try { + account_object son_account = get_account(owner_account); + + vesting_balance_create_operation op; + op.creator = son_account.get_id(); + op.owner = son_account.get_id(); + op.amount = asset_object().amount_from_string(amount); + if (vesting_type == "normal") + op.balance_type = vesting_balance_type::normal; + else if (vesting_type == "gpos") + op.balance_type = vesting_balance_type::gpos; + else if (vesting_type == "son") + op.balance_type = vesting_balance_type::son; + else + { + FC_ASSERT( false, "unknown vesting type value ${vt}", ("vt", vesting_type) ); + } + if (op.balance_type == vesting_balance_type::son) + op.policy = dormant_vesting_policy_initializer {}; + + signed_transaction tx; + tx.operations.push_back( op ); + set_operation_fees( tx, _remote_db->get_global_properties().parameters.current_fees); + tx.validate(); + + return sign_transaction( tx, broadcast ); + } FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) } + vector< vesting_balance_object_with_info > get_vesting_balances( string account_name ) { try { fc::optional vbid = maybe_id( account_name ); @@ -4234,11 +4270,21 @@ committee_member_object wallet_api::get_committee_member(string owner_account) return my->get_committee_member(owner_account); } +signed_transaction wallet_api::create_vesting(string owner_account, + string amount, + string vesting_type, + bool broadcast /* = false */) +{ + return my->create_vesting(owner_account, amount, vesting_type, broadcast); +} + signed_transaction wallet_api::create_son(string owner_account, string url, + vesting_balance_id_type deposit_id, + vesting_balance_id_type pay_vb_id, bool broadcast /* = false */) { - return my->create_son(owner_account, url, broadcast); + return my->create_son(owner_account, url, deposit_id, pay_vb_id, broadcast); } signed_transaction wallet_api::update_son(string owner_account, diff --git a/programs/build_helpers/cat-parts b/programs/build_helpers/cat-parts deleted file mode 100755 index 2bcd1c8a..00000000 Binary files a/programs/build_helpers/cat-parts and /dev/null differ diff --git a/tests/cli/cli_fixture.cpp b/tests/cli/cli_fixture.cpp new file mode 100644 index 00000000..5b5fd7ad --- /dev/null +++ b/tests/cli/cli_fixture.cpp @@ -0,0 +1,277 @@ +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#ifdef _WIN32 +#ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0501 + #endif + #include + #include +#else +#include +#include +#include +#endif +#include + +#include +#include + +#include "cli_fixture.hpp" + +/***** + * Global Initialization for Windows + * ( sets up Winsock stuf ) + */ +#ifdef _WIN32 +int sockInit(void) +{ + WSADATA wsa_data; + return WSAStartup(MAKEWORD(1,1), &wsa_data); +} +int sockQuit(void) +{ + return WSACleanup(); +} +#endif + +/********************* + * Helper Methods + *********************/ + +#include "../common/genesis_file_util.hpp" + +////// +/// @brief attempt to find an available port on localhost +/// @returns an available port number, or -1 on error +///// +int get_available_port() +{ + struct sockaddr_in sin; + int socket_fd = socket(AF_INET, SOCK_STREAM, 0); + if (socket_fd == -1) + return -1; + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (::bind(socket_fd, (struct sockaddr*)&sin, sizeof(struct sockaddr_in)) == -1) + return -1; + socklen_t len = sizeof(sin); + if (getsockname(socket_fd, (struct sockaddr *)&sin, &len) == -1) + return -1; +#ifdef _WIN32 + closesocket(socket_fd); +#else + close(socket_fd); +#endif + return ntohs(sin.sin_port); +} + +/////////// +/// @brief Start the application +/// @param app_dir the temporary directory to use +/// @param server_port_number to be filled with the rpc endpoint port number +/// @returns the application object +////////// +std::shared_ptr start_application(fc::temp_directory& app_dir, int& server_port_number) { + std::shared_ptr app1(new graphene::app::application{}); + + app1->register_plugin(); + app1->register_plugin(); + app1->register_plugin(); + app1->register_plugin(); + app1->startup_plugins(); + boost::program_options::variables_map cfg; +#ifdef _WIN32 + sockInit(); +#endif + server_port_number = get_available_port(); + cfg.emplace( + "rpc-endpoint", + boost::program_options::variable_value(string("127.0.0.1:" + std::to_string(server_port_number)), false) + ); + cfg.emplace("genesis-json", boost::program_options::variable_value(create_genesis_file(app_dir), false)); + cfg.emplace("seed-nodes", boost::program_options::variable_value(string("[]"), false)); + cfg.emplace("plugins", boost::program_options::variable_value(string("bookie account_history market_history"), false)); + + app1->initialize(app_dir.path(), cfg); + + app1->initialize_plugins(cfg); + app1->startup_plugins(); + + app1->startup(); + fc::usleep(fc::milliseconds(500)); + return app1; +} + +client_connection::client_connection( + std::shared_ptr app, + const fc::temp_directory& data_dir, + const int server_port_number +) +{ + wallet_data.chain_id = app->chain_database()->get_chain_id(); + wallet_data.ws_server = "ws://127.0.0.1:" + std::to_string(server_port_number); + wallet_data.ws_user = ""; + wallet_data.ws_password = ""; + websocket_connection = websocket_client.connect( wallet_data.ws_server ); + + api_connection = std::make_shared(websocket_connection, GRAPHENE_MAX_NESTED_OBJECTS); + + remote_login_api = api_connection->get_remote_api< graphene::app::login_api >(1); + BOOST_CHECK(remote_login_api->login( wallet_data.ws_user, wallet_data.ws_password ) ); + + wallet_api_ptr = std::make_shared(wallet_data, remote_login_api); + wallet_filename = data_dir.path().generic_string() + "/wallet.json"; + wallet_api_ptr->set_wallet_filename(wallet_filename); + + wallet_api = fc::api(wallet_api_ptr); + + wallet_cli = std::make_shared(GRAPHENE_MAX_NESTED_OBJECTS); + for( auto& name_formatter : wallet_api_ptr->get_result_formatters() ) + wallet_cli->format_result( name_formatter.first, name_formatter.second ); + + boost::signals2::scoped_connection closed_connection(websocket_connection->closed.connect([=]{ + cerr << "Server has disconnected us.\n"; + wallet_cli->stop(); + })); + (void)(closed_connection); +} + +client_connection::~client_connection() +{ + // wait for everything to finish up + fc::usleep(fc::milliseconds(500)); +} + +/////////////////////////////// +// Cli Wallet Fixture +/////////////////////////////// + +cli_fixture::cli_fixture() : + server_port_number(0), + app_dir( graphene::utilities::temp_directory_path() ), + app1( start_application(app_dir, server_port_number) ), + con( app1, app_dir, server_port_number ), + nathan_keys( {"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"} ) +{ + BOOST_TEST_MESSAGE("Setup cli_wallet::boost_fixture_test_case"); + + using namespace graphene::chain; + using namespace graphene::app; + + try + { + BOOST_TEST_MESSAGE("Setting wallet password"); + con.wallet_api_ptr->set_password("supersecret"); + con.wallet_api_ptr->unlock("supersecret"); + + // import Nathan account + BOOST_TEST_MESSAGE("Importing nathan key"); + BOOST_CHECK_EQUAL(nathan_keys[0], "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"); + BOOST_CHECK(con.wallet_api_ptr->import_key("nathan", nathan_keys[0])); + } catch( fc::exception& e ) { + edump((e.to_detail_string())); + throw; + } +} + +cli_fixture::~cli_fixture() +{ + BOOST_TEST_MESSAGE("Cleanup cli_wallet::boost_fixture_test_case"); + + // wait for everything to finish up + fc::usleep(fc::seconds(1)); + + app1->shutdown(); +#ifdef _WIN32 + sockQuit(); +#endif +} + +bool cli_fixture::generate_maintenance_block() { + try { + fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); + uint32_t skip = ~database::skip_fork_db; + auto db = app1->chain_database(); + auto maint_time = db->get_dynamic_global_properties().next_maintenance_time; + auto slots_to_miss = db->get_slot_at_time(maint_time); + db->generate_block(db->get_slot_time(slots_to_miss), + db->get_scheduled_witness(slots_to_miss), + committee_key, + skip); + return true; + } catch (exception& e) + { + return false; + } +} + +bool cli_fixture::generate_block() +{ + graphene::chain::signed_block returned_block; + return generate_block(returned_block); +} + +bool cli_fixture::generate_block(graphene::chain::signed_block& returned_block) +{ + try { + fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); + auto db = app1->chain_database(); + returned_block = db->generate_block( db->get_slot_time(1), + db->get_scheduled_witness(1), + committee_key, + database::skip_nothing ); + return true; + } catch (exception &e) { + return false; + } +} + +void cli_fixture::init_nathan() +{ + try + { + BOOST_TEST_MESSAGE("Upgrade Nathan's account"); + + account_object nathan_acct_before_upgrade, nathan_acct_after_upgrade; + std::vector import_txs; + signed_transaction upgrade_tx; + + BOOST_TEST_MESSAGE("Importing nathan's balance"); + import_txs = con.wallet_api_ptr->import_balance("nathan", nathan_keys, true); + nathan_acct_before_upgrade = con.wallet_api_ptr->get_account("nathan"); + + BOOST_CHECK(generate_block()); + + // upgrade nathan + BOOST_TEST_MESSAGE("Upgrading Nathan to LTM"); + upgrade_tx = con.wallet_api_ptr->upgrade_account("nathan", true); + + nathan_acct_after_upgrade = con.wallet_api_ptr->get_account("nathan"); + + // verify that the upgrade was successful + BOOST_CHECK_PREDICATE( + std::not_equal_to(), + (nathan_acct_before_upgrade.membership_expiration_date.sec_since_epoch()) + (nathan_acct_after_upgrade.membership_expiration_date.sec_since_epoch()) + ); + BOOST_CHECK(nathan_acct_after_upgrade.is_lifetime_member()); + } catch( fc::exception& e ) { + edump((e.to_detail_string())); + throw; + } +} diff --git a/tests/cli/cli_fixture.hpp b/tests/cli/cli_fixture.hpp new file mode 100644 index 00000000..43196b9e --- /dev/null +++ b/tests/cli/cli_fixture.hpp @@ -0,0 +1,77 @@ +#include +#include + +#include +#include +#include +#include + +#define INVOKE(test) ((struct test*)this)->test_method(); + +/////////// +/// @brief a class to make connecting to the application server easier +/////////// +class client_connection +{ +public: + client_connection( + std::shared_ptr app, + const fc::temp_directory& data_dir, + const int server_port_number + ); + ~client_connection(); +public: + fc::http::websocket_client websocket_client; + graphene::wallet::wallet_data wallet_data; + fc::http::websocket_connection_ptr websocket_connection; + std::shared_ptr api_connection; + fc::api remote_login_api; + std::shared_ptr wallet_api_ptr; + fc::api wallet_api; + std::shared_ptr wallet_cli; + std::string wallet_filename; +}; + +/////////////////////////////// +// Cli Wallet Fixture +/////////////////////////////// +struct cli_fixture +{ + class dummy + { + public: + ~dummy() + { + // wait for everything to finish up + fc::usleep(fc::milliseconds(500)); + } + }; + dummy dmy; + int server_port_number; + fc::temp_directory app_dir; + std::shared_ptr app1; + client_connection con; + std::vector nathan_keys; + + cli_fixture(); + ~cli_fixture(); + + /////////// + /// Send a block to the db + /// @param returned_block the signed block + /// @returns true on success + /////////// + bool generate_block(graphene::chain::signed_block& returned_block); + bool generate_block(); + /////////// + /// @brief Skip intermediate blocks, and generate a maintenance block + /// @returns true on success + /////////// + bool generate_maintenance_block(); + + /////////// + // @brief init "nathan" account and make it LTM to use in tests + ////////// + void init_nathan(); +}; + diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 2f64f481..cc155979 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -21,358 +21,34 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#include -#include -#include +#include "cli_fixture.hpp" -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include #include -#ifdef _WIN32 -#ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 - #endif - #include - #include -#else -#include -#include -#include -#endif -#include - -#include - #define BOOST_TEST_MODULE Test Application #include -/***** - * Global Initialization for Windows - * ( sets up Winsock stuf ) - */ -#ifdef _WIN32 -int sockInit(void) -{ - WSADATA wsa_data; - return WSAStartup(MAKEWORD(1,1), &wsa_data); -} -int sockQuit(void) -{ - return WSACleanup(); -} -#endif - -/********************* - * Helper Methods - *********************/ - -#include "../common/genesis_file_util.hpp" - -#define INVOKE(test) ((struct test*)this)->test_method(); - -////// -/// @brief attempt to find an available port on localhost -/// @returns an available port number, or -1 on error -///// -int get_available_port() -{ - struct sockaddr_in sin; - int socket_fd = socket(AF_INET, SOCK_STREAM, 0); - if (socket_fd == -1) - return -1; - sin.sin_family = AF_INET; - sin.sin_port = 0; - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - if (::bind(socket_fd, (struct sockaddr*)&sin, sizeof(struct sockaddr_in)) == -1) - return -1; - socklen_t len = sizeof(sin); - if (getsockname(socket_fd, (struct sockaddr *)&sin, &len) == -1) - return -1; -#ifdef _WIN32 - closesocket(socket_fd); -#else - close(socket_fd); -#endif - return ntohs(sin.sin_port); -} - -/////////// -/// @brief Start the application -/// @param app_dir the temporary directory to use -/// @param server_port_number to be filled with the rpc endpoint port number -/// @returns the application object -////////// -std::shared_ptr start_application(fc::temp_directory& app_dir, int& server_port_number) { - std::shared_ptr app1(new graphene::app::application{}); - - app1->register_plugin(); - app1->register_plugin(); - app1->register_plugin(); - app1->register_plugin(); - app1->startup_plugins(); - boost::program_options::variables_map cfg; -#ifdef _WIN32 - sockInit(); -#endif - server_port_number = get_available_port(); - cfg.emplace( - "rpc-endpoint", - boost::program_options::variable_value(string("127.0.0.1:" + std::to_string(server_port_number)), false) - ); - cfg.emplace("genesis-json", boost::program_options::variable_value(create_genesis_file(app_dir), false)); - cfg.emplace("seed-nodes", boost::program_options::variable_value(string("[]"), false)); - cfg.emplace("plugins", boost::program_options::variable_value(string("bookie account_history market_history"), false)); - - app1->initialize(app_dir.path(), cfg); - - app1->initialize_plugins(cfg); - app1->startup_plugins(); - - app1->startup(); - fc::usleep(fc::milliseconds(500)); - return app1; -} - -/////////// -/// Send a block to the db -/// @param app the application -/// @param returned_block the signed block -/// @returns true on success -/////////// -bool generate_block(std::shared_ptr app, graphene::chain::signed_block& returned_block) -{ - try { - fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); - auto db = app->chain_database(); - returned_block = db->generate_block( db->get_slot_time(1), - db->get_scheduled_witness(1), - committee_key, - database::skip_nothing ); - return true; - } catch (exception &e) { - return false; - } -} - -bool generate_block(std::shared_ptr app) -{ - graphene::chain::signed_block returned_block; - return generate_block(app, returned_block); -} - -/////////// -/// @brief Skip intermediate blocks, and generate a maintenance block -/// @param app the application -/// @returns true on success -/////////// -bool generate_maintenance_block(std::shared_ptr app) { - try { - fc::ecc::private_key committee_key = fc::ecc::private_key::regenerate(fc::sha256::hash(string("nathan"))); - uint32_t skip = ~0; - auto db = app->chain_database(); - auto maint_time = db->get_dynamic_global_properties().next_maintenance_time; - auto slots_to_miss = db->get_slot_at_time(maint_time); - db->generate_block(db->get_slot_time(slots_to_miss), - db->get_scheduled_witness(slots_to_miss), - committee_key, - skip); - return true; - } catch (exception& e) - { - return false; - } -} - -/////////// -/// @brief a class to make connecting to the application server easier -/////////// -class client_connection -{ -public: - ///////// - // constructor - ///////// - client_connection( - std::shared_ptr app, - const fc::temp_directory& data_dir, - const int server_port_number - ) - { - wallet_data.chain_id = app->chain_database()->get_chain_id(); - wallet_data.ws_server = "ws://127.0.0.1:" + std::to_string(server_port_number); - wallet_data.ws_user = ""; - wallet_data.ws_password = ""; - websocket_connection = websocket_client.connect( wallet_data.ws_server ); - - api_connection = std::make_shared(websocket_connection, GRAPHENE_MAX_NESTED_OBJECTS); - - remote_login_api = api_connection->get_remote_api< graphene::app::login_api >(1); - BOOST_CHECK(remote_login_api->login( wallet_data.ws_user, wallet_data.ws_password ) ); - - wallet_api_ptr = std::make_shared(wallet_data, remote_login_api); - wallet_filename = data_dir.path().generic_string() + "/wallet.json"; - wallet_api_ptr->set_wallet_filename(wallet_filename); - - wallet_api = fc::api(wallet_api_ptr); - - wallet_cli = std::make_shared(GRAPHENE_MAX_NESTED_OBJECTS); - for( auto& name_formatter : wallet_api_ptr->get_result_formatters() ) - wallet_cli->format_result( name_formatter.first, name_formatter.second ); - - boost::signals2::scoped_connection closed_connection(websocket_connection->closed.connect([=]{ - cerr << "Server has disconnected us.\n"; - wallet_cli->stop(); - })); - (void)(closed_connection); - } - ~client_connection() - { - // wait for everything to finish up - fc::usleep(fc::milliseconds(500)); - } -public: - fc::http::websocket_client websocket_client; - graphene::wallet::wallet_data wallet_data; - fc::http::websocket_connection_ptr websocket_connection; - std::shared_ptr api_connection; - fc::api remote_login_api; - std::shared_ptr wallet_api_ptr; - fc::api wallet_api; - std::shared_ptr wallet_cli; - std::string wallet_filename; -}; - - -/////////////////////////////// -// Cli Wallet Fixture -/////////////////////////////// - -struct cli_fixture -{ - class dummy - { - public: - ~dummy() - { - // wait for everything to finish up - fc::usleep(fc::milliseconds(500)); - } - }; - dummy dmy; - int server_port_number; - fc::temp_directory app_dir; - std::shared_ptr app1; - client_connection con; - std::vector nathan_keys; - - cli_fixture() : - server_port_number(0), - app_dir( graphene::utilities::temp_directory_path() ), - app1( start_application(app_dir, server_port_number) ), - con( app1, app_dir, server_port_number ), - nathan_keys( {"5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"} ) - { - BOOST_TEST_MESSAGE("Setup cli_wallet::boost_fixture_test_case"); - - using namespace graphene::chain; - using namespace graphene::app; - - try - { - BOOST_TEST_MESSAGE("Setting wallet password"); - con.wallet_api_ptr->set_password("supersecret"); - con.wallet_api_ptr->unlock("supersecret"); - - // import Nathan account - BOOST_TEST_MESSAGE("Importing nathan key"); - BOOST_CHECK_EQUAL(nathan_keys[0], "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"); - BOOST_CHECK(con.wallet_api_ptr->import_key("nathan", nathan_keys[0])); - } catch( fc::exception& e ) { - edump((e.to_detail_string())); - throw; - } - } - - ~cli_fixture() - { - BOOST_TEST_MESSAGE("Cleanup cli_wallet::boost_fixture_test_case"); - - // wait for everything to finish up - fc::usleep(fc::seconds(1)); - - app1->shutdown(); -#ifdef _WIN32 - sockQuit(); -#endif - } -}; - /////////////////////////////// // Tests /////////////////////////////// -//////////////// -// Start a server and connect using the same calls as the CLI -//////////////// -BOOST_FIXTURE_TEST_CASE( cli_connect, cli_fixture ) +BOOST_FIXTURE_TEST_SUITE(cli_common, cli_fixture) + +BOOST_AUTO_TEST_CASE( cli_connect ) { BOOST_TEST_MESSAGE("Testing wallet connection."); } -BOOST_FIXTURE_TEST_CASE( upgrade_nathan_account, cli_fixture ) +BOOST_AUTO_TEST_CASE( upgrade_nathan_account ) { - try - { - BOOST_TEST_MESSAGE("Upgrade Nathan's account"); - - account_object nathan_acct_before_upgrade, nathan_acct_after_upgrade; - std::vector import_txs; - signed_transaction upgrade_tx; - - BOOST_TEST_MESSAGE("Importing nathan's balance"); - import_txs = con.wallet_api_ptr->import_balance("nathan", nathan_keys, true); - nathan_acct_before_upgrade = con.wallet_api_ptr->get_account("nathan"); - - BOOST_CHECK(generate_block(app1)); - - // upgrade nathan - BOOST_TEST_MESSAGE("Upgrading Nathan to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("nathan", true); - - nathan_acct_after_upgrade = con.wallet_api_ptr->get_account("nathan"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (nathan_acct_before_upgrade.membership_expiration_date.sec_since_epoch()) - (nathan_acct_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(nathan_acct_after_upgrade.is_lifetime_member()); - } catch( fc::exception& e ) { - edump((e.to_detail_string())); - throw; - } + init_nathan(); } -BOOST_FIXTURE_TEST_CASE( create_new_account, cli_fixture ) +BOOST_AUTO_TEST_CASE( create_new_account ) { try { - INVOKE(upgrade_nathan_account); + init_nathan(); // create a new account graphene::wallet::brain_key_info bki = con.wallet_api_ptr->suggest_brain_key(); @@ -400,13 +76,13 @@ BOOST_FIXTURE_TEST_CASE( create_new_account, cli_fixture ) // Vote for two witnesses, and make sure they both stay there // after a maintenance block /////////////////////// -BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture ) +BOOST_AUTO_TEST_CASE( cli_vote_for_2_witnesses ) { try { BOOST_TEST_MESSAGE("Cli Vote Test for 2 Witnesses"); - INVOKE(upgrade_nathan_account); // just to fund nathan + init_nathan(); // get the details for init1 witness_object init1_obj = con.wallet_api_ptr->get_witness("init1"); @@ -415,9 +91,9 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture ) signed_transaction vote_witness1_tx = con.wallet_api_ptr->vote_for_witness("nathan", "init1", true, true); // generate a block to get things started - BOOST_CHECK(generate_block(app1)); + BOOST_CHECK(generate_block()); // wait for a maintenance interval - BOOST_CHECK(generate_maintenance_block(app1)); + BOOST_CHECK(generate_maintenance_block()); // Verify that the vote is there init1_obj = con.wallet_api_ptr->get_witness("init1"); @@ -430,7 +106,7 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture ) signed_transaction vote_witness2_tx = con.wallet_api_ptr->vote_for_witness("nathan", "init2", true, true); // send another block to trigger maintenance interval - BOOST_CHECK(generate_maintenance_block(app1)); + BOOST_CHECK(generate_maintenance_block()); // Verify that both the first vote and the 2nd are there init2_obj = con.wallet_api_ptr->get_witness("init2"); @@ -446,935 +122,10 @@ BOOST_FIXTURE_TEST_CASE( cli_vote_for_2_witnesses, cli_fixture ) } } -/////////////////////// -// SON CLI -/////////////////////// -BOOST_FIXTURE_TEST_CASE( create_son, cli_fixture ) -{ - BOOST_TEST_MESSAGE("SON cli wallet tests begin"); - try - { - INVOKE(upgrade_nathan_account); - - graphene::wallet::brain_key_info bki; - signed_transaction create_tx; - signed_transaction transfer_tx; - signed_transaction upgrade_tx; - signed_transaction delete_tx; - account_object son1_before_upgrade, son1_after_upgrade; - account_object son2_before_upgrade, son2_after_upgrade; - son_object son1_obj; - son_object son2_obj; - - // create son1account - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "son1account", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("son1account", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give son1account some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to son1account"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "son1account", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - son1_before_upgrade = con.wallet_api_ptr->get_account("son1account"); - BOOST_CHECK(generate_block(app1)); - - // upgrade son1account - BOOST_TEST_MESSAGE("Upgrading son1account to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("son1account", true); - son1_after_upgrade = con.wallet_api_ptr->get_account("son1account"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (son1_before_upgrade.membership_expiration_date.sec_since_epoch()) - (son1_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(son1_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create son2account - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "son2account", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("son2account", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give son1account some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to son2account"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "son2account", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - son2_before_upgrade = con.wallet_api_ptr->get_account("son2account"); - BOOST_CHECK(generate_block(app1)); - - // upgrade son1account - BOOST_TEST_MESSAGE("Upgrading son2account to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("son2account", true); - son2_after_upgrade = con.wallet_api_ptr->get_account("son2account"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (son2_before_upgrade.membership_expiration_date.sec_since_epoch()) - (son2_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(son2_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create 2 SONs - BOOST_TEST_MESSAGE("Creating two SONs"); - create_tx = con.wallet_api_ptr->create_son("son1account", "http://son1", "true"); - create_tx = con.wallet_api_ptr->create_son("son2account", "http://son2", "true"); - BOOST_CHECK(generate_maintenance_block(app1)); - - son1_obj = con.wallet_api_ptr->get_son("son1account"); - BOOST_CHECK(son1_obj.son_account == con.wallet_api_ptr->get_account_id("son1account")); - BOOST_CHECK_EQUAL(son1_obj.url, "http://son1"); - - son2_obj = con.wallet_api_ptr->get_son("son2account"); - BOOST_CHECK(son2_obj.son_account == con.wallet_api_ptr->get_account_id("son2account")); - BOOST_CHECK_EQUAL(son2_obj.url, "http://son2"); - - - - BOOST_TEST_MESSAGE("Voting for SONs"); - - signed_transaction vote_son1_tx; - signed_transaction vote_son2_tx; - int son1_start_votes, son1_end_votes; - int son2_start_votes, son2_end_votes; - - son1_obj = con.wallet_api_ptr->get_son("son1account"); - son1_start_votes = son1_obj.total_votes; - son2_obj = con.wallet_api_ptr->get_son("son2account"); - son2_start_votes = son2_obj.total_votes; - - // Vote for a son1account - BOOST_TEST_MESSAGE("Voting for son1account"); - vote_son1_tx = con.wallet_api_ptr->vote_for_son("nathan", "son1account", true, true); - BOOST_CHECK(generate_maintenance_block(app1)); - - // Verify that the vote is there - son1_obj = con.wallet_api_ptr->get_son("son1account"); - son1_end_votes = son1_obj.total_votes; - BOOST_CHECK(son1_end_votes > son1_start_votes); - - // Vote for a son2account - BOOST_TEST_MESSAGE("Voting for son2account"); - vote_son2_tx = con.wallet_api_ptr->vote_for_son("nathan", "son2account", true, true); - BOOST_CHECK(generate_maintenance_block(app1)); - - // Verify that the vote is there - son2_obj = con.wallet_api_ptr->get_son("son2account"); - son2_end_votes = son2_obj.total_votes; - BOOST_CHECK(son2_end_votes > son2_start_votes); - - // Withdraw vote for a son1account - BOOST_TEST_MESSAGE("Withdraw vote for a son1account"); - vote_son1_tx = con.wallet_api_ptr->vote_for_son("nathan", "son1account", false, true); - BOOST_CHECK(generate_maintenance_block(app1)); - - // Verify that the vote is removed - son1_obj = con.wallet_api_ptr->get_son("son1account"); - son1_end_votes = son1_obj.total_votes; - BOOST_CHECK(son1_end_votes == son1_start_votes); - - // Withdraw vote for a son2account - BOOST_TEST_MESSAGE("Withdraw vote for a son2account"); - vote_son2_tx = con.wallet_api_ptr->vote_for_son("nathan", "son2account", false, true); - BOOST_CHECK(generate_maintenance_block(app1)); - - // Verify that the vote is removed - son2_obj = con.wallet_api_ptr->get_son("son2account"); - son2_end_votes = son2_obj.total_votes; - BOOST_CHECK(son2_end_votes == son2_start_votes); - - - - BOOST_TEST_MESSAGE("Deleting SONs"); - auto _db = app1->chain_database(); - BOOST_CHECK(_db->get_index_type().indices().size() == 2); - delete_tx = con.wallet_api_ptr->delete_son("son1account", "true"); - delete_tx = con.wallet_api_ptr->delete_son("son2account", "true"); - BOOST_CHECK(generate_maintenance_block(app1)); - BOOST_CHECK(_db->get_index_type().indices().size() == 0); - - } catch( fc::exception& e ) { - BOOST_TEST_MESSAGE("SON cli wallet tests exception"); - edump((e.to_detail_string())); - throw; - } - BOOST_TEST_MESSAGE("SON cli wallet tests end"); -} - -BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture ) -{ - BOOST_TEST_MESSAGE("SON cli wallet tests begin"); - try - { - INVOKE(upgrade_nathan_account); - - graphene::wallet::brain_key_info bki; - signed_transaction create_tx; - signed_transaction transfer_tx; - signed_transaction upgrade_tx; - signed_transaction vote_tx; - account_object acc_before_upgrade, acc_after_upgrade; - son_object son_obj; - global_property_object gpo; - - // create sonaccount01 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount01", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount01", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount01 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount01"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount01", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount01"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount01 - BOOST_TEST_MESSAGE("Upgrading sonaccount01 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount01", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount01"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount02 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount02", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount02", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount02 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount02"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount02", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount02"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount02 - BOOST_TEST_MESSAGE("Upgrading sonaccount02 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount02", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount02"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount03 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount03", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount03", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount03 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount03"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount03", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount03"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount03 - BOOST_TEST_MESSAGE("Upgrading sonaccount03 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount03", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount03"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount04 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount04", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount04", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount04 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount04"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount04", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount04"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount04 - BOOST_TEST_MESSAGE("Upgrading sonaccount04 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount04", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount04"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount05 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount05", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount05", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount05 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount05"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount05", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount05"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount05 - BOOST_TEST_MESSAGE("Upgrading sonaccount05 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount05", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount05"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount06 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount06", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount06", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount06 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount06"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount06", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount06"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount06 - BOOST_TEST_MESSAGE("Upgrading sonaccount06 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount06", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount06"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount07 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount07", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount07", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount07 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount07"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount07", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount07"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount07 - BOOST_TEST_MESSAGE("Upgrading sonaccount07 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount07", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount07"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount08 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount08", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount08", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount08 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount08"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount08", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount08"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount08 - BOOST_TEST_MESSAGE("Upgrading sonaccount08 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount08", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount08"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount09 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount09", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount09", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount09 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount09"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount09", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount09"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount09 - BOOST_TEST_MESSAGE("Upgrading sonaccount09 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount09", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount09"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount10 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount10", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount10", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount10 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount10"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount10", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount10"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount10 - BOOST_TEST_MESSAGE("Upgrading sonaccount10 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount10", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount10"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount11 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount11", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount11", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount11 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount11"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount11", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount11"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount11 - BOOST_TEST_MESSAGE("Upgrading sonaccount11 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount11", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount11"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount12 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount12", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount12", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount12 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount12"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount12", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount12"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount12 - BOOST_TEST_MESSAGE("Upgrading sonaccount12 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount12", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount12"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount13 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount13", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount13", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount13 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount13"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount13", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount13"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount13 - BOOST_TEST_MESSAGE("Upgrading sonaccount13 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount13", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount13"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount14 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount14", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount14", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount14 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount14"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount14", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount14"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount14 - BOOST_TEST_MESSAGE("Upgrading sonaccount14 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount14", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount14"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount15 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount15", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount15", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount15 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount15"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount15", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount15"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount15 - BOOST_TEST_MESSAGE("Upgrading sonaccount15 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount15", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount15"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create sonaccount16 - bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - create_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonaccount16", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonaccount16", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonaccount16 some CORE tokens - BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to sonaccount16"); - transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonaccount16", "15000", "1.3.0", "Here are some CORE token for your new account", true - ); - - acc_before_upgrade = con.wallet_api_ptr->get_account("sonaccount16"); - BOOST_CHECK(generate_block(app1)); - - // upgrade sonaccount16 - BOOST_TEST_MESSAGE("Upgrading sonaccount16 to LTM"); - upgrade_tx = con.wallet_api_ptr->upgrade_account("sonaccount16", true); - acc_after_upgrade = con.wallet_api_ptr->get_account("sonaccount16"); - - // verify that the upgrade was successful - BOOST_CHECK_PREDICATE( - std::not_equal_to(), - (acc_before_upgrade.membership_expiration_date.sec_since_epoch()) - (acc_after_upgrade.membership_expiration_date.sec_since_epoch()) - ); - BOOST_CHECK(acc_after_upgrade.is_lifetime_member()); - - BOOST_CHECK(generate_block(app1)); - - - - // create 16 SONs - BOOST_TEST_MESSAGE("Creating 16 SONs"); - create_tx = con.wallet_api_ptr->create_son("sonaccount01", "http://son01", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount02", "http://son02", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount03", "http://son03", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount04", "http://son04", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount05", "http://son05", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount06", "http://son06", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount07", "http://son07", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount08", "http://son08", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount09", "http://son09", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount10", "http://son10", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount11", "http://son11", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount12", "http://son12", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount13", "http://son13", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount14", "http://son14", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount15", "http://son15", "true"); - create_tx = con.wallet_api_ptr->create_son("sonaccount16", "http://son16", "true"); - BOOST_CHECK(generate_maintenance_block(app1)); - - son_obj = con.wallet_api_ptr->get_son("sonaccount01"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount01")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son01"); - son_obj = con.wallet_api_ptr->get_son("sonaccount02"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount02")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son02"); - son_obj = con.wallet_api_ptr->get_son("sonaccount03"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount03")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son03"); - son_obj = con.wallet_api_ptr->get_son("sonaccount04"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount04")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son04"); - son_obj = con.wallet_api_ptr->get_son("sonaccount05"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount05")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son05"); - son_obj = con.wallet_api_ptr->get_son("sonaccount06"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount06")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son06"); - son_obj = con.wallet_api_ptr->get_son("sonaccount07"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount07")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son07"); - son_obj = con.wallet_api_ptr->get_son("sonaccount08"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount08")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son08"); - son_obj = con.wallet_api_ptr->get_son("sonaccount09"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount09")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son09"); - son_obj = con.wallet_api_ptr->get_son("sonaccount10"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount10")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son10"); - son_obj = con.wallet_api_ptr->get_son("sonaccount11"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount11")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son11"); - son_obj = con.wallet_api_ptr->get_son("sonaccount12"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount12")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son12"); - son_obj = con.wallet_api_ptr->get_son("sonaccount13"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount13")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son13"); - son_obj = con.wallet_api_ptr->get_son("sonaccount14"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount14")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son14"); - son_obj = con.wallet_api_ptr->get_son("sonaccount15"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount15")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son15"); - son_obj = con.wallet_api_ptr->get_son("sonaccount16"); - BOOST_CHECK(son_obj.son_account == con.wallet_api_ptr->get_account_id("sonaccount16")); - BOOST_CHECK_EQUAL(son_obj.url, "http://son16"); - - - - BOOST_TEST_MESSAGE("Voting for SONs"); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount01", "sonaccount01", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount02", "sonaccount02", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount03", "sonaccount03", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount04", "sonaccount04", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount05", "sonaccount05", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount06", "sonaccount06", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount07", "sonaccount07", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount08", "sonaccount08", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount09", "sonaccount09", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount10", "sonaccount10", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount11", "sonaccount11", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount12", "sonaccount12", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount13", "sonaccount13", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount14", "sonaccount14", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount15", "sonaccount15", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount16", "sonaccount16", true, true); - BOOST_CHECK(generate_maintenance_block(app1)); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount01", "sonaccount02", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount02", "sonaccount03", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount03", "sonaccount04", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount04", "sonaccount05", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount05", "sonaccount06", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount06", "sonaccount07", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount07", "sonaccount08", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount08", "sonaccount09", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount09", "sonaccount10", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount10", "sonaccount11", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount11", "sonaccount12", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount12", "sonaccount13", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount13", "sonaccount14", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount14", "sonaccount15", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount15", "sonaccount16", true, true); - gpo = con.wallet_api_ptr->get_global_properties(); - BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); - BOOST_CHECK(generate_maintenance_block(app1)); - gpo = con.wallet_api_ptr->get_global_properties(); - BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount03", "sonaccount01", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount04", "sonaccount02", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount05", "sonaccount03", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount06", "sonaccount04", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount07", "sonaccount05", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount08", "sonaccount06", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount09", "sonaccount07", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount10", "sonaccount08", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount11", "sonaccount09", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount12", "sonaccount10", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount13", "sonaccount11", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount14", "sonaccount12", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount15", "sonaccount13", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount16", "sonaccount14", true, true); - gpo = con.wallet_api_ptr->get_global_properties(); - BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); - BOOST_CHECK(generate_maintenance_block(app1)); - gpo = con.wallet_api_ptr->get_global_properties(); - BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount04", "sonaccount01", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount05", "sonaccount02", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount06", "sonaccount03", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount07", "sonaccount04", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount08", "sonaccount05", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount09", "sonaccount06", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount10", "sonaccount07", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount11", "sonaccount08", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount12", "sonaccount09", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount13", "sonaccount10", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount14", "sonaccount11", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount15", "sonaccount12", true, true); - vote_tx = con.wallet_api_ptr->vote_for_son("sonaccount16", "sonaccount13", true, true); - gpo = con.wallet_api_ptr->get_global_properties(); - BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); - BOOST_CHECK(generate_maintenance_block(app1)); - - BOOST_CHECK(gpo.active_sons.size() == 15); - - } catch( fc::exception& e ) { - BOOST_TEST_MESSAGE("SON cli wallet tests exception"); - edump((e.to_detail_string())); - throw; - } - BOOST_TEST_MESSAGE("SON cli wallet tests end"); -} - /////////////////////// // Check account history pagination /////////////////////// -BOOST_FIXTURE_TEST_CASE( account_history_pagination, cli_fixture ) +BOOST_AUTO_TEST_CASE( account_history_pagination ) { try { @@ -1388,7 +139,7 @@ BOOST_FIXTURE_TEST_CASE( account_history_pagination, cli_fixture ) "1.3.0", "Here are some CORE token for your new account", true); } - BOOST_CHECK(generate_block(app1)); + BOOST_CHECK(generate_block()); // now get account history and make sure everything is there (and no duplicates) std::vector history = con.wallet_api_ptr->get_account_history("jmjatlanta", 300); @@ -1410,57 +161,4 @@ BOOST_FIXTURE_TEST_CASE( account_history_pagination, cli_fixture ) } } -BOOST_FIXTURE_TEST_CASE( cli_get_son, cli_fixture ) -{ - try - { - BOOST_TEST_MESSAGE("Cli get_son Test"); - - INVOKE(upgrade_nathan_account); // just to fund nathan - - // create a new account - graphene::wallet::brain_key_info bki = con.wallet_api_ptr->suggest_brain_key(); - BOOST_CHECK(!bki.brain_priv_key.empty()); - signed_transaction create_acct_tx = con.wallet_api_ptr->create_account_with_brain_key( - bki.brain_priv_key, "sonmember", "nathan", "nathan", true - ); - // save the private key for this new account in the wallet file - BOOST_CHECK(con.wallet_api_ptr->import_key("sonmember", bki.wif_priv_key)); - con.wallet_api_ptr->save_wallet_file(con.wallet_filename); - - // attempt to give sonmember some CORE - BOOST_TEST_MESSAGE("Transferring CORE from Nathan to sonmember"); - signed_transaction transfer_tx = con.wallet_api_ptr->transfer( - "nathan", "sonmember", "100000", "1.3.0", "Here are some CORE token for your new account", true - ); - - BOOST_CHECK(generate_block(app1)); - - // upgrade sonmember account - con.wallet_api_ptr->upgrade_account("sonmember", true); - auto sonmember_acct = con.wallet_api_ptr->get_account("sonmember"); - BOOST_CHECK(sonmember_acct.is_lifetime_member()); - - // create son - con.wallet_api_ptr->create_son("sonmember", "http://sonmember", true); - - // get_son - auto son_data = con.wallet_api_ptr->get_son("sonmember"); - BOOST_CHECK(son_data.url == "http://sonmember"); - BOOST_CHECK(son_data.son_account == sonmember_acct.get_id()); - - // update SON - con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", true); - son_data = con.wallet_api_ptr->get_son("sonmember"); - BOOST_CHECK(son_data.url == "http://sonmember_updated"); - - // delete SON - con.wallet_api_ptr->delete_son("sonmember", true); - auto res = con.wallet_api_ptr->list_sons("", 100); - BOOST_CHECK(res.find("sonmember") == res.end()); - - } catch( fc::exception& e ) { - edump((e.to_detail_string())); - throw; - } -} +BOOST_AUTO_TEST_SUITE_END() diff --git a/tests/cli/son.cpp b/tests/cli/son.cpp new file mode 100644 index 00000000..1dfd8381 --- /dev/null +++ b/tests/cli/son.cpp @@ -0,0 +1,519 @@ +/* + * Copyright (c) 2019 PBSA, and contributors. + * + * The MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +#include "cli_fixture.hpp" + +#include +#include + +#include + +class son_test_helper +{ + cli_fixture& fixture_; + +public: + son_test_helper(cli_fixture& fixture): + fixture_(fixture) + { + fixture_.init_nathan(); + } + + void create_son(const std::string& account_name, const std::string& son_url, + bool generate_maintenance = true) + { + graphene::wallet::brain_key_info bki; + signed_transaction create_tx; + signed_transaction transfer_tx; + signed_transaction upgrade_tx; + account_object son_account; + son_object son_obj; + + // create son account + bki = fixture_.con.wallet_api_ptr->suggest_brain_key(); + BOOST_CHECK(!bki.brain_priv_key.empty()); + create_tx = fixture_.con.wallet_api_ptr->create_account_with_brain_key( + bki.brain_priv_key, account_name, "nathan", "nathan", true + ); + // save the private key for this new account in the wallet file + BOOST_CHECK(fixture_.con.wallet_api_ptr->import_key(account_name, bki.wif_priv_key)); + fixture_.con.wallet_api_ptr->save_wallet_file(fixture_.con.wallet_filename); + + // attempt to give son account some CORE tokens + BOOST_TEST_MESSAGE("Transferring CORE tokens from Nathan to son account"); + transfer_tx = fixture_.con.wallet_api_ptr->transfer( + "nathan", account_name, "65000", "1.3.0", "Here are some CORE token for your new account", true + ); + + BOOST_CHECK(fixture_.generate_block()); + + // upgrade son account + BOOST_TEST_MESSAGE("Upgrading son account to LTM"); + upgrade_tx = fixture_.con.wallet_api_ptr->upgrade_account(account_name, true); + son_account = fixture_.con.wallet_api_ptr->get_account(account_name); + + // verify that the upgrade was successful + BOOST_CHECK(son_account.is_lifetime_member()); + + BOOST_CHECK(fixture_.generate_block()); + + // create deposit vesting + fixture_.con.wallet_api_ptr->create_vesting(account_name, "50000000", "son", true); + BOOST_CHECK(fixture_.generate_block()); + + // create pay_vb vesting + fixture_.con.wallet_api_ptr->create_vesting(account_name, "1000000", "normal", true); + BOOST_CHECK(fixture_.generate_block()); + + // check deposits are here + auto deposits = fixture_.con.wallet_api_ptr->get_vesting_balances(account_name); + BOOST_CHECK(deposits.size() == 2); + + create_tx = fixture_.con.wallet_api_ptr->create_son(account_name, son_url, + deposits[0].id, deposits[1].id, + true); + + if (generate_maintenance) + BOOST_CHECK(fixture_.generate_maintenance_block()); + } + +}; + +/////////////////////// +// SON CLI +/////////////////////// +BOOST_FIXTURE_TEST_SUITE(son_cli, cli_fixture) + +BOOST_AUTO_TEST_CASE( create_sons ) +{ + BOOST_TEST_MESSAGE("SON cli wallet tests begin"); + try + { + son_test_helper sth(*this); + sth.create_son("son1account", "http://son1"); + sth.create_son("son2account", "http://son2"); + + auto son1_obj = con.wallet_api_ptr->get_son("son1account"); + BOOST_CHECK(son1_obj.son_account == con.wallet_api_ptr->get_account_id("son1account")); + BOOST_CHECK_EQUAL(son1_obj.url, "http://son1"); + + auto son2_obj = con.wallet_api_ptr->get_son("son2account"); + BOOST_CHECK(son2_obj.son_account == con.wallet_api_ptr->get_account_id("son2account")); + BOOST_CHECK_EQUAL(son2_obj.url, "http://son2"); + + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("SON cli wallet tests end"); +} + +BOOST_AUTO_TEST_CASE( cli_update_son ) +{ + try + { + BOOST_TEST_MESSAGE("Cli get_son and update_son Test"); + + son_test_helper sth(*this); + sth.create_son("sonmember", "http://sonmember"); + + auto sonmember_acct = con.wallet_api_ptr->get_account("sonmember"); + + // get_son + auto son_data = con.wallet_api_ptr->get_son("sonmember"); + BOOST_CHECK(son_data.url == "http://sonmember"); + BOOST_CHECK(son_data.son_account == sonmember_acct.get_id()); + + // update SON + con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", true); + son_data = con.wallet_api_ptr->get_son("sonmember"); + BOOST_CHECK(son_data.url == "http://sonmember_updated"); + + // update SON signing key + con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated2", "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG", true); + son_data = con.wallet_api_ptr->get_son("sonmember"); + BOOST_CHECK(son_data.url == "http://sonmember_updated2"); + BOOST_CHECK(std::string(son_data.signing_key) == "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG"); + + } catch( fc::exception& e ) { + edump((e.to_detail_string())); + throw; + } +} + +BOOST_AUTO_TEST_CASE( son_voting ) +{ + BOOST_TEST_MESSAGE("SON Vote cli wallet tests begin"); + try + { + son_test_helper sth(*this); + sth.create_son("son1account", "http://son1"); + sth.create_son("son2account", "http://son2"); + + BOOST_TEST_MESSAGE("Voting for SONs"); + + son_object son1_obj; + son_object son2_obj; + signed_transaction vote_son1_tx; + signed_transaction vote_son2_tx; + int son1_start_votes, son1_end_votes; + int son2_start_votes, son2_end_votes; + + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_start_votes = son1_obj.total_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_start_votes = son2_obj.total_votes; + + // Vote for a son1account + BOOST_TEST_MESSAGE("Voting for son1account"); + vote_son1_tx = con.wallet_api_ptr->vote_for_son("nathan", "son1account", true, true); + BOOST_CHECK(generate_maintenance_block()); + + // Verify that the vote is there + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes > son1_start_votes); + + // Vote for a son2account + BOOST_TEST_MESSAGE("Voting for son2account"); + vote_son2_tx = con.wallet_api_ptr->vote_for_son("nathan", "son2account", true, true); + BOOST_CHECK(generate_maintenance_block()); + + // Verify that the vote is there + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes > son2_start_votes); + + // Withdraw vote for a son1account + BOOST_TEST_MESSAGE("Withdraw vote for a son1account"); + vote_son1_tx = con.wallet_api_ptr->vote_for_son("nathan", "son1account", false, true); + BOOST_CHECK(generate_maintenance_block()); + + // Verify that the vote is removed + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes == son1_start_votes); + + // Withdraw vote for a son2account + BOOST_TEST_MESSAGE("Withdraw vote for a son2account"); + vote_son2_tx = con.wallet_api_ptr->vote_for_son("nathan", "son2account", false, true); + BOOST_CHECK(generate_maintenance_block()); + + // Verify that the vote is removed + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes == son2_start_votes); + + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("SON Vote cli wallet tests end"); +} + +BOOST_AUTO_TEST_CASE( delete_son ) +{ + BOOST_TEST_MESSAGE("SON delete cli wallet tests begin"); + try + { + son_test_helper sth(*this); + sth.create_son("son1account", "http://son1"); + sth.create_son("son2account", "http://son2"); + + BOOST_TEST_MESSAGE("Deleting SONs"); + signed_transaction delete_tx; + auto _db = app1->chain_database(); + BOOST_CHECK(_db->get_index_type().indices().size() == 2); + delete_tx = con.wallet_api_ptr->delete_son("son1account", "true"); + delete_tx = con.wallet_api_ptr->delete_son("son2account", "true"); + BOOST_CHECK(generate_maintenance_block()); + BOOST_CHECK(_db->get_index_type().indices().size() == 0); + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("SON delete cli wallet tests end"); +} + + +BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture ) +{ + BOOST_TEST_MESSAGE("SON cli wallet tests begin"); + try + { + son_test_helper sth(*this); + + graphene::wallet::brain_key_info bki; + signed_transaction create_tx; + signed_transaction transfer_tx; + signed_transaction upgrade_tx; + signed_transaction vote_tx; + account_object acc_before_upgrade, acc_after_upgrade; + son_object son_obj; + global_property_object gpo; + + gpo = con.wallet_api_ptr->get_global_properties(); + unsigned int son_number = gpo.parameters.maximum_son_count; + + // create son accounts + for(unsigned int i = 0; i < son_number + 1; i++) + { + sth.create_son("sonaccount" + fc::to_pretty_string(i), + "http://son" + fc::to_pretty_string(i), false); + } + BOOST_CHECK(generate_maintenance_block()); + + BOOST_TEST_MESSAGE("Voting for SONs"); + for(unsigned int i = 0; i < son_number + 1; i++) + { + std::string name = "sonaccount" + fc::to_pretty_string(i); + vote_tx = con.wallet_api_ptr->vote_for_son(name, name, true, true); + } + BOOST_CHECK(generate_maintenance_block()); + + for(unsigned int i = 0; i < son_number; i++) + { + std::string name1 = "sonaccount" + fc::to_pretty_string(i); + std::string name2 = "sonaccount" + fc::to_pretty_string(i + 1); + vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, true, true); + } + gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); + BOOST_CHECK(generate_maintenance_block()); + gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); + + for(unsigned int i = 0; i < son_number - 1; i++) + { + std::string name1 = "sonaccount" + fc::to_pretty_string(i + 2); + std::string name2 = "sonaccount" + fc::to_pretty_string(i); + vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, true, true); + } + gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); + BOOST_CHECK(generate_maintenance_block()); + gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); + + for(unsigned int i = 0; i < son_number - 2; i++) + { + std::string name1 = "sonaccount" + fc::to_pretty_string(i + 3); + std::string name2 = "sonaccount" + fc::to_pretty_string(i); + vote_tx = con.wallet_api_ptr->vote_for_son(name1, name2, true, true); + } + gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_TEST_MESSAGE("gpo: " << gpo.active_sons.size()); + BOOST_CHECK(generate_maintenance_block()); + + BOOST_CHECK(gpo.active_sons.size() == 15); + + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("SON cli wallet tests end"); +} + +BOOST_AUTO_TEST_CASE( list_son ) +{ + BOOST_TEST_MESSAGE("List SONs cli wallet tests begin"); + try + { + son_test_helper sth(*this); + sth.create_son("son1account", "http://son1"); + sth.create_son("son2account", "http://son2"); + + auto res = con.wallet_api_ptr->list_sons("", 100); + BOOST_REQUIRE(res.size() == 2); + BOOST_CHECK(res.find("son1account") != res.end()); + BOOST_CHECK(res.find("son2account") != res.end()); + + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("List SONs cli wallet tests end"); +} + +BOOST_AUTO_TEST_CASE( update_son_votes_test ) +{ + BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests begin"); + try + { + son_test_helper sth(*this); + sth.create_son("son1account", "http://son1"); + sth.create_son("son2account", "http://son2"); + + BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes"); + + son_object son1_obj; + son_object son2_obj; + int son1_start_votes, son1_end_votes; + int son2_start_votes, son2_end_votes; + + // Get votes at start + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_start_votes = son1_obj.total_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_start_votes = son2_obj.total_votes; + + std::vector accepted; + std::vector rejected; + signed_transaction update_votes_tx; + + // Vote for both SONs + accepted.clear(); + rejected.clear(); + accepted.push_back("son1account"); + accepted.push_back("son2account"); + update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, + rejected, 15, true); + BOOST_CHECK(generate_block()); + BOOST_CHECK(generate_maintenance_block()); + + // Verify the votes + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes > son1_start_votes); + son1_start_votes = son1_end_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes > son2_start_votes); + son2_start_votes = son2_end_votes; + + + // Withdraw vote for SON 1 + accepted.clear(); + rejected.clear(); + rejected.push_back("son1account"); + update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, + rejected, 15, true); + BOOST_CHECK(generate_maintenance_block()); + + // Verify the votes + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes < son1_start_votes); + son1_start_votes = son1_end_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + // voice distribution changed, SON2 now has all voices + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes > son2_start_votes); + son2_start_votes = son2_end_votes; + + // Try to reject incorrect SON + accepted.clear(); + rejected.clear(); + rejected.push_back("son1accnt"); + BOOST_CHECK_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, + rejected, 15, true), fc::exception); + BOOST_CHECK(generate_block()); + + // Verify the votes + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes == son1_start_votes); + son1_start_votes = son1_end_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes == son2_start_votes); + son2_start_votes = son2_end_votes; + + // Reject SON2 + accepted.clear(); + rejected.clear(); + rejected.push_back("son2account"); + update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, + rejected, 15, true); + BOOST_CHECK(generate_maintenance_block()); + + // Verify the votes + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes == son1_start_votes); + son1_start_votes = son1_end_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes < son2_start_votes); + son2_start_votes = son2_end_votes; + + // Try to accept and reject the same SON + accepted.clear(); + rejected.clear(); + rejected.push_back("son1accnt"); + accepted.push_back("son1accnt"); + BOOST_REQUIRE_THROW(update_votes_tx = con.wallet_api_ptr->update_son_votes("nathan", accepted, + rejected, 15, true), fc::exception); + BOOST_CHECK(generate_maintenance_block()); + + // Verify the votes + son1_obj = con.wallet_api_ptr->get_son("son1account"); + son1_end_votes = son1_obj.total_votes; + BOOST_CHECK(son1_end_votes == son1_start_votes); + son1_start_votes = son1_end_votes; + son2_obj = con.wallet_api_ptr->get_son("son2account"); + son2_end_votes = son2_obj.total_votes; + BOOST_CHECK(son2_end_votes == son2_start_votes); + son2_start_votes = son2_end_votes; + + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests end"); +} + +BOOST_AUTO_TEST_CASE( related_functions ) +{ + BOOST_TEST_MESSAGE("SON-related functions cli wallet tests begin"); + try + { + global_property_object gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_CHECK(gpo.active_sons.size() == 0); + + son_test_helper sth(*this); + sth.create_son("son1account", "http://son1"); + sth.create_son("son2account", "http://son2"); + + gpo = con.wallet_api_ptr->get_global_properties(); + BOOST_CHECK(gpo.active_sons.size() == 2); + + } catch( fc::exception& e ) { + BOOST_TEST_MESSAGE("SON cli wallet tests exception"); + edump((e.to_detail_string())); + throw; + } + BOOST_TEST_MESSAGE("SON-related functions cli wallet tests end"); +} + + +BOOST_AUTO_TEST_SUITE_END() + + +