fix claim search by fee for claims without fees

This commit is contained in:
Jack Robison 2021-07-26 13:00:45 -04:00 committed by Victor Shyba
parent fe69afaa56
commit 528af27e4a
2 changed files with 39 additions and 1 deletions

View file

@ -490,7 +490,7 @@ class LevelDB:
if not metadata: if not metadata:
return return
if not metadata.is_stream or not metadata.stream.has_fee: if not metadata.is_stream or not metadata.stream.has_fee:
fee_amount = None fee_amount = 0
else: else:
fee_amount = int(max(metadata.stream.fee.amount or 0, 0) * 1000) fee_amount = int(max(metadata.stream.fee.amount or 0, 0) * 1000)
if fee_amount >= 9223372036854775807: if fee_amount >= 9223372036854775807:

View file

@ -562,6 +562,44 @@ class ResolveClaimTakeovers(BaseResolveTestCase):
await self.assertNoClaimForName(name) await self.assertNoClaimForName(name)
await self._test_activation_delay() 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): async def test_early_takeover(self):
name = 'derp' name = 'derp'
# block 207 # block 207