Skip to content

Commit

Permalink
test case for stream_type search on claims missing source + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shyba committed Nov 29, 2021
1 parent 11c3ea0 commit e50c69f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lbry/wallet/server/leveldb.py
Expand Up @@ -565,7 +565,7 @@ def _prepare_claim_metadata(self, claim_hash: bytes, claim: ResolveResult):
reposted_has_source = False if not reposted_metadata.is_stream else reposted_metadata.stream.has_source
reposted_claim_type = CLAIM_TYPES[reposted_metadata.claim_type]
reposted_stream_type = STREAM_TYPES[guess_stream_type(reposted_metadata.stream.source.media_type)] \
if reposted_metadata.is_stream else 0
if reposted_has_source else 0
reposted_media_type = reposted_metadata.stream.source.media_type if reposted_metadata.is_stream else 0
if not reposted_metadata.is_stream or not reposted_metadata.stream.has_fee:
reposted_fee_amount = 0
Expand Down Expand Up @@ -626,7 +626,8 @@ def _prepare_claim_metadata(self, claim_hash: bytes, claim: ResolveResult):
'has_source': reposted_has_source if metadata.is_repost else (
False if not metadata.is_stream else metadata.stream.has_source),
'stream_type': STREAM_TYPES[guess_stream_type(metadata.stream.source.media_type)]
if metadata.is_stream else reposted_stream_type if metadata.is_repost else 0,
if metadata.is_stream and metadata.stream.has_source
else reposted_stream_type if metadata.is_repost else 0,
'media_type': metadata.stream.source.media_type
if metadata.is_stream else reposted_media_type if metadata.is_repost else None,
'fee_amount': fee_amount if not metadata.is_repost else reposted_fee_amount,
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/claims/test_claim_commands.py
Expand Up @@ -12,6 +12,7 @@
from lbry.extras.daemon.daemon import DEFAULT_PAGE_SIZE
from lbry.testcase import CommandTestCase
from lbry.wallet.orchstr8.node import SPVNode
from lbry.wallet.server.db.common import STREAM_TYPES
from lbry.wallet.transaction import Transaction, Output
from lbry.wallet.util import satoshis_to_coins as lbc
from lbry.crypto.hash import sha256
Expand Down Expand Up @@ -227,6 +228,7 @@ async def test_source_filter(self):
await self.assertListsClaims([channel_repost, no_source_repost, normal_repost, normal], has_source=True)
await self.assertFindsClaims([channel_repost, no_source_repost, normal_repost, normal, no_source, channel])
await self.assertListsClaims([channel_repost, no_source_repost, normal_repost, normal, no_source, channel])
await self.assertFindsClaims([normal_repost, normal], stream_types=list(STREAM_TYPES.keys()))

async def test_pagination(self):
await self.create_channel()
Expand Down

0 comments on commit e50c69f

Please sign in to comment.