From bc28976e1276b0b83c9707ee628a38726569ab2c Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sun, 25 Nov 2018 22:00:21 -0300 Subject: [PATCH] adds test for claims on abandoned channels --- tests/integration/wallet/test_commands.py | 26 +++++++++++++++++++++-- tox.ini | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/integration/wallet/test_commands.py b/tests/integration/wallet/test_commands.py index 3cc1c86e1..cf08827db 100644 --- a/tests/integration/wallet/test_commands.py +++ b/tests/integration/wallet/test_commands.py @@ -482,12 +482,12 @@ class ClaimManagement(CommandTestCase): VERBOSITY = logging.WARN - async def make_claim(self, name='hovercraft', amount='1.0', data=b'hi!'): + async def make_claim(self, name='hovercraft', amount='1.0', data=b'hi!', channel_name=None): with tempfile.NamedTemporaryFile() as file: file.write(data) file.flush() claim = await self.out(self.daemon.jsonrpc_publish( - name, amount, file_path=file.name + name, amount, file_path=file.name, channel_name=channel_name )) self.assertTrue(claim['success']) await self.on_transaction_dict(claim['tx']) @@ -610,6 +610,28 @@ class ClaimManagement(CommandTestCase): await self.out(self.daemon.jsonrpc_claim_abandon(claim['claim_id'])) self.assertEqual('9.97968399', await self.daemon.jsonrpc_account_balance()) + async def test_abandoned_channel_with_signed_claims(self): + channel = await self.out(self.daemon.jsonrpc_channel_new('@abc', "1.0")) + self.assertTrue(channel['success']) + await self.confirm_tx(channel['tx']['txid']) + claim = await self.make_claim(amount='0.0001', name='on-channel-claim', channel_name='@abc') + self.assertTrue(claim['success']) + abandon = await self.out(self.daemon.jsonrpc_claim_abandon(txid=channel['tx']['txid'], nout=0, blocking=False)) + self.assertTrue(abandon['success']) + channel = await self.out(self.daemon.jsonrpc_channel_new('@abc', "1.0")) + self.assertTrue(channel['success']) + await self.confirm_tx(channel['tx']['txid']) + + # Original channel doesnt exists anymore, so the signature is invalid. For invalid signatures, resolution is + # only possible when using the name + claim id + response = await self.out(self.daemon.jsonrpc_resolve(uri='lbry://@abc/on-channel-claim')) + self.assertNotIn('claim', response['lbry://@abc/on-channel-claim']) + response = await self.out(self.daemon.jsonrpc_resolve(uri='lbry://on-channel-claim')) + self.assertNotIn('claim', response['lbry://on-channel-claim']) + direct_uri = 'lbry://on-channel-claim#' + claim['claim_id'] + response = await self.out(self.daemon.jsonrpc_resolve(uri=direct_uri)) + self.assertIn('claim', response[direct_uri]) + async def test_regular_supports_and_tip_supports(self): # account2 will be used to send tips and supports to account1 account2_id = (await self.daemon.jsonrpc_account_create('second account'))['id'] diff --git a/tox.ini b/tox.ini index c13aa1f46..4d186c662 100644 --- a/tox.ini +++ b/tox.ini @@ -19,5 +19,6 @@ commands = coverage run -p --source={envsitepackagesdir}/lbrynet -m twisted.trial --reactor=asyncio integration.wallet.test_commands.ClaimManagement.test_publishing_checks_all_accounts_for_certificate coverage run -p --source={envsitepackagesdir}/lbrynet -m twisted.trial --reactor=asyncio integration.wallet.test_commands.ClaimManagement.test_updating_claim_includes_claim_value_in_balance_check coverage run -p --source={envsitepackagesdir}/lbrynet -m twisted.trial --reactor=asyncio integration.wallet.test_commands.ClaimManagement.test_abandoning_claim_at_loss + coverage run -p --source={envsitepackagesdir}/lbrynet -m twisted.trial --reactor=asyncio integration.wallet.test_commands.ClaimManagement.test_abandoned_channel_with_signed_claims coverage run -p --source={envsitepackagesdir}/lbrynet -m twisted.trial --reactor=asyncio integration.wallet.test_commands.ClaimManagement.test_regular_supports_and_tip_supports coverage run -p --source={envsitepackagesdir}/lbrynet -m twisted.trial --reactor=asyncio integration.wallet.test_commands.EpicAdventuresOfChris45