From 54e53932bd4975a696e8e30c234533a57e85d27e Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 12 Jun 2019 01:43:46 -0300 Subject: [PATCH] fix bug: fee address defaults respect replace --- lbrynet/extras/daemon/Daemon.py | 2 +- lbrynet/schema/attrs.py | 4 ++-- tests/integration/test_claim_commands.py | 21 +++++++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index b3fd515a1..22cf30c77 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -2610,7 +2610,7 @@ class Daemon(metaclass=JSONRPCServerType): channel = old_txo.channel if 'fee_amount' in kwargs: - kwargs['fee_address'] = self.get_fee_address(kwargs, claim_address) + kwargs['fee_address'] = self.get_fee_address(kwargs, old_txo.claim.stream.fee.address or claim_address) if replace: claim = Claim() diff --git a/lbrynet/schema/attrs.py b/lbrynet/schema/attrs.py index da9fa8569..d0ddebbfd 100644 --- a/lbrynet/schema/attrs.py +++ b/lbrynet/schema/attrs.py @@ -206,8 +206,8 @@ class Fee(Metadata): def update(self, address: str = None, currency: str = None, amount=None): if address is not None: self.address = address - if currency is not None and amount is not None: - currency = currency.lower() + if (self.message.currency or currency is not None) and amount is not None: + currency = currency.lower() if currency is not None else self.currency.lower() assert currency in ('lbc', 'btc', 'usd'), f'Unknown currency type: {currency}' setattr(self, currency, Decimal(amount)) diff --git a/tests/integration/test_claim_commands.py b/tests/integration/test_claim_commands.py index 9662d208a..b19f6e3d4 100644 --- a/tests/integration/test_claim_commands.py +++ b/tests/integration/test_claim_commands.py @@ -708,16 +708,25 @@ class StreamCommands(ClaimTestCase): # clearing fee tx = await self.out(self.stream_update(claim_id, clear_fee=True)) txo = tx['outputs'][0] - del fixed_values['fee'] + fixed_fee = fixed_values.pop('fee') self.assertEqual(txo['value'], fixed_values) # setting the fee after it has been cleared, without a fee address, sets the fee address to claim address - tx = await self.out(self.stream_update(claim_id, fee_amount='0.1', fee_currency='LBC')) + tx = await self.out(self.stream_update( + claim_id, fee_amount=fixed_fee['amount'], fee_currency=fixed_fee['currency'], + )) txo = tx['outputs'][0] - self.assertIn('fee', txo['value']) - self.assertIn('address', txo['value']['fee']) - self.assertEqual(txo['value']['fee']['address'], txo['address']) - fixed_values['fee'] = txo['value']['fee'] + fixed_fee['address'] = txo['address'] + fixed_values['fee'] = fixed_fee + self.assertEqual(txo['value'], fixed_values) + + # update just the fee amount, shouldnt update fee address to claim address + address = await self.daemon.jsonrpc_address_unused() + tx = await self.out(self.stream_update( + claim_id, fee_amount='1.33', claim_address=address + )) + fixed_values['fee']['amount'] = '1.33' + self.assertEqual(tx['outputs'][0]['value'], fixed_values) # modifying hash/size/name fixed_values['source']['name'] = 'changed_name'