Compare commits

...

1 commit

Author SHA1 Message Date
Srdjan Obucina
e3ba9192d4 Extend SON objects to contain sidechain public keys 2019-12-23 00:42:06 +01:00
8 changed files with 132 additions and 31 deletions

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <graphene/chain/protocol/base.hpp> #include <graphene/chain/protocol/base.hpp>
#include <graphene/peerplays_sidechain/defs.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
@ -12,6 +13,7 @@ namespace graphene { namespace chain {
std::string url; std::string url;
vesting_balance_id_type deposit; vesting_balance_id_type deposit;
public_key_type signing_key; public_key_type signing_key;
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
vesting_balance_id_type pay_vb; vesting_balance_id_type pay_vb;
account_id_type fee_payer()const { return owner_account; } account_id_type fee_payer()const { return owner_account; }
@ -28,6 +30,7 @@ namespace graphene { namespace chain {
optional<std::string> new_url; optional<std::string> new_url;
optional<vesting_balance_id_type> new_deposit; optional<vesting_balance_id_type> new_deposit;
optional<public_key_type> new_signing_key; optional<public_key_type> new_signing_key;
optional<flat_map<peerplays_sidechain::sidechain_type, string>> new_sidechain_public_keys;
optional<vesting_balance_id_type> new_pay_vb; optional<vesting_balance_id_type> new_pay_vb;
account_id_type fee_payer()const { return owner_account; } account_id_type fee_payer()const { return owner_account; }
@ -63,12 +66,12 @@ namespace graphene { namespace chain {
} } // namespace graphene::chain } } // namespace graphene::chain
FC_REFLECT(graphene::chain::son_create_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_create_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(deposit)(signing_key) FC_REFLECT(graphene::chain::son_create_operation, (fee)(owner_account)(url)(deposit)(signing_key)(sidechain_public_keys)
(pay_vb) ) (pay_vb) )
FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_update_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit) FC_REFLECT(graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url)(new_deposit)
(new_signing_key)(new_pay_vb) ) (new_signing_key)(new_sidechain_public_keys)(new_pay_vb) )
FC_REFLECT(graphene::chain::son_delete_operation::fee_parameters_type, (fee) ) FC_REFLECT(graphene::chain::son_delete_operation::fee_parameters_type, (fee) )
FC_REFLECT(graphene::chain::son_delete_operation, (fee)(son_id)(payer)(owner_account) ) FC_REFLECT(graphene::chain::son_delete_operation, (fee)(son_id)(payer)(owner_account) )

View file

@ -2,6 +2,7 @@
#include <graphene/chain/protocol/types.hpp> #include <graphene/chain/protocol/types.hpp>
#include <graphene/db/object.hpp> #include <graphene/db/object.hpp>
#include <graphene/db/generic_index.hpp> #include <graphene/db/generic_index.hpp>
#include <graphene/peerplays_sidechain/defs.hpp>
namespace graphene { namespace chain { namespace graphene { namespace chain {
using namespace graphene::db; using namespace graphene::db;
@ -60,6 +61,7 @@ namespace graphene { namespace chain {
vesting_balance_id_type pay_vb; vesting_balance_id_type pay_vb;
son_statistics_id_type statistics; son_statistics_id_type statistics;
son_status status = son_status::inactive; son_status status = son_status::inactive;
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
void pay_son_fee(share_type pay, database& db); void pay_son_fee(share_type pay, database& db);
}; };
@ -95,7 +97,7 @@ namespace graphene { namespace chain {
FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(in_maintenance)(deregistered) ) FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(in_maintenance)(deregistered) )
FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object), FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object),
(son_account)(vote_id)(total_votes)(url)(deposit)(signing_key)(pay_vb) ) (son_account)(vote_id)(total_votes)(url)(deposit)(signing_key)(pay_vb)(sidechain_public_keys) )
FC_REFLECT_DERIVED( graphene::chain::son_statistics_object, FC_REFLECT_DERIVED( graphene::chain::son_statistics_object,
(graphene::db::object), (graphene::db::object),

View file

@ -30,6 +30,7 @@ object_id_type create_son_evaluator::do_apply(const son_create_operation& op)
obj.url = op.url; obj.url = op.url;
obj.deposit = op.deposit; obj.deposit = op.deposit;
obj.signing_key = op.signing_key; obj.signing_key = op.signing_key;
obj.sidechain_public_keys = op.sidechain_public_keys;
obj.pay_vb = op.pay_vb; obj.pay_vb = op.pay_vb;
obj.statistics = db().create<son_statistics_object>([&](son_statistics_object& s){s.owner = obj.id;}).id; obj.statistics = db().create<son_statistics_object>([&](son_statistics_object& s){s.owner = obj.id;}).id;
}); });
@ -55,6 +56,7 @@ object_id_type update_son_evaluator::do_apply(const son_update_operation& op)
if(op.new_url.valid()) so.url = *op.new_url; if(op.new_url.valid()) so.url = *op.new_url;
if(op.new_deposit.valid()) so.deposit = *op.new_deposit; if(op.new_deposit.valid()) so.deposit = *op.new_deposit;
if(op.new_signing_key.valid()) so.signing_key = *op.new_signing_key; if(op.new_signing_key.valid()) so.signing_key = *op.new_signing_key;
if(op.new_sidechain_public_keys.valid()) so.sidechain_public_keys = *op.new_sidechain_public_keys;
if(op.new_pay_vb.valid()) so.pay_vb = *op.new_pay_vb; if(op.new_pay_vb.valid()) so.pay_vb = *op.new_pay_vb;
}); });
} }

