From d03bfa81f70da861cab3cc61415d2cefb23d90c1 Mon Sep 17 00:00:00 2001 From: gladcow Date: Sun, 8 Dec 2019 09:43:05 +0300 Subject: [PATCH 1/2] [SON-199] Fix unit tests (#233) * fix app_test * fix son_delete_test --- libraries/chain/son_evaluator.cpp | 1 + tests/CMakeLists.txt | 2 +- tests/app/main.cpp | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/chain/son_evaluator.cpp b/libraries/chain/son_evaluator.cpp index c54d1391..ad581348 100644 --- a/libraries/chain/son_evaluator.cpp +++ b/libraries/chain/son_evaluator.cpp @@ -83,6 +83,7 @@ void_result delete_son_evaluator::do_apply(const son_delete_operation& op) linear_vesting_policy new_vesting_policy; new_vesting_policy.begin_timestamp = db().head_block_time(); new_vesting_policy.vesting_cliff_seconds = db().get_global_properties().parameters.son_vesting_period(); + new_vesting_policy.begin_balance = deposit.balance.amount; db().modify(son->deposit(db()), [&new_vesting_policy](vesting_balance_object &vbo) { vbo.policy = new_vesting_policy; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 472da676..cf633dfd 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -23,7 +23,7 @@ target_link_libraries( chain_bench graphene_chain graphene_app graphene_account_ file(GLOB APP_SOURCES "app/*.cpp") add_executable( app_test ${APP_SOURCES} ) -target_link_libraries( app_test graphene_app graphene_account_history graphene_bookie graphene_net graphene_chain graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) +target_link_libraries( app_test graphene_app graphene_account_history graphene_witness graphene_bookie graphene_net graphene_chain graphene_egenesis_none fc ${PLATFORM_SPECIFIC_LIBS} ) file(GLOB INTENSE_SOURCES "intense/*.cpp") add_executable( intense_test ${INTENSE_SOURCES} ${COMMON_SOURCES} ) diff --git a/tests/app/main.cpp b/tests/app/main.cpp index 98f19c19..b3775b1f 100644 --- a/tests/app/main.cpp +++ b/tests/app/main.cpp @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include @@ -57,6 +59,8 @@ BOOST_AUTO_TEST_CASE( two_node_network ) graphene::app::application app1; app1.register_plugin(); + app1.register_plugin(); + app1.register_plugin(); boost::program_options::variables_map cfg; cfg.emplace("p2p-endpoint", boost::program_options::variable_value(string("127.0.0.1:0"), false)); app1.initialize(app_dir.path(), cfg); @@ -72,6 +76,8 @@ BOOST_AUTO_TEST_CASE( two_node_network ) graphene::app::application app2; app2.register_plugin(); + app2.register_plugin(); + app2.register_plugin(); cfg2.erase("p2p-endpoint"); cfg2.emplace("p2p-endpoint", boost::program_options::variable_value(string("127.0.0.1:0"), false)); cfg2.emplace("seed-node", boost::program_options::variable_value(vector{endpoint1}, false)); From 876bbc8c6d87b62fdeeaa7de864b77227494639a Mon Sep 17 00:00:00 2001 From: obucinac Date: Wed, 11 Dec 2019 14:58:47 +0100 Subject: [PATCH 2/2] Add peerplays account for a SON in a config/command line options (#231) --- .../peerplays_sidechain_plugin.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp index 9b993614..50739bef 100644 --- a/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp +++ b/libraries/plugins/peerplays_sidechain/peerplays_sidechain_plugin.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace bpo = boost::program_options; @@ -51,15 +52,15 @@ void peerplays_sidechain_plugin::plugin_set_program_options( boost::program_options::options_description& cfg ) { + auto default_priv_key = fc::ecc::private_key::regenerate(fc::sha256::hash(std::string("nathan"))); + string son_id_example = fc::json::to_string(chain::son_id_type(5)); + cli.add_options() - //("bitcoin-node-ip", bpo::value()->implicit_value("127.0.0.1"), "IP address of Bitcoin node") - //("bitcoin-node-zmq-port", bpo::value()->implicit_value(28332), "ZMQ port of Bitcoin node") - //("bitcoin-node-rpc-port", bpo::value()->implicit_value(18332), "RPC port of Bitcoin node") - //("bitcoin-node-rpc-user", bpo::value(), "Bitcoin RPC user") - //("bitcoin-node-rpc-password", bpo::value(), "Bitcoin RPC password") - //("bitcoin-address", bpo::value(), "Bitcoin address") - //("bitcoin-public-key", bpo::value(), "Bitcoin public key") - //("bitcoin-private-key", bpo::value(), "Bitcoin private key") + ("son-id,w", bpo::value>(), ("ID of SON controlled by this node (e.g. " + son_id_example + ", quotes are required)").c_str()) + ("peerplays-private-key", bpo::value>()->composing()->multitoken()-> + DEFAULT_VALUE_VECTOR(std::make_pair(chain::public_key_type(default_priv_key.get_public_key()), graphene::utilities::key_to_wif(default_priv_key))), + "Tuple of [PublicKey, WIF private key]") + ("bitcoin-node-ip", bpo::value()->default_value("99.79.189.95"), "IP address of Bitcoin node") ("bitcoin-node-zmq-port", bpo::value()->default_value(11111), "ZMQ port of Bitcoin node") ("bitcoin-node-rpc-port", bpo::value()->default_value(22222), "RPC port of Bitcoin node")