diff --git a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp index 9f9468c5..b8aa07c6 100644 --- a/libraries/chain/include/graphene/chain/sidechain_address_object.hpp +++ b/libraries/chain/include/graphene/chain/sidechain_address_object.hpp @@ -59,23 +59,24 @@ namespace graphene { namespace chain { ordered_unique< tag, composite_key, - member, + member, member + > >, ordered_non_unique< tag, - member + member >, - ordered_unique< tag, + ordered_non_unique< tag, composite_key, member, member > >, - ordered_unique< tag, + ordered_non_unique< tag, composite_key, - member, + member, member > > @@ -88,4 +89,4 @@ namespace graphene { namespace chain { FC_REFLECT_DERIVED( graphene::chain::sidechain_address_object, (graphene::db::object), (sidechain_address_account) (sidechain) (deposit_public_key) (deposit_address) (deposit_address_data) - (withdraw_public_key) (withdraw_address) ) + (withdraw_public_key) (withdraw_address) (valid_from) (expires) ) diff --git a/libraries/chain/sidechain_address_evaluator.cpp b/libraries/chain/sidechain_address_evaluator.cpp index 8ad87614..8f136bf7 100644 --- a/libraries/chain/sidechain_address_evaluator.cpp +++ b/libraries/chain/sidechain_address_evaluator.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -16,11 +17,12 @@ void_result add_sidechain_address_evaluator::do_evaluate(const sidechain_address object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address_add_operation& op) { try { - const auto &sidechain_addresses_idx = database.get_index_type().indices().get(); - const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sed.peerplays_from, op.sidechain, time_point_sec::maximum())); + const auto &sidechain_addresses_idx = db().get_index_type().indices().get(); + const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(op.sidechain_address_account, op.sidechain, time_point_sec::maximum())); + if (addr_itr != sidechain_addresses_idx.end()) { - db().modify(*addr_itr, [&op](sidechain_address_object &sao) { + db().modify(*addr_itr, [&](sidechain_address_object &sao) { sao.expires = db().head_block_time(); }); } @@ -41,13 +43,13 @@ object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address void_result update_sidechain_address_evaluator::do_evaluate(const sidechain_address_update_operation& op) { try { - const auto& sidx = _db.get_index_type().indices().get(); + const auto& sidx = db().get_index_type().indices().get(); const auto& son_obj = sidx.find(op.payer); FC_ASSERT( son_obj != sidx.end() && db().is_son_active(son_obj->id), "Non active SON trying to update deposit address object" ); const auto& sdpke_idx = db().get_index_type().indices().get(); FC_ASSERT( op.deposit_address.valid() && op.deposit_public_key.valid() && op.deposit_address_data.valid(), "Update operation by SON is not valid"); - FC_ASSERT( op->deposit_address.length() > 0 && op->deposit_public_key.length() > 0 && op->deposit_address_data.length() > 0, "SON should create a valid deposit address with valid deposit public key"); - FC_ASSERT( sdpke_idx.find(boost::make_tuple(op.sidechain, op.deposit_public_key, time_point_sec::maximum())) != sdpke_idx.end(), "Invalid update operation by SON" ); + FC_ASSERT( (*op.deposit_address).length() > 0 && (*op.deposit_public_key).length() > 0 && (*op.deposit_address_data).length() > 0, "SON should create a valid deposit address with valid deposit public key"); + FC_ASSERT( sdpke_idx.find(boost::make_tuple(op.sidechain, *op.deposit_public_key, time_point_sec::maximum())) != sdpke_idx.end(), "Invalid update operation by SON" ); FC_ASSERT( db().get(op.sidechain_address_id).sidechain_address_account == op.sidechain_address_account, "Invalid sidechain address account" ); const auto& idx = db().get_index_type().indices().get(); FC_ASSERT( idx.find(op.sidechain_address_id) != idx.end(), "Invalid sidechain address ID" ); @@ -65,15 +67,15 @@ object_id_type update_sidechain_address_evaluator::do_apply(const sidechain_addr const auto& new_sidechain_address_object = db().create( [&]( sidechain_address_object& obj ) { obj.sidechain_address_account = op.sidechain_address_account; obj.sidechain = op.sidechain; - obj.deposit_public_key = op.deposit_public_key; + obj.deposit_public_key = *op.deposit_public_key; obj.deposit_address = itr->deposit_address; obj.deposit_address_data = itr->deposit_address_data; - obj.withdraw_public_key = op.withdraw_public_key; - obj.withdraw_address = op.withdraw_address; + obj.withdraw_public_key = *op.withdraw_public_key; + obj.withdraw_address = *op.withdraw_address; obj.valid_from = itr->valid_from; obj.expires = db().head_block_time(); }); - db().modify(*itr, [&op](sidechain_address_object &sao) { + db().modify(*itr, [&](sidechain_address_object &sao) { if(op.deposit_address.valid()) sao.deposit_address = *op.deposit_address; if(op.deposit_address_data.valid()) sao.deposit_address_data = *op.deposit_address_data; sao.valid_from = db().head_block_time(); @@ -102,7 +104,7 @@ void_result delete_sidechain_address_evaluator::do_apply(const sidechain_address const auto& idx = db().get_index_type().indices().get(); auto sidechain_address = idx.find(op.sidechain_address_id); if(sidechain_address != idx.end()) { - db().modify(*sidechain_address, [](sidechain_address_object &sao) { + db().modify(*sidechain_address, [&](sidechain_address_object &sao) { sao.expires = db().head_block_time(); }); } diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler.hpp index 7f2a8b18..50dfd505 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler.hpp @@ -42,7 +42,6 @@ public: virtual bool process_proposal(const proposal_object &po) = 0; virtual void process_primary_wallet() = 0; virtual void process_sidechain_addresses() = 0; - virtual bool create_deposit_address(const sidechain_address_object &sao) = 0; virtual bool process_deposit(const son_wallet_deposit_object &swdo) = 0; virtual bool process_withdrawal(const son_wallet_withdraw_object &swwo) = 0; virtual std::string process_sidechain_transaction(const sidechain_transaction_object &sto) = 0; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp index 8b91f125..eb218a4c 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_bitcoin.hpp @@ -91,7 +91,6 @@ public: bool process_proposal(const proposal_object &po); void process_primary_wallet(); void process_sidechain_addresses(); - bool create_deposit_address(const sidechain_address_object &sao); bool process_deposit(const son_wallet_deposit_object &swdo); bool process_withdrawal(const son_wallet_withdraw_object &swwo); std::string process_sidechain_transaction(const sidechain_transaction_object &sto); diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_peerplays.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_peerplays.hpp index 934022e4..aa094d95 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_peerplays.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/sidechain_net_handler_peerplays.hpp @@ -16,7 +16,6 @@ public: bool process_proposal(const proposal_object &po); void process_primary_wallet(); void process_sidechain_addresses(); - bool create_deposit_address(const sidechain_address_object &sao); bool process_deposit(const son_wallet_deposit_object &swdo); bool process_withdrawal(const son_wallet_withdraw_object &swwo); std::string process_sidechain_transaction(const sidechain_transaction_object &sto); diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler.cpp index 7abdd323..ed404efe 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler.cpp @@ -356,31 +356,13 @@ void sidechain_net_handler::process_proposals() { void sidechain_net_handler::process_active_sons_change() { process_primary_wallet(); - process_sidechain_addresses(); } void sidechain_net_handler::create_deposit_addresses() { if (database.get_global_properties().active_sons.size() < database.get_chain_properties().immutable_parameters.min_son_count) { return; } - - const auto &idx = database.get_index_type().indices().get(); - const auto &idx_range = idx.equal_range(std::make_tuple(sidechain, "", time_point_sec::maximum())); - - std::for_each(idx_range.first, idx_range.second, [&](const sidechain_address_object &sao) { - if (sao.id == object_id_type(0, 0, 0)) { - return; - } - - ilog("sidechain deposit address to create: ${sao}", ("sao", sao)); - - bool create_address_result = create_deposit_address(sao); - - if (!create_address_result) { - wlog("Deposit address not created: ${sao}", ("sao", sao)); - return; - } - }); + process_sidechain_addresses(); } void sidechain_net_handler::process_deposits() { diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index 8e1c7d41..48f641c3 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -1384,49 +1384,6 @@ void sidechain_net_handler_bitcoin::process_sidechain_addresses() { }); } -bool sidechain_net_handler_bitcoin::create_deposit_address(const sidechain_address_object &sao) { - using namespace bitcoin; - - const chain::global_property_object &gpo = database.get_global_properties(); - std::vector> pubkeys; - for (auto &son : gpo.active_sons) { - std::string pub_key_str = son.sidechain_public_keys.at(sidechain_type::bitcoin); - auto pubkey = fc::ecc::public_key(create_public_key_data(parse_hex(pub_key_str))); - pubkeys.push_back(std::make_pair(pubkey, son.weight)); - } - - auto usr_pubkey = fc::ecc::public_key(create_public_key_data(parse_hex(sao.deposit_public_key))); - - btc_one_or_weighted_multisig_address addr(usr_pubkey, pubkeys, network_type); - std::string address_data = "{ \"redeemScript\": \"" + fc::to_hex(addr.get_redeem_script()) + - "\", \"witnessScript\": \"" + fc::to_hex(addr.get_witness_script()) + "\" }"; - - if (addr.get_address() != sao.deposit_address) { - sidechain_address_update_operation op; - op.payer = plugin.get_current_son_object().son_account; - op.sidechain_address_id = sao.id; - op.sidechain_address_account = sao.sidechain_address_account; - op.sidechain = sao.sidechain; - op.deposit_public_key = sao.deposit_public_key; - op.deposit_address = addr.get_address(); - op.deposit_address_data = address_data; - op.withdraw_public_key = sao.withdraw_public_key; - op.withdraw_address = sao.withdraw_address; - - signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), op); - try { - trx.validate(); - database.push_transaction(trx, database::validation_steps::skip_block_size_check); - if (plugin.app().p2p_node()) - plugin.app().p2p_node()->broadcast(net::trx_message(trx)); - return true; - } catch (fc::exception e) { - elog("Sending transaction for update deposit address operation failed with exception ${e}", ("e", e.what())); - return false; - } - } -} - bool sidechain_net_handler_bitcoin::process_deposit(const son_wallet_deposit_object &swdo) { if (proposal_exists(chain::operation::tag::value, swdo.id)) { diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp index 8e636cc7..3388527a 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_peerplays.cpp @@ -124,11 +124,39 @@ void sidechain_net_handler_peerplays::process_primary_wallet() { } void sidechain_net_handler_peerplays::process_sidechain_addresses() { - return; -} + const auto &sidechain_addresses_idx = database.get_index_type(); + const auto &sidechain_addresses_by_sidechain_idx = sidechain_addresses_idx.indices().get(); + const auto &sidechain_addresses_by_sidechain_range = sidechain_addresses_by_sidechain_idx.equal_range(sidechain); + std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second, + [&](const sidechain_address_object &sao) { + if (sao.expires == time_point_sec::maximum()) { + if (sao.deposit_address == "") { + sidechain_address_update_operation op; + op.payer = plugin.get_current_son_object().son_account; + op.sidechain_address_id = sao.id; + op.sidechain_address_account = sao.sidechain_address_account; + op.sidechain = sao.sidechain; + op.deposit_public_key = sao.deposit_public_key; + op.deposit_address = sao.withdraw_address; + op.deposit_address_data = sao.withdraw_address; + op.withdraw_public_key = sao.withdraw_public_key; + op.withdraw_address = sao.withdraw_address; -bool sidechain_net_handler_peerplays::create_deposit_address(const sidechain_address_object &sao) { - return true; + signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), op); + try { + trx.validate(); + database.push_transaction(trx, database::validation_steps::skip_block_size_check); + if (plugin.app().p2p_node()) + plugin.app().p2p_node()->broadcast(net::trx_message(trx)); + return true; + } catch (fc::exception e) { + elog("Sending transaction for update deposit address operation failed with exception ${e}", ("e", e.what())); + return false; + } + } + } + }); + return; } bool sidechain_net_handler_peerplays::process_deposit(const son_wallet_deposit_object &swdo) { diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 59154fd7..3eebcc8e 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -1452,25 +1452,6 @@ class wallet_api string withdraw_address, bool broadcast = false); - /** Updates existing sidechain address owned by the given account for a given sidechain. - * - * Only address, private key and public key might be updated. - * - * @param account the name or id of the account who owns the address - * @param sidechain a sidechain to whom address belongs - * @param deposit_public_key sidechain public key used for deposit address - * @param withdraw_public_key sidechain public key used for withdraw address - * @param withdraw_address sidechain address for withdrawals - * @param broadcast true to broadcast the transaction on the network - * @returns the signed transaction updating sidechain address - */ - signed_transaction update_sidechain_address(string account, - sidechain_type sidechain, - string deposit_public_key, - string withdraw_public_key, - string withdraw_address, - bool broadcast = false); - /** Deletes existing sidechain address owned by the given account for a given sidechain. * * @param account the name or id of the account who owns the address @@ -2319,7 +2300,6 @@ FC_API( graphene::wallet::wallet_api, (get_son_wallet_by_time_point) (get_son_wallets) (add_sidechain_address) - (update_sidechain_address) (delete_sidechain_address) (get_sidechain_addresses_by_account) (get_sidechain_addresses_by_sidechain) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index b083213d..72700c28 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -2102,35 +2102,6 @@ public: return sign_transaction( tx, broadcast ); } FC_CAPTURE_AND_RETHROW() } - signed_transaction update_sidechain_address(string account, - sidechain_type sidechain, - string deposit_public_key, - string withdraw_public_key, - string withdraw_address, - bool broadcast /* = false */) - { try { - account_id_type sidechain_address_account_id = get_account_id(account); - fc::optional sao = _remote_db->get_sidechain_address_by_account_and_sidechain(sidechain_address_account_id, sidechain); - if (!sao) - FC_THROW("No sidechain address for account ${account} and sidechain ${sidechain}", ("account", sidechain_address_account_id)("sidechain", sidechain)); - - sidechain_address_update_operation op; - op.payer = sidechain_address_account_id; - op.sidechain_address_id = sao->id; - op.sidechain_address_account = sidechain_address_account_id; - op.sidechain = sidechain; - op.deposit_public_key = deposit_public_key; - op.withdraw_public_key = withdraw_public_key; - op.withdraw_address = withdraw_address; - - 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() } - signed_transaction delete_sidechain_address(string account, sidechain_type sidechain, bool broadcast /* = false */) @@ -4807,16 +4778,6 @@ signed_transaction wallet_api::add_sidechain_address(string account, return my->add_sidechain_address(account, sidechain, deposit_public_key, withdraw_public_key, withdraw_address, broadcast); } -signed_transaction wallet_api::update_sidechain_address(string account, - sidechain_type sidechain, - string deposit_public_key, - string withdraw_public_key, - string withdraw_address, - bool broadcast /* = false */) -{ - return my->update_sidechain_address(account, sidechain, deposit_public_key, withdraw_public_key, withdraw_address, broadcast); -} - signed_transaction wallet_api::delete_sidechain_address(string account, sidechain_type sidechain, bool broadcast /* = false */) diff --git a/tests/tests/sidechain_addresses_test.cpp b/tests/tests/sidechain_addresses_test.cpp index f0dbe520..755ad37f 100644 --- a/tests/tests/sidechain_addresses_test.cpp +++ b/tests/tests/sidechain_addresses_test.cpp @@ -3,6 +3,7 @@ #include "../common/database_fixture.hpp" #include +#include #include #include @@ -31,7 +32,6 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) { op.sidechain_address_account = alice_id; op.sidechain = sidechain_type::bitcoin; op.deposit_public_key = "deposit_public_key"; - op.deposit_address = "deposit_address"; op.withdraw_public_key = "withdraw_public_key"; op.withdraw_address = "withdraw_address"; @@ -43,66 +43,83 @@ BOOST_AUTO_TEST_CASE( sidechain_address_add_test ) { BOOST_TEST_MESSAGE("Check sidechain_address_add_operation results"); - const auto& idx = db.get_index_type().indices().get(); + const auto& idx = db.get_index_type().indices().get(); BOOST_REQUIRE( idx.size() == 1 ); - auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) ); + auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin, time_point_sec::maximum() ) ); BOOST_REQUIRE( obj != idx.end() ); BOOST_CHECK( obj->sidechain_address_account == alice_id ); BOOST_CHECK( obj->sidechain == sidechain_type::bitcoin ); BOOST_CHECK( obj->deposit_public_key == "deposit_public_key" ); - BOOST_CHECK( obj->deposit_address == "deposit_address" ); + BOOST_CHECK( obj->deposit_address == "" ); + BOOST_CHECK( obj->deposit_address_data == "" ); BOOST_CHECK( obj->withdraw_public_key == "withdraw_public_key" ); BOOST_CHECK( obj->withdraw_address == "withdraw_address" ); } BOOST_AUTO_TEST_CASE( sidechain_address_update_test ) { - BOOST_TEST_MESSAGE("sidechain_address_update_test"); + generate_blocks(HARDFORK_SON_TIME); + generate_block(); INVOKE(sidechain_address_add_test); GET_ACTOR(alice); + ACTORS((bob)); - const auto& idx = db.get_index_type().indices().get(); + const auto& idx = db.get_index_type().indices().get(); BOOST_REQUIRE( idx.size() == 1 ); - auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) ); + auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin, time_point_sec::maximum() ) ); BOOST_REQUIRE( obj != idx.end() ); - - std::string new_deposit_public_key = "new_deposit_public_key"; + std::string new_deposit_public_key = "deposit_public_key"; std::string new_deposit_address = "new_deposit_address"; - std::string new_withdraw_public_key = "new_withdraw_public_key"; - std::string new_withdraw_address = "new_withdraw_address"; + std::string new_deposit_address_data = "new_deposit_address_data"; + std::string new_withdraw_public_key = "withdraw_public_key"; + std::string new_withdraw_address = "withdraw_address"; + generate_block(); + auto& son = db.create( [&]( son_object& sobj ) + { + sobj.son_account = bob_id; + sobj.statistics = db.create([&](son_statistics_object& s){s.owner = sobj.id;}).id; + }); + generate_block(); + db.modify( db.get_global_properties(), [&]( global_property_object& _gpo ) + { + son_info sinfo; + sinfo.son_id = son.id; + _gpo.active_sons.push_back(sinfo); + }); + generate_block(); { BOOST_TEST_MESSAGE("Send sidechain_address_update_operation"); - + trx.clear(); sidechain_address_update_operation op; - op.payer = alice_id; + op.payer = bob_id; op.sidechain_address_id = sidechain_address_id_type(0); op.sidechain_address_account = obj->sidechain_address_account; op.sidechain = obj->sidechain; op.deposit_public_key = new_deposit_public_key; op.deposit_address = new_deposit_address; + op.deposit_address_data = new_deposit_address_data; op.withdraw_public_key = new_withdraw_public_key; op.withdraw_address = new_withdraw_address; - trx.operations.push_back(op); - sign(trx, alice_private_key); + sign(trx, bob_private_key); PUSH_TX(db, trx, ~0); } generate_block(); - { BOOST_TEST_MESSAGE("Check sidechain_address_update_operation results"); - const auto& idx = db.get_index_type().indices().get(); + const auto& idx = db.get_index_type().indices().get(); BOOST_REQUIRE( idx.size() == 1 ); - auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) ); + auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin, time_point_sec::maximum() ) ); BOOST_REQUIRE( obj != idx.end() ); BOOST_CHECK( obj->sidechain_address_account == obj->sidechain_address_account ); BOOST_CHECK( obj->sidechain == obj->sidechain ); BOOST_CHECK( obj->deposit_public_key == new_deposit_public_key ); BOOST_CHECK( obj->deposit_address == new_deposit_address ); + BOOST_CHECK( obj->deposit_address_data == new_deposit_address_data ); BOOST_CHECK( obj->withdraw_public_key == new_withdraw_public_key ); BOOST_CHECK( obj->withdraw_address == new_withdraw_address ); } @@ -116,9 +133,9 @@ BOOST_AUTO_TEST_CASE( sidechain_address_delete_test ) { GET_ACTOR(alice); - const auto& idx = db.get_index_type().indices().get(); + const auto& idx = db.get_index_type().indices().get(); BOOST_REQUIRE( idx.size() == 1 ); - auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) ); + auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin, time_point_sec::maximum() ) ); BOOST_REQUIRE( obj != idx.end() ); { @@ -134,15 +151,18 @@ BOOST_AUTO_TEST_CASE( sidechain_address_delete_test ) { sign(trx, alice_private_key); PUSH_TX(db, trx, ~0); } + time_point_sec now = db.head_block_time(); generate_block(); { BOOST_TEST_MESSAGE("Check sidechain_address_delete_operation results"); - const auto& idx = db.get_index_type().indices().get(); - BOOST_REQUIRE( idx.size() == 0 ); - auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin ) ); + const auto& idx = db.get_index_type().indices().get(); + BOOST_REQUIRE( idx.size() == 1 ); + auto obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin, time_point_sec::maximum() ) ); BOOST_REQUIRE( obj == idx.end() ); + auto expired_obj = idx.find( boost::make_tuple( alice_id, sidechain_type::bitcoin, now ) ); + BOOST_REQUIRE( expired_obj != idx.end() ); } }