View file

@ -10,8 +10,9 @@ namespace graphene { namespace peerplays_sidechain {
enum class sidechain_type { enum class sidechain_type {
bitcoin, bitcoin,
//ethereum, ethereum,
//eos eos,
peerplays
}; };
using bytes = std::vector<char>; using bytes = std::vector<char>;
@ -69,4 +70,4 @@ struct sidechain_event_data {
} } // graphene::peerplays_sidechain } } // graphene::peerplays_sidechain
FC_REFLECT_ENUM(graphene::peerplays_sidechain::sidechain_type, (bitcoin) ) FC_REFLECT_ENUM(graphene::peerplays_sidechain::sidechain_type, (bitcoin)(ethereum)(eos)(peerplays) )

View file

@ -1312,6 +1312,7 @@ class wallet_api
* display this when showing a list of SONs. May be blank. * display this when showing a list of SONs. May be blank.
* @param deposit_id vesting balance id for SON deposit * @param deposit_id vesting balance id for SON deposit
* @param pay_vb_id vesting balance id for SON pay_vb * @param pay_vb_id vesting balance id for SON pay_vb
* @param sidechain_public_keys The new set of sidechain public keys.
* @param broadcast true to broadcast the transaction on the network * @param broadcast true to broadcast the transaction on the network
* @returns the signed transaction registering a SON * @returns the signed transaction registering a SON
*/ */
@ -1319,6 +1320,7 @@ class wallet_api
string url, string url,
vesting_balance_id_type deposit_id, vesting_balance_id_type deposit_id,
vesting_balance_id_type pay_vb_id, vesting_balance_id_type pay_vb_id,
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
bool broadcast = false); bool broadcast = false);
/** /**
@ -1327,11 +1329,13 @@ class wallet_api
* @param witness The name of the SON's owner account. Also accepts the ID of the owner account or the ID of the SON. * @param witness The name of the SON's owner account. Also accepts the ID of the owner account or the ID of the SON.
* @param url Same as for create_son. The empty string makes it remain the same. * @param url Same as for create_son. The empty string makes it remain the same.
* @param block_signing_key The new block signing public key. The empty string makes it remain the same. * @param block_signing_key The new block signing public key. The empty string makes it remain the same.
* @param sidechain_public_keys The new set of sidechain public keys. The empty string makes it remain the same.
* @param broadcast true if you wish to broadcast the transaction. * @param broadcast true if you wish to broadcast the transaction.
*/ */
signed_transaction update_son(string owner_account, signed_transaction update_son(string owner_account,
string url, string url,
string block_signing_key, string block_signing_key,
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
bool broadcast = false); bool broadcast = false);

