From e47ef741f7d431fb9b803c3a3bd899dbb4153406 Mon Sep 17 00:00:00 2001 From: hackrush Date: Wed, 5 Sep 2018 00:35:45 +0530 Subject: [PATCH] Review Fixes --- lbrynet/daemon/Daemon.py | 6 ++++-- lbrynet/wallet/manager.py | 8 ++------ tests/integration/wallet/test_commands.py | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 3b7dfb4e0..169851cbe 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -1080,7 +1080,7 @@ class Daemon(AuthJSONRPCServer): result = yield self.wallet_manager.send_points_to_address(reserved_points, amount) self.analytics_manager.send_credits_sent() else: - log.info("This command is deprecated for sending tips, please use the newer tip_claim command") + log.info("This command is deprecated for sending tips, please use the newer claim_tip command") result = yield self.jsonrpc_claim_tip(claim_id, amount) return result @@ -2392,6 +2392,7 @@ class Daemon(AuthJSONRPCServer): } """ + account = self.default_account if account_id is not None: account = self.get_account_or_error("account_id", account_id, lbc_only=True) @@ -2404,7 +2405,7 @@ class Daemon(AuthJSONRPCServer): @defer.inlineCallbacks def jsonrpc_claim_tip(self, claim_id, amount, account_id=None): """ - Tip a claim + Tip the owner of the claim Usage: claim_tip ( | --claim_id=) ( | --amount=) [--account_id=] @@ -2427,6 +2428,7 @@ class Daemon(AuthJSONRPCServer): } """ + account = self.default_account if account_id is not None: account = self.get_account_or_error("account_id", account_id, lbc_only=True) diff --git a/lbrynet/wallet/manager.py b/lbrynet/wallet/manager.py index f4df28159..ad168feb5 100644 --- a/lbrynet/wallet/manager.py +++ b/lbrynet/wallet/manager.py @@ -246,18 +246,14 @@ class LbryWalletManager(BaseWalletManager): } @defer.inlineCallbacks - def support_claim(self, claim_name, claim_id, amount, account=None): - if account is None: - account = self.default_account + def support_claim(self, claim_name, claim_id, amount, account): holding_address = yield account.receiving.get_or_create_usable_address() tx = yield Transaction.support(claim_name, claim_id, amount, holding_address, [account], account) yield account.ledger.broadcast(tx) return tx @defer.inlineCallbacks - def tip_claim(self, amount, claim_id, account=None): - if account is None: - account = self.default_account + def tip_claim(self, amount, claim_id, account): claim_to_tip = yield self.get_claim_by_claim_id(claim_id) tx = yield Transaction.support( claim_to_tip['name'], claim_id, amount, claim_to_tip['address'], [account], account diff --git a/tests/integration/wallet/test_commands.py b/tests/integration/wallet/test_commands.py index 00a7b2091..303cac389 100644 --- a/tests/integration/wallet/test_commands.py +++ b/tests/integration/wallet/test_commands.py @@ -350,7 +350,7 @@ class EpicAdventuresOfChris45(CommandTestCase): # And voila, and bravo and encore! His Best Friend Ramsey read the story and immediately knew this was a hit # Now to keep this claim winning on the lbry blockchain he immediately supports the claim tx = yield self.out(self.daemon.jsonrpc_claim_new_support( - 'fresh-start', claim3['claim_id'], '0.2', account_id=ramsey_account_id + 'fresh-start', claim3['claim_id'], 0.2, account_id=ramsey_account_id )) yield self.d_confirm_tx(tx['txid']) @@ -364,7 +364,7 @@ class EpicAdventuresOfChris45(CommandTestCase): # Now he also wanted to support the original creator of the Award Winning Novel # So he quickly decides to send a tip to him tx = yield self.out( - self.daemon.jsonrpc_claim_tip(claim3['claim_id'], '0.3', account_id=ramsey_account_id)) + self.daemon.jsonrpc_claim_tip(claim3['claim_id'], 0.3, account_id=ramsey_account_id)) yield self.d_confirm_tx(tx['txid']) # And again checks if it went to the just right place @@ -372,6 +372,18 @@ class EpicAdventuresOfChris45(CommandTestCase): # Which it obviously did. Because....????? self.assertEqual(resolve_result[uri]['claim']['supports'][1]['amount'], 0.3) self.assertEqual(resolve_result[uri]['claim']['supports'][1]['txid'], tx['txid']) + yield self.d_generate(5) + + # Seeing the ravishing success of his novel Chris adds support to his claim too + tx = yield self.out(self.daemon.jsonrpc_claim_new_support('fresh-start', claim3['claim_id'], 0.4)) + yield self.d_confirm_tx(tx['txid']) + + # And check if his support showed up + resolve_result = yield self.out(self.daemon.jsonrpc_resolve(uri=uri)) + # It did! + self.assertEqual(resolve_result[uri]['claim']['supports'][2]['amount'], 0.4) + self.assertEqual(resolve_result[uri]['claim']['supports'][2]['txid'], tx['txid']) + yield self.d_generate(5) class AccountManagement(CommandTestCase):