From c61c01d1d79d69e0ab918d627c910ce67f1c1073 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 22 Apr 2019 17:29:13 -0300 Subject: [PATCH 1/4] add htlc api calls --- libraries/app/database_api.cpp | 79 +++++++++ .../app/include/graphene/app/database_api.hpp | 36 +++- .../app/include/graphene/app/full_account.hpp | 2 + .../include/graphene/chain/htlc_object.hpp | 16 +- tests/tests/htlc_tests.cpp | 154 ++++++++++++++++++ 5 files changed, 285 insertions(+), 2 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 3ed284bc39..982e8cbb72 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -168,6 +168,11 @@ class database_api_impl : public std::enable_shared_from_this vector get_withdraw_permissions_by_giver(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; vector get_withdraw_permissions_by_recipient(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; + // HTCL + optional get_htlc(htlc_id_type id) const; + vector get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; + vector get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; + //private: static string price_to_string( const price& _price, const asset_object& _base, const asset_object& _quote ); @@ -969,6 +974,12 @@ std::map database_api_impl::get_full_accounts( const acnt.withdraws.emplace_back(withdraw); }); + // get htlcs + auto htlc_range = _db.get_index_type().indices().get().equal_range(account->id); + std::for_each(htlc_range.first, htlc_range.second, + [&acnt] (const htlc_object& htlc) { + acnt.htlcs.emplace_back(htlc); + }); results[account_name_or_id] = acnt; } @@ -2382,6 +2393,74 @@ vector database_api_impl::get_withdraw_permissions_b return result; } +////////////////////////////////////////////////////////////////////// +// // +// HTLC // +// // +////////////////////////////////////////////////////////////////////// + +optional database_api::get_htlc(htlc_id_type id)const +{ + return my->get_htlc(id); +} + +fc::optional database_api_impl::get_htlc(htlc_id_type id) const +{ + auto obj = get_objects( { id }).front(); + if ( !obj.is_null() ) + { + return fc::optional(obj.template as(GRAPHENE_MAX_NESTED_OBJECTS)); + } + return fc::optional(); +} + +vector database_api::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit)const +{ + return my->get_htlc_by_from(account_id_or_name, start, limit); +} + +vector database_api_impl::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const +{ + FC_ASSERT( limit <= 101 ); + vector result; + + const auto& htlc_idx = _db.get_index_type< htlc_index >().indices().get< by_from_id >(); + auto htlc_index_end = htlc_idx.end(); + const account_id_type account = get_account_from_string(account_id_or_name)->id; + auto htlc_itr = htlc_idx.lower_bound(boost::make_tuple(account, start)); + + while(htlc_itr != htlc_index_end && htlc_itr->transfer.from == account && result.size() < limit) + { + result.push_back(*htlc_itr); + ++htlc_itr; + } + return result; +} + +vector database_api::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit)const +{ + return my->get_htlc_by_to(account_id_or_name, start, limit); +} + +vector database_api_impl::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const +{ + + FC_ASSERT( limit <= 101 ); + vector result; + + const auto& htlc_idx = _db.get_index_type< htlc_index >().indices().get< by_to_id >(); + auto htlc_index_end = htlc_idx.end(); + const account_id_type account = get_account_from_string(account_id_or_name)->id; + auto htlc_itr = htlc_idx.lower_bound(boost::make_tuple(account, start)); + + while(htlc_itr != htlc_index_end && htlc_itr->transfer.to == account && result.size() < limit) + { + result.push_back(*htlc_itr); + ++htlc_itr; + } + return result; +} + ////////////////////////////////////////////////////////////////////// // // // Private methods // diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index fe97083956..44de9bdf71 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -743,7 +744,36 @@ class database_api */ vector get_withdraw_permissions_by_recipient(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; - private: + ////////// + // HTLC // + ////////// + + /** + * @brief Get HTLC object + * @param id HTLC contarct id + * @return HTLC object for the id + */ + optional get_htlc(htlc_id_type id) const; + + /** + * @brief Get non expired HTLC objects using the sender account + * @param account Account ID or name to get objects from + * @param start Withdraw permission objects(1.16.X) before this ID will be skipped in results. Pagination purposes. + * @param limit Maximum number of objects to retrieve + * @return HTLC objects for the account + */ + vector get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; + + /** + * @brief Get non expired HTLC objects using the receiver account + * @param account Account ID or name to get objects from + * @param start Withdraw permission objects(1.16.X) before this ID will be skipped in results. Pagination purposes. + * @param limit Maximum number of objects to retrieve + * @return HTLC objects for the account + */ + vector get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; + +private: std::shared_ptr< database_api_impl > my; }; @@ -865,4 +895,8 @@ FC_API(graphene::app::database_api, (get_withdraw_permissions_by_giver) (get_withdraw_permissions_by_recipient) + // HTLC + (get_htlc) + (get_htlc_by_from) + (get_htlc_by_to) ) diff --git a/libraries/app/include/graphene/app/full_account.hpp b/libraries/app/include/graphene/app/full_account.hpp index dea5eb7e6a..139eb5cc1e 100644 --- a/libraries/app/include/graphene/app/full_account.hpp +++ b/libraries/app/include/graphene/app/full_account.hpp @@ -48,6 +48,7 @@ namespace graphene { namespace app { vector proposals; vector assets; vector withdraws; + vector htlcs; }; } } @@ -68,4 +69,5 @@ FC_REFLECT( graphene::app::full_account, (proposals) (assets) (withdraws) + (htlcs) ) diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index 5d41eda392..3958839ae2 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -77,10 +77,19 @@ namespace graphene { namespace chain { const result_type& operator()(const htlc_object& o)const { return o.transfer.from; } }; + /***** + * Index helper for to + */ + struct to_extractor { + typedef account_id_type result_type; + const result_type& operator()(const htlc_object& o)const { return o.transfer.to; } + }; + }; struct by_from_id; struct by_expiration; + struct by_to_id; typedef multi_index_container< htlc_object, indexed_by< @@ -94,8 +103,13 @@ namespace graphene { namespace chain { ordered_unique< tag< by_from_id >, composite_key< htlc_object, htlc_object::from_extractor, + member< object, object_id_type, &object::id > > >, + + ordered_unique< tag< by_to_id >, + composite_key< htlc_object, + htlc_object::to_extractor, member< object, object_id_type, &object::id > > > - > + > > htlc_object_index_type; diff --git a/tests/tests/htlc_tests.cpp b/tests/tests/htlc_tests.cpp index 51279cecf8..29d685d8a4 100644 --- a/tests/tests/htlc_tests.cpp +++ b/tests/tests/htlc_tests.cpp @@ -832,4 +832,158 @@ try { } FC_LOG_AND_RETHROW() } +BOOST_AUTO_TEST_CASE(htlc_database_api) { +try { + + ACTORS((alice)(bob)(carl)(dan)); + + int64_t init_balance(100 * GRAPHENE_BLOCKCHAIN_PRECISION); + + transfer( committee_account, alice_id, graphene::chain::asset(init_balance) ); + + generate_blocks(HARDFORK_CORE_1468_TIME); + set_expiration( db, trx ); + + set_committee_parameters(this); + + uint16_t preimage_size = 256; + std::vector pre_image(256); + std::independent_bits_engine rbe; + std::generate(begin(pre_image), end(pre_image), std::ref(rbe)); + graphene::chain::htlc_id_type alice_htlc_id_bob; + graphene::chain::htlc_id_type alice_htlc_id_carl; + graphene::chain::htlc_id_type alice_htlc_id_dan; + + generate_block(); + set_expiration( db, trx ); + trx.clear(); + // alice puts a htlc contract to bob + { + graphene::chain::htlc_create_operation create_operation; + BOOST_TEST_MESSAGE("Alice (who has 100 coins, is transferring 2 coins to Bob"); + create_operation.amount = graphene::chain::asset( 3 * GRAPHENE_BLOCKCHAIN_PRECISION ); + create_operation.to = bob_id; + create_operation.claim_period_seconds = 60; + create_operation.preimage_hash = hash_it( pre_image ); + create_operation.preimage_size = preimage_size; + create_operation.from = alice_id; + create_operation.fee = db.get_global_properties().parameters.current_fees->calculate_fee(create_operation); + trx.operations.push_back(create_operation); + sign(trx, alice_private_key); + PUSH_TX(db, trx, ~0); + trx.clear(); + set_expiration( db, trx ); + graphene::chain::signed_block blk = generate_block(); + processed_transaction alice_trx = blk.transactions[0]; + alice_htlc_id_bob = alice_trx.operation_results[0].get(); + generate_block(); + set_expiration( db, trx ); + } + + trx.clear(); + // alice puts a htlc contract to carl + { + graphene::chain::htlc_create_operation create_operation; + BOOST_TEST_MESSAGE("Alice (who has 100 coins, is transferring 2 coins to Bob"); + create_operation.amount = graphene::chain::asset( 3 * GRAPHENE_BLOCKCHAIN_PRECISION ); + create_operation.to = carl_id; + create_operation.claim_period_seconds = 60; + create_operation.preimage_hash = hash_it( pre_image ); + create_operation.preimage_size = preimage_size; + create_operation.from = alice_id; + create_operation.fee = db.get_global_properties().parameters.current_fees->calculate_fee(create_operation); + trx.operations.push_back(create_operation); + sign(trx, alice_private_key); + PUSH_TX(db, trx, ~0); + trx.clear(); + set_expiration( db, trx ); + graphene::chain::signed_block blk = generate_block(); + processed_transaction alice_trx = blk.transactions[0]; + alice_htlc_id_carl = alice_trx.operation_results[0].get(); + generate_block(); + set_expiration( db, trx ); + } + + trx.clear(); + // alice puts a htlc contract to dan + { + graphene::chain::htlc_create_operation create_operation; + BOOST_TEST_MESSAGE("Alice (who has 100 coins, is transferring 2 coins to Bob"); + create_operation.amount = graphene::chain::asset( 3 * GRAPHENE_BLOCKCHAIN_PRECISION ); + create_operation.to = dan_id; + create_operation.claim_period_seconds = 60; + create_operation.preimage_hash = hash_it( pre_image ); + create_operation.preimage_size = preimage_size; + create_operation.from = alice_id; + create_operation.fee = db.get_global_properties().parameters.current_fees->calculate_fee(create_operation); + trx.operations.push_back(create_operation); + sign(trx, alice_private_key); + PUSH_TX(db, trx, ~0); + trx.clear(); + set_expiration( db, trx ); + graphene::chain::signed_block blk = generate_block(); + processed_transaction alice_trx = blk.transactions[0]; + alice_htlc_id_dan = alice_trx.operation_results[0].get(); + generate_block(); + set_expiration( db, trx ); + } + + graphene::app::database_api db_api(db); + + auto htlc = db_api.get_htlc(alice_htlc_id_bob); + BOOST_CHECK_EQUAL( htlc->id.instance(), 0); + BOOST_CHECK_EQUAL( htlc->transfer.from.instance.value, 16 ); + BOOST_CHECK_EQUAL( htlc->transfer.to.instance.value, 17 ); + + htlc = db_api.get_htlc(alice_htlc_id_carl); + BOOST_CHECK_EQUAL( htlc->id.instance(), 1); + BOOST_CHECK_EQUAL( htlc->transfer.from.instance.value, 16 ); + BOOST_CHECK_EQUAL( htlc->transfer.to.instance.value, 18 ); + + htlc = db_api.get_htlc(alice_htlc_id_dan); + BOOST_CHECK_EQUAL( htlc->id.instance(), 2); + BOOST_CHECK_EQUAL( htlc->transfer.from.instance.value, 16 ); + BOOST_CHECK_EQUAL( htlc->transfer.to.instance.value, 19 ); + + auto htlcs_alice = db_api.get_htlc_by_from(alice.name, graphene::chain::htlc_id_type(0), 100); + BOOST_CHECK_EQUAL( htlcs_alice.size(), 3 ); + BOOST_CHECK_EQUAL( htlcs_alice[0].id.instance(), 0 ); + BOOST_CHECK_EQUAL( htlcs_alice[1].id.instance(), 1 ); + BOOST_CHECK_EQUAL( htlcs_alice[2].id.instance(), 2 ); + + htlcs_alice = db_api.get_htlc_by_from(alice.name, graphene::chain::htlc_id_type(1), 1); + BOOST_CHECK_EQUAL( htlcs_alice.size(), 1 ); + BOOST_CHECK_EQUAL( htlcs_alice[0].id.instance(), 1 ); + + htlcs_alice = db_api.get_htlc_by_from(alice.name, graphene::chain::htlc_id_type(1), 2); + BOOST_CHECK_EQUAL( htlcs_alice.size(), 2 ); + BOOST_CHECK_EQUAL( htlcs_alice[0].id.instance(), 1 ); + BOOST_CHECK_EQUAL( htlcs_alice[1].id.instance(), 2 ); + + auto htlcs_bob = db_api.get_htlc_by_to(bob.name, graphene::chain::htlc_id_type(0), 100); + BOOST_CHECK_EQUAL( htlcs_bob.size(), 1 ); + BOOST_CHECK_EQUAL( htlcs_bob[0].id.instance(), 0 ); + + auto htlcs_carl = db_api.get_htlc_by_to(carl.name, graphene::chain::htlc_id_type(0), 100); + BOOST_CHECK_EQUAL( htlcs_carl.size(), 1 ); + BOOST_CHECK_EQUAL( htlcs_carl[0].id.instance(), 1 ); + + auto htlcs_dan = db_api.get_htlc_by_to(dan.name, graphene::chain::htlc_id_type(0), 100); + BOOST_CHECK_EQUAL( htlcs_dan.size(), 1 ); + BOOST_CHECK_EQUAL( htlcs_dan[0].id.instance(), 2 ); + + auto full = db_api.get_full_accounts({alice.name}, false); + BOOST_CHECK_EQUAL( full[alice.name].htlcs.size(), 3 ); + + full = db_api.get_full_accounts({bob.name}, false); + BOOST_CHECK_EQUAL( full[alice.name].htlcs.size(), 0 ); + +} catch (fc::exception &e) { + edump((e.to_detail_string())); + throw; + } +} + + + BOOST_AUTO_TEST_SUITE_END() From 91f3fa22e352b044bb6c5272128f44fca7ef0a6d Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 29 Apr 2019 12:20:01 -0500 Subject: [PATCH 2/4] fixed typos, added from to get_full_accounts --- libraries/app/database_api.cpp | 18 ++++++++++++------ .../app/include/graphene/app/database_api.hpp | 10 +++++----- .../include/graphene/chain/htlc_object.hpp | 2 ++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 982e8cbb72..7038106928 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -168,7 +168,7 @@ class database_api_impl : public std::enable_shared_from_this vector get_withdraw_permissions_by_giver(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; vector get_withdraw_permissions_by_recipient(const std::string account_id_or_name, withdraw_permission_id_type start, uint32_t limit)const; - // HTCL + // HTLC optional get_htlc(htlc_id_type id) const; vector get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; vector get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const; @@ -975,11 +975,17 @@ std::map database_api_impl::get_full_accounts( const }); // get htlcs - auto htlc_range = _db.get_index_type().indices().get().equal_range(account->id); - std::for_each(htlc_range.first, htlc_range.second, - [&acnt] (const htlc_object& htlc) { - acnt.htlcs.emplace_back(htlc); - }); + auto htlc_from_range = _db.get_index_type().indices().get().equal_range(account->id); + std::for_each(htlc_from_range.first, htlc_from_range.second, + [&acnt] (const htlc_object& htlc) { + acnt.htlcs.emplace_back(htlc); + }); + auto htlc_to_range = _db.get_index_type().indices().get().equal_range(account->id); + std::for_each(htlc_to_range.first, htlc_to_range.second, + [&acnt] (const htlc_object& htlc) { + if ( std::find(acnt.htlcs.begin(), acnt.htlcs.end(), htlc) == acnt.htlcs.end() ) + acnt.htlcs.emplace_back(htlc); + }); results[account_name_or_id] = acnt; } diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 44de9bdf71..b5ecbf4625 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -750,15 +750,15 @@ class database_api /** * @brief Get HTLC object - * @param id HTLC contarct id + * @param id HTLC contract id * @return HTLC object for the id */ optional get_htlc(htlc_id_type id) const; /** * @brief Get non expired HTLC objects using the sender account - * @param account Account ID or name to get objects from - * @param start Withdraw permission objects(1.16.X) before this ID will be skipped in results. Pagination purposes. + * @param account_id_or_name Account ID or name to get objects from + * @param start htlc objects before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of objects to retrieve * @return HTLC objects for the account */ @@ -766,8 +766,8 @@ class database_api /** * @brief Get non expired HTLC objects using the receiver account - * @param account Account ID or name to get objects from - * @param start Withdraw permission objects(1.16.X) before this ID will be skipped in results. Pagination purposes. + * @param account_id_or_name Account ID or name to get objects from + * @param start htlc objects before this ID will be skipped in results. Pagination purposes. * @param limit Maximum number of objects to retrieve * @return HTLC objects for the account */ diff --git a/libraries/chain/include/graphene/chain/htlc_object.hpp b/libraries/chain/include/graphene/chain/htlc_object.hpp index 3958839ae2..da853877d3 100644 --- a/libraries/chain/include/graphene/chain/htlc_object.hpp +++ b/libraries/chain/include/graphene/chain/htlc_object.hpp @@ -85,6 +85,8 @@ namespace graphene { namespace chain { const result_type& operator()(const htlc_object& o)const { return o.transfer.to; } }; + bool operator==(const htlc_object& in) { return this->id == in.id; } + }; struct by_from_id; From c69953896048d604053d28764436732a063ef219 Mon Sep 17 00:00:00 2001 From: John Jones Date: Mon, 29 Apr 2019 13:33:26 -0500 Subject: [PATCH 3/4] Make get_htlc_by_x return size limits configurable --- libraries/app/application.cpp | 3 +++ libraries/app/database_api.cpp | 5 ++--- libraries/app/include/graphene/app/application.hpp | 1 + tests/tests/htlc_tests.cpp | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 4217b2e934..8f089c0b0b 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -340,6 +340,9 @@ void application_impl::set_api_limit() { if(_options->count("api-limit-get-key-references")){ _app_options.api_limit_get_key_references = _options->at("api-limit-get-key-references").as(); } + if(_options->count("api-limit-get-htlc-by")) { + _app_options.api_limit_get_htlc_by = _options->at("api-limit-get-htlc-by").as(); + } } void application_impl::startup() diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 7038106928..8227fa9f4a 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -986,7 +986,6 @@ std::map database_api_impl::get_full_accounts( const if ( std::find(acnt.htlcs.begin(), acnt.htlcs.end(), htlc) == acnt.htlcs.end() ) acnt.htlcs.emplace_back(htlc); }); - results[account_name_or_id] = acnt; } return results; @@ -2427,7 +2426,7 @@ vector database_api::get_htlc_by_from(const std::string account_id_ vector database_api_impl::get_htlc_by_from(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const { - FC_ASSERT( limit <= 101 ); + FC_ASSERT( limit <= _app_options->api_limit_get_htlc_by ); vector result; const auto& htlc_idx = _db.get_index_type< htlc_index >().indices().get< by_from_id >(); @@ -2451,7 +2450,7 @@ vector database_api::get_htlc_by_to(const std::string account_id_or vector database_api_impl::get_htlc_by_to(const std::string account_id_or_name, htlc_id_type start, uint32_t limit) const { - FC_ASSERT( limit <= 101 ); + FC_ASSERT( limit <= _app_options->api_limit_get_htlc_by ); vector result; const auto& htlc_idx = _db.get_index_type< htlc_index >().indices().get< by_to_id >(); diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 6f1a0d6e90..226fc0053f 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -47,6 +47,7 @@ namespace graphene { namespace app { uint64_t api_limit_get_account_history_by_operations = 100; uint64_t api_limit_get_asset_holders = 100; uint64_t api_limit_get_key_references = 100; + uint64_t api_limit_get_htlc_by = 100; }; class application diff --git a/tests/tests/htlc_tests.cpp b/tests/tests/htlc_tests.cpp index b41b38b717..3281178440 100644 --- a/tests/tests/htlc_tests.cpp +++ b/tests/tests/htlc_tests.cpp @@ -928,7 +928,7 @@ try { set_expiration( db, trx ); } - graphene::app::database_api db_api(db); + graphene::app::database_api db_api(db, &(this->app.get_options()) ) ; auto htlc = db_api.get_htlc(alice_htlc_id_bob); BOOST_CHECK_EQUAL( htlc->id.instance(), 0); From 7a6f44261f3814042bd1676f33645f0da3c26c51 Mon Sep 17 00:00:00 2001 From: John Jones Date: Tue, 30 Apr 2019 07:47:10 -0500 Subject: [PATCH 4/4] verify correct collection in test --- tests/tests/htlc_tests.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/tests/htlc_tests.cpp b/tests/tests/htlc_tests.cpp index 3281178440..88b9bf73f9 100644 --- a/tests/tests/htlc_tests.cpp +++ b/tests/tests/htlc_tests.cpp @@ -860,7 +860,7 @@ try { // alice puts a htlc contract to bob { graphene::chain::htlc_create_operation create_operation; - BOOST_TEST_MESSAGE("Alice (who has 100 coins, is transferring 2 coins to Bob"); + BOOST_TEST_MESSAGE("Alice, who has 100 coins, is transferring 3 coins to Bob"); create_operation.amount = graphene::chain::asset( 3 * GRAPHENE_BLOCKCHAIN_PRECISION ); create_operation.to = bob_id; create_operation.claim_period_seconds = 60; @@ -884,7 +884,7 @@ try { // alice puts a htlc contract to carl { graphene::chain::htlc_create_operation create_operation; - BOOST_TEST_MESSAGE("Alice (who has 100 coins, is transferring 2 coins to Bob"); + BOOST_TEST_MESSAGE("Alice, who has 100 coins, is transferring 3 coins to Carl"); create_operation.amount = graphene::chain::asset( 3 * GRAPHENE_BLOCKCHAIN_PRECISION ); create_operation.to = carl_id; create_operation.claim_period_seconds = 60; @@ -908,7 +908,7 @@ try { // alice puts a htlc contract to dan { graphene::chain::htlc_create_operation create_operation; - BOOST_TEST_MESSAGE("Alice (who has 100 coins, is transferring 2 coins to Bob"); + BOOST_TEST_MESSAGE("Alice, who has 100 coins, is transferring 3 coins to Dan"); create_operation.amount = graphene::chain::asset( 3 * GRAPHENE_BLOCKCHAIN_PRECISION ); create_operation.to = dan_id; create_operation.claim_period_seconds = 60; @@ -976,7 +976,7 @@ try { BOOST_CHECK_EQUAL( full[alice.name].htlcs.size(), 3 ); full = db_api.get_full_accounts({bob.name}, false); - BOOST_CHECK_EQUAL( full[alice.name].htlcs.size(), 0 ); + BOOST_CHECK_EQUAL( full[bob.name].htlcs.size(), 1 ); } catch (fc::exception &e) { edump((e.to_detail_string()));