From 605fc8ecd8b583798359d0c3f30a8742a23a1e1d Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Wed, 12 Feb 2020 11:51:35 -0500 Subject: [PATCH] claim_search by --claim_type=repost support --- lbry/wallet/server/db/common.py | 1 + lbry/wallet/server/db/writer.py | 1 + tests/integration/blockchain/test_claim_commands.py | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/server/db/common.py b/lbry/wallet/server/db/common.py index 827e4b783..8f75737e7 100644 --- a/lbry/wallet/server/db/common.py +++ b/lbry/wallet/server/db/common.py @@ -1,6 +1,7 @@ CLAIM_TYPES = { 'stream': 1, 'channel': 2, + 'repost': 3 } STREAM_TYPES = { diff --git a/lbry/wallet/server/db/writer.py b/lbry/wallet/server/db/writer.py index db2cda525..2377d46c8 100644 --- a/lbry/wallet/server/db/writer.py +++ b/lbry/wallet/server/db/writer.py @@ -360,6 +360,7 @@ class SQLDB: if isinstance(fee.amount, Decimal): claim_record['fee_amount'] = int(fee.amount*1000) elif claim.is_repost: + claim_record['claim_type'] = CLAIM_TYPES['repost'] claim_record['reposted_claim_hash'] = claim.repost.reference.claim_hash elif claim.is_channel: claim_record['claim_type'] = CLAIM_TYPES['channel'] diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 7e69da840..a912c69f5 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -309,12 +309,14 @@ class ClaimSearchCommand(ClaimTestCase): octet = await self.stream_create() video = await self.stream_create('chrome', file_path=self.video_file_name) image = await self.stream_create('blank-image', data=self.image_data, suffix='.png') + repost = await self.stream_repost(self.get_claim_id(image)) channel = await self.channel_create() unknown = self.sout(tx) # claim_type await self.assertFindsClaims([image, video, octet, unknown], claim_type='stream') await self.assertFindsClaims([channel], claim_type='channel') + await self.assertFindsClaims([repost], claim_type='repost') # stream_type await self.assertFindsClaims([octet, unknown], stream_types=['binary']) @@ -322,7 +324,7 @@ class ClaimSearchCommand(ClaimTestCase): await self.assertFindsClaims([image], stream_types=['image']) await self.assertFindsClaims([image, video], stream_types=['video', 'image']) - # stream_type + # media_type await self.assertFindsClaims([octet, unknown], media_types=['application/octet-stream']) await self.assertFindsClaims([video], media_types=['video/mp4']) await self.assertFindsClaims([image], media_types=['image/png'])