From 8d72142390d1fbc59651f735f8bea353da8004b9 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Fri, 8 Oct 2021 16:30:26 -0400 Subject: [PATCH] fix setting references on txos in extra_txos --- lbry/schema/result.py | 8 +++++++- .../integration/claims/test_claim_commands.py | 18 ++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lbry/schema/result.py b/lbry/schema/result.py index eed4b9d6d..4d193133d 100644 --- a/lbry/schema/result.py +++ b/lbry/schema/result.py @@ -180,7 +180,13 @@ class Outputs: if blocked is not None: blocked.to_message(page, extra_txo_rows) for row in extra_txo_rows: - cls.encode_txo(page.extra_txos.add(), row) + txo_message: 'OutputsMessage' = page.extra_txos.add() + if not isinstance(row, Exception): + if row.channel_hash: + set_reference(txo_message.claim.channel, row.channel_hash, extra_txo_rows) + if row.reposted_claim_hash: + set_reference(txo_message.claim.repost, row.reposted_claim_hash, extra_txo_rows) + cls.encode_txo(txo_message, row) for row in txo_rows: # cls.row_to_message(row, page.txos.add(), extra_txo_rows) diff --git a/tests/integration/claims/test_claim_commands.py b/tests/integration/claims/test_claim_commands.py index 7d3e44656..025af4355 100644 --- a/tests/integration/claims/test_claim_commands.py +++ b/tests/integration/claims/test_claim_commands.py @@ -1433,7 +1433,11 @@ class StreamCommands(ClaimTestCase): self.assertTrue(signed['outputs'][0]['is_channel_signature_valid']) async def test_repost(self): - await self.channel_create('@goodies', '1.0') + tx = await self.channel_create('@goodies', '1.0') + goodies_claim_id = self.get_claim_id(tx) + tx = await self.channel_create('@spam', '1.0') + spam_claim_id = self.get_claim_id(tx) + tx = await self.stream_create('newstuff', '1.1', channel_name='@goodies', tags=['foo', 'gaming']) claim_id = self.get_claim_id(tx) @@ -1441,8 +1445,18 @@ class StreamCommands(ClaimTestCase): self.assertItemCount(await self.daemon.jsonrpc_txo_list(reposted_claim_id=claim_id), 0) self.assertItemCount(await self.daemon.jsonrpc_txo_list(type='repost'), 0) - tx = await self.stream_repost(claim_id, 'newstuff-again', '1.1') + tx = await self.stream_repost(claim_id, 'newstuff-again', '1.1', channel_name='@spam') repost_id = self.get_claim_id(tx) + + # test inflating reposted channels works + repost_url = f'newstuff-again:{repost_id}' + self.ledger._tx_cache.clear() + self.assertEqual( + goodies_claim_id, + (await self.out(self.daemon.jsonrpc_resolve(repost_url)) + )[repost_url]['reposted_claim']['signing_channel']['claim_id'] + ) + self.assertItemCount(await self.daemon.jsonrpc_claim_list(claim_type='repost'), 1) self.assertEqual((await self.claim_search(name='newstuff'))[0]['meta']['reposted'], 1) self.assertEqual((await self.claim_search(reposted_claim_id=claim_id))[0]['claim_id'], repost_id)