From f4c111f04c11adffa50715e763e6e188841d19cc Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 29 Jul 2019 17:47:03 -0400 Subject: [PATCH 1/2] handle null content fee --- lbry/lbry/stream/stream_manager.py | 2 +- lbry/tests/integration/test_file_commands.py | 29 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lbry/lbry/stream/stream_manager.py b/lbry/lbry/stream/stream_manager.py index 93237ee93..06d5bf5e7 100644 --- a/lbry/lbry/stream/stream_manager.py +++ b/lbry/lbry/stream/stream_manager.py @@ -391,7 +391,7 @@ class StreamManager: fee_amount, fee_address = None, None # check that the fee is payable - if not to_replace and claim.stream.has_fee: + if not to_replace and claim.stream.has_fee and claim.stream.fee.amount: fee_amount = round(exchange_rate_manager.convert_currency( claim.stream.fee.currency, "LBC", claim.stream.fee.amount ), 5) diff --git a/lbry/tests/integration/test_file_commands.py b/lbry/tests/integration/test_file_commands.py index 9f6d9fe73..f53f0ae8d 100644 --- a/lbry/tests/integration/test_file_commands.py +++ b/lbry/tests/integration/test_file_commands.py @@ -277,6 +277,24 @@ class FileCommands(CommandTestCase): self.assertEqual(response['content_fee']['outputs'][0]['amount'], '2.0') self.assertEqual(response['content_fee']['outputs'][0]['address'], target_address) + async def test_null_fee(self): + target_address = await self.blockchain.get_raw_change_address() + tx = await self.stream_create( + 'nullfee', '0.01', data=b'no pay me, no', + fee_currency='LBC', fee_address=target_address, fee_amount='1.0' + ) + await self.__raw_value_update_no_fee_amount(tx, target_address) + await self.daemon.jsonrpc_file_delete(claim_name='nullfee') + response = await self.daemon.jsonrpc_get('lbry://nullfee') + self.assertEqual(len(self.daemon.jsonrpc_file_list()), 1) + self.assertIsNone(response.content_fee) + self.assertTrue(response.stream_claim_info.claim.stream.has_fee) + self.assertDictEqual( + response.stream_claim_info.claim.stream.to_dict()['fee'], + {'currency': 'LBC', 'address': target_address} + ) + await self.daemon.jsonrpc_file_delete(claim_name='nullfee') + async def __raw_value_update_no_fee_address(self, tx, claim_address, **kwargs): tx = await self.daemon.jsonrpc_stream_update( self.get_claim_id(tx), preview=True, claim_address=claim_address, **kwargs @@ -286,3 +304,14 @@ class FileCommands(CommandTestCase): await tx.sign([self.account]) await self.broadcast(tx) await self.confirm_tx(tx.id) + + async def __raw_value_update_no_fee_amount(self, tx, claim_address): + tx = await self.daemon.jsonrpc_stream_update( + self.get_claim_id(tx), preview=True, fee_currency='LBC', fee_amount='1.0', fee_address=claim_address, + claim_address=claim_address + ) + tx.outputs[0].claim.stream.fee.message.ClearField('amount') + tx.outputs[0].script.generate() + await tx.sign([self.account]) + await self.broadcast(tx) + await self.confirm_tx(tx.id) From 221585908a6ab849d3fe062ab02b3e81476c796b Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 29 Jul 2019 17:47:40 -0400 Subject: [PATCH 2/2] re-raise unexpected resolve error during download as a ResolveError --- lbry/lbry/stream/stream_manager.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lbry/lbry/stream/stream_manager.py b/lbry/lbry/stream/stream_manager.py index 06d5bf5e7..f52661bcc 100644 --- a/lbry/lbry/stream/stream_manager.py +++ b/lbry/lbry/stream/stream_manager.py @@ -360,6 +360,10 @@ class StreamManager: ) except asyncio.TimeoutError: raise ResolveTimeout(uri) + except Exception as err: + if isinstance(err, asyncio.CancelledError): + raise + raise ResolveError(f"Unexpected error resolving stream: {str(err)}") await self.storage.save_claims_for_resolve([ value for value in resolved_result.values() if 'error' not in value ])