View file

@ -1863,6 +1863,7 @@ public:
string url, string url,
vesting_balance_id_type deposit_id, vesting_balance_id_type deposit_id,
vesting_balance_id_type pay_vb_id, vesting_balance_id_type pay_vb_id,
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
bool broadcast /* = false */) bool broadcast /* = false */)
{ try { { try {
account_object son_account = get_account(owner_account); account_object son_account = get_account(owner_account);
@ -1877,6 +1878,7 @@ public:
son_create_op.url = url; son_create_op.url = url;
son_create_op.deposit = deposit_id; son_create_op.deposit = deposit_id;
son_create_op.pay_vb = pay_vb_id; son_create_op.pay_vb = pay_vb_id;
son_create_op.sidechain_public_keys = sidechain_public_keys;
if (_remote_db->get_son_by_account(son_create_op.owner_account)) 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)); FC_THROW("Account ${owner_account} is already a SON", ("owner_account", owner_account));
@ -1894,6 +1896,7 @@ public:
signed_transaction update_son(string owner_account, signed_transaction update_son(string owner_account,
string url, string url,
string block_signing_key, string block_signing_key,
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
bool broadcast /* = false */) bool broadcast /* = false */)
{ try { { try {
son_object son = get_son(owner_account); son_object son = get_son(owner_account);
@ -1906,6 +1909,9 @@ public:
if( block_signing_key != "" ) { if( block_signing_key != "" ) {
son_update_op.new_signing_key = public_key_type( block_signing_key ); son_update_op.new_signing_key = public_key_type( block_signing_key );
} }
if( !sidechain_public_keys.empty() ) {
son_update_op.new_sidechain_public_keys = sidechain_public_keys;
}
signed_transaction tx; signed_transaction tx;
tx.operations.push_back( son_update_op ); tx.operations.push_back( son_update_op );
@ -4369,17 +4375,19 @@ signed_transaction wallet_api::create_son(string owner_account,
string url, string url,
vesting_balance_id_type deposit_id, vesting_balance_id_type deposit_id,
vesting_balance_id_type pay_vb_id, vesting_balance_id_type pay_vb_id,
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->create_son(owner_account, url, deposit_id, pay_vb_id, broadcast); return my->create_son(owner_account, url, deposit_id, pay_vb_id, sidechain_public_keys, broadcast);
} }
signed_transaction wallet_api::update_son(string owner_account, signed_transaction wallet_api::update_son(string owner_account,
string url, string url,
string block_signing_key, string block_signing_key,
flat_map<peerplays_sidechain::sidechain_type, string> sidechain_public_keys,
bool broadcast /* = false */) bool broadcast /* = false */)
{ {
return my->update_son(owner_account, url, block_signing_key, broadcast); return my->update_son(owner_account, url, block_signing_key, sidechain_public_keys, broadcast);
} }
signed_transaction wallet_api::delete_son(string owner_account, signed_transaction wallet_api::delete_son(string owner_account,

View file

@ -40,6 +40,7 @@ public:
} }
void create_son(const std::string& account_name, const std::string& son_url, void create_son(const std::string& account_name, const std::string& son_url,
flat_map<graphene::peerplays_sidechain::sidechain_type, string>& sidechain_public_keys,
bool generate_maintenance = true) bool generate_maintenance = true)
{ {
graphene::wallet::brain_key_info bki; graphene::wallet::brain_key_info bki;
@ -92,6 +93,7 @@ public:
create_tx = fixture_.con.wallet_api_ptr->create_son(account_name, son_url, create_tx = fixture_.con.wallet_api_ptr->create_son(account_name, son_url,
deposits[0].id, deposits[1].id, deposits[0].id, deposits[1].id,
sidechain_public_keys,
true); true);
if (generate_maintenance) if (generate_maintenance)
@ -110,9 +112,17 @@ BOOST_AUTO_TEST_CASE( create_sons )
BOOST_TEST_MESSAGE("SON cli wallet tests begin"); BOOST_TEST_MESSAGE("SON cli wallet tests begin");
try try
{ {
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
son_test_helper sth(*this); son_test_helper sth(*this);
sth.create_son("son1account", "http://son1");
sth.create_son("son2account", "http://son2"); sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
sth.create_son("son1account", "http://son1", sidechain_public_keys);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
sth.create_son("son2account", "http://son2", sidechain_public_keys);
auto son1_obj = con.wallet_api_ptr->get_son("son1account"); 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(son1_obj.son_account == con.wallet_api_ptr->get_account_id("son1account"));
@ -136,8 +146,13 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
{ {
BOOST_TEST_MESSAGE("Cli get_son and update_son Test"); BOOST_TEST_MESSAGE("Cli get_son and update_son Test");
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
son_test_helper sth(*this); son_test_helper sth(*this);
sth.create_son("sonmember", "http://sonmember"); sth.create_son("sonmember", "http://sonmember", sidechain_public_keys);
auto sonmember_acct = con.wallet_api_ptr->get_account("sonmember"); auto sonmember_acct = con.wallet_api_ptr->get_account("sonmember");
@ -147,12 +162,16 @@ BOOST_AUTO_TEST_CASE( cli_update_son )
BOOST_CHECK(son_data.son_account == sonmember_acct.get_id()); BOOST_CHECK(son_data.son_account == sonmember_acct.get_id());
// update SON // update SON
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", true); sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated", "", sidechain_public_keys, true);
son_data = con.wallet_api_ptr->get_son("sonmember"); son_data = con.wallet_api_ptr->get_son("sonmember");
BOOST_CHECK(son_data.url == "http://sonmember_updated"); BOOST_CHECK(son_data.url == "http://sonmember_updated");
// update SON signing key // update SON signing key
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated2", "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG", true); sidechain_public_keys.clear();
con.wallet_api_ptr->update_son("sonmember", "http://sonmember_updated2", "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG", sidechain_public_keys, true);
son_data = con.wallet_api_ptr->get_son("sonmember"); son_data = con.wallet_api_ptr->get_son("sonmember");
BOOST_CHECK(son_data.url == "http://sonmember_updated2"); BOOST_CHECK(son_data.url == "http://sonmember_updated2");
BOOST_CHECK(std::string(son_data.signing_key) == "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG"); BOOST_CHECK(std::string(son_data.signing_key) == "TEST6Yaq5ZNTTkMM2kBBzV5jktr8ETsniCC3bnVD7eFmegRrLXfGGG");
@ -168,9 +187,17 @@ BOOST_AUTO_TEST_CASE( son_voting )
BOOST_TEST_MESSAGE("SON Vote cli wallet tests begin"); BOOST_TEST_MESSAGE("SON Vote cli wallet tests begin");
try try
{ {
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
son_test_helper sth(*this); son_test_helper sth(*this);
sth.create_son("son1account", "http://son1");
sth.create_son("son2account", "http://son2"); sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
sth.create_son("son1account", "http://son1", sidechain_public_keys);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
sth.create_son("son2account", "http://son2", sidechain_public_keys);
BOOST_TEST_MESSAGE("Voting for SONs"); BOOST_TEST_MESSAGE("Voting for SONs");
@ -239,9 +266,17 @@ BOOST_AUTO_TEST_CASE( delete_son )
BOOST_TEST_MESSAGE("SON delete cli wallet tests begin"); BOOST_TEST_MESSAGE("SON delete cli wallet tests begin");
try try
{ {
son_test_helper sth(*this); flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
sth.create_son("son1account", "http://son1");
sth.create_son("son2account", "http://son2"); son_test_helper sth(*this);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
sth.create_son("son1account", "http://son1", sidechain_public_keys);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
sth.create_son("son2account", "http://son2", sidechain_public_keys);
BOOST_TEST_MESSAGE("Deleting SONs"); BOOST_TEST_MESSAGE("Deleting SONs");
signed_transaction delete_tx; signed_transaction delete_tx;
@ -279,11 +314,17 @@ BOOST_FIXTURE_TEST_CASE( select_top_fifteen_sons, cli_fixture )
gpo = con.wallet_api_ptr->get_global_properties(); gpo = con.wallet_api_ptr->get_global_properties();
unsigned int son_number = gpo.parameters.maximum_son_count; unsigned int son_number = gpo.parameters.maximum_son_count;
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
// create son accounts // create son accounts
for(unsigned int i = 0; i < son_number + 1; i++) for(unsigned int i = 0; i < son_number + 1; i++)
{ {
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
sth.create_son("sonaccount" + fc::to_pretty_string(i), sth.create_son("sonaccount" + fc::to_pretty_string(i),
"http://son" + fc::to_pretty_string(i), false); "http://son" + fc::to_pretty_string(i),
sidechain_public_keys,
false);
} }
BOOST_CHECK(generate_maintenance_block()); BOOST_CHECK(generate_maintenance_block());
@ -344,9 +385,17 @@ BOOST_AUTO_TEST_CASE( list_son )
BOOST_TEST_MESSAGE("List SONs cli wallet tests begin"); BOOST_TEST_MESSAGE("List SONs cli wallet tests begin");
try try
{ {
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
son_test_helper sth(*this); son_test_helper sth(*this);
sth.create_son("son1account", "http://son1");
sth.create_son("son2account", "http://son2"); sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
sth.create_son("son1account", "http://son1", sidechain_public_keys);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
sth.create_son("son2account", "http://son2", sidechain_public_keys);
auto res = con.wallet_api_ptr->list_sons("", 100); auto res = con.wallet_api_ptr->list_sons("", 100);
BOOST_REQUIRE(res.size() == 2); BOOST_REQUIRE(res.size() == 2);
@ -366,9 +415,17 @@ BOOST_AUTO_TEST_CASE( update_son_votes_test )
BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests begin"); BOOST_TEST_MESSAGE("SON update_son_votes cli wallet tests begin");
try try
{ {
son_test_helper sth(*this); flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
sth.create_son("son1account", "http://son1");
sth.create_son("son2account", "http://son2"); son_test_helper sth(*this);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
sth.create_son("son1account", "http://son1", sidechain_public_keys);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
sth.create_son("son2account", "http://son2", sidechain_public_keys);
BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes"); BOOST_TEST_MESSAGE("Vote for 2 accounts with update_son_votes");
@ -515,9 +572,17 @@ BOOST_AUTO_TEST_CASE( related_functions )
global_property_object gpo = con.wallet_api_ptr->get_global_properties(); global_property_object gpo = con.wallet_api_ptr->get_global_properties();
BOOST_CHECK(gpo.active_sons.size() == 0); BOOST_CHECK(gpo.active_sons.size() == 0);
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
son_test_helper sth(*this); son_test_helper sth(*this);
sth.create_son("son1account", "http://son1");
sth.create_son("son2account", "http://son2"); sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 1";
sth.create_son("son1account", "http://son1", sidechain_public_keys);
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address 2";
sth.create_son("son2account", "http://son2", sidechain_public_keys);
gpo = con.wallet_api_ptr->get_global_properties(); gpo = con.wallet_api_ptr->get_global_properties();
BOOST_CHECK(gpo.active_sons.size() == 2); BOOST_CHECK(gpo.active_sons.size() == 2);
@ -543,11 +608,17 @@ BOOST_FIXTURE_TEST_CASE( cli_list_active_sons, cli_fixture )
gpo = con.wallet_api_ptr->get_global_properties(); gpo = con.wallet_api_ptr->get_global_properties();
unsigned int son_number = gpo.parameters.maximum_son_count; unsigned int son_number = gpo.parameters.maximum_son_count;
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
// create son accounts // create son accounts
for(unsigned int i = 0; i < son_number + 1; i++) for(unsigned int i = 0; i < son_number + 1; i++)
{ {
sidechain_public_keys.clear();
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin_address " + fc::to_pretty_string(i);
sth.create_son("sonaccount" + fc::to_pretty_string(i), sth.create_son("sonaccount" + fc::to_pretty_string(i),
"http://son" + fc::to_pretty_string(i), false); "http://son" + fc::to_pretty_string(i),
sidechain_public_keys,
false);
} }
BOOST_CHECK(generate_maintenance_block()); BOOST_CHECK(generate_maintenance_block());

View file

@ -83,12 +83,16 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
// alice became son // alice became son
{ {
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "bitcoin address";
son_create_operation op; son_create_operation op;
op.owner_account = alice_id; op.owner_account = alice_id;
op.url = test_url; op.url = test_url;
op.deposit = deposit; op.deposit = deposit;
op.pay_vb = payment; op.pay_vb = payment;
op.signing_key = alice_public_key; op.signing_key = alice_public_key;
op.sidechain_public_keys = sidechain_public_keys;
trx.operations.push_back(op); trx.operations.push_back(op);
sign(trx, alice_private_key); sign(trx, alice_private_key);
PUSH_TX(db, trx, ~0); PUSH_TX(db, trx, ~0);
@ -101,6 +105,7 @@ BOOST_AUTO_TEST_CASE( create_son_test ) {
BOOST_REQUIRE( obj != idx.end() ); BOOST_REQUIRE( obj != idx.end() );
BOOST_CHECK( obj->url == test_url ); BOOST_CHECK( obj->url == test_url );
BOOST_CHECK( obj->signing_key == alice_public_key ); BOOST_CHECK( obj->signing_key == alice_public_key );
BOOST_CHECK( obj->sidechain_public_keys.at(graphene::peerplays_sidechain::sidechain_type::bitcoin) == "bitcoin address" );
BOOST_CHECK( obj->deposit.instance == deposit.instance.value ); BOOST_CHECK( obj->deposit.instance == deposit.instance.value );
BOOST_CHECK( obj->pay_vb.instance == payment.instance.value ); BOOST_CHECK( obj->pay_vb.instance == payment.instance.value );
} }
@ -113,10 +118,14 @@ BOOST_AUTO_TEST_CASE( update_son_test ) {
std::string new_url = "https://anewurl.com"; std::string new_url = "https://anewurl.com";
{ {
flat_map<graphene::peerplays_sidechain::sidechain_type, string> sidechain_public_keys;
sidechain_public_keys[graphene::peerplays_sidechain::sidechain_type::bitcoin] = "new bitcoin address";
son_update_operation op; son_update_operation op;
op.son_id = son_id_type(0);
op.owner_account = alice_id; op.owner_account = alice_id;
op.new_url = new_url; op.new_url = new_url;
op.son_id = son_id_type(0); op.new_sidechain_public_keys = sidechain_public_keys;
trx.operations.push_back(op); trx.operations.push_back(op);
sign(trx, alice_private_key); sign(trx, alice_private_key);
@ -129,6 +138,7 @@ BOOST_AUTO_TEST_CASE( update_son_test ) {
auto obj = idx.find( alice_id ); auto obj = idx.find( alice_id );
BOOST_REQUIRE( obj != idx.end() ); BOOST_REQUIRE( obj != idx.end() );
BOOST_CHECK( obj->url == new_url ); BOOST_CHECK( obj->url == new_url );
BOOST_CHECK( obj->sidechain_public_keys.at(graphene::peerplays_sidechain::sidechain_type::bitcoin) == "new bitcoin address" );
} }
BOOST_AUTO_TEST_CASE( delete_son_test ) { BOOST_AUTO_TEST_CASE( delete_son_test ) {