From 528af27e4aa12c9ead5c3915c9f44cb271cc1127 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 26 Jul 2021 13:00:45 -0400 Subject: [PATCH] fix claim search by fee for claims without fees --- lbry/wallet/server/leveldb.py | 2 +- .../blockchain/test_resolve_command.py | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/server/leveldb.py b/lbry/wallet/server/leveldb.py index 23a54c071..9963ed943 100644 --- a/lbry/wallet/server/leveldb.py +++ b/lbry/wallet/server/leveldb.py @@ -490,7 +490,7 @@ class LevelDB: if not metadata: return if not metadata.is_stream or not metadata.stream.has_fee: - fee_amount = None + fee_amount = 0 else: fee_amount = int(max(metadata.stream.fee.amount or 0, 0) * 1000) if fee_amount >= 9223372036854775807: diff --git a/tests/integration/blockchain/test_resolve_command.py b/tests/integration/blockchain/test_resolve_command.py index 10b894b24..25284a432 100644 --- a/tests/integration/blockchain/test_resolve_command.py +++ b/tests/integration/blockchain/test_resolve_command.py @@ -562,6 +562,44 @@ class ResolveClaimTakeovers(BaseResolveTestCase): await self.assertNoClaimForName(name) await self._test_activation_delay() + async def test_resolve_signed_claims_with_fees(self): + channel_name = '@abc' + channel_id = self.get_claim_id( + await self.channel_create(channel_name, '0.01') + ) + self.assertEqual(channel_id, (await self.assertMatchWinningClaim(channel_name)).claim_hash.hex()) + stream_name = 'foo' + stream_with_no_fee = self.get_claim_id( + await self.stream_create(stream_name, '0.01', channel_id=channel_id) + ) + stream_with_fee = self.get_claim_id( + await self.stream_create('with_a_fee', '0.01', channel_id=channel_id, fee_amount='1', fee_currency='LBC') + ) + greater_than_or_equal_to_zero = [ + claim['claim_id'] for claim in ( + await self.conductor.spv_node.server.bp.db.search_index.search( + channel_id=channel_id, fee_amount=">=0" + ))[0] + ] + self.assertEqual(2, len(greater_than_or_equal_to_zero)) + self.assertSetEqual(set(greater_than_or_equal_to_zero), {stream_with_no_fee, stream_with_fee}) + greater_than_zero = [ + claim['claim_id'] for claim in ( + await self.conductor.spv_node.server.bp.db.search_index.search( + channel_id=channel_id, fee_amount=">0" + ))[0] + ] + self.assertEqual(1, len(greater_than_zero)) + self.assertSetEqual(set(greater_than_zero), {stream_with_fee}) + equal_to_zero = [ + claim['claim_id'] for claim in ( + await self.conductor.spv_node.server.bp.db.search_index.search( + channel_id=channel_id, fee_amount="<=0" + ))[0] + ] + self.assertEqual(1, len(equal_to_zero)) + self.assertSetEqual(set(equal_to_zero), {stream_with_no_fee}) + async def test_early_takeover(self): name = 'derp' # block 207