forked from LBRYCommunity/lbry-sdk
fixes
This commit is contained in:
parent
aa9365f218
commit
915233c96c
3 changed files with 13 additions and 23 deletions
|
@ -197,7 +197,7 @@ class Database:
|
||||||
return await self.run(q.has_claims)
|
return await self.run(q.has_claims)
|
||||||
|
|
||||||
async def has_supports(self):
|
async def has_supports(self):
|
||||||
return await self.run(q.has_claims)
|
return await self.run(q.has_supports)
|
||||||
|
|
||||||
async def get_best_block_height(self) -> int:
|
async def get_best_block_height(self) -> int:
|
||||||
return await self.run(q.get_best_block_height)
|
return await self.run(q.get_best_block_height)
|
||||||
|
|
|
@ -134,7 +134,10 @@ def distribute_unspent_txos(
|
||||||
total = 0
|
total = 0
|
||||||
buckets = []
|
buckets = []
|
||||||
for bucket in context().fetchall(sql):
|
for bucket in context().fetchall(sql):
|
||||||
if len(buckets) > 0 and buckets[-1][-1] == bucket['start_height']:
|
if len(buckets) > 0:
|
||||||
|
if buckets[-1][-1] == bucket['start_height']:
|
||||||
|
if bucket['start_height'] == bucket['end_height']:
|
||||||
|
continue
|
||||||
bucket['start_height'] += 1
|
bucket['start_height'] += 1
|
||||||
total += bucket['items']
|
total += bucket['items']
|
||||||
buckets.append((bucket['start_height'], bucket['end_height']))
|
buckets.append((bucket['start_height'], bucket['end_height']))
|
||||||
|
|
|
@ -429,19 +429,18 @@ class TestMultiBlockFileSyncing(BasicBlockchainTestCase):
|
||||||
self.assertEqual(279, (await db.get_blocks_in_file(1, 251))[28]['height'])
|
self.assertEqual(279, (await db.get_blocks_in_file(1, 251))[28]['height'])
|
||||||
|
|
||||||
# get_takeover_count
|
# get_takeover_count
|
||||||
self.assertEqual(0, await db.get_takeover_count(0, 101))
|
self.assertEqual(0, await db.get_takeover_count(0, 100))
|
||||||
self.assertEqual(2, await db.get_takeover_count(101, 102))
|
self.assertEqual(3610, await db.get_takeover_count(101, 102))
|
||||||
self.assertEqual(1, await db.get_takeover_count(103, 251))
|
self.assertEqual(0, await db.get_takeover_count(103, 1000))
|
||||||
self.assertEqual(0, await db.get_takeover_count(252, 291))
|
|
||||||
|
|
||||||
# get_takeovers
|
# get_takeovers
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
[
|
[
|
||||||
{'height': 102, 'name': b'one'},
|
{'height': 250, 'name': ''}, # normalization on regtest kicks-in
|
||||||
{'height': 102, 'name': b'two'},
|
{'height': 102, 'name': 'one'},
|
||||||
{'height': 250, 'name': b''} # normalization on regtest kicks-in
|
{'height': 102, 'name': 'two'},
|
||||||
],
|
],
|
||||||
[{'name': takeover['name'], 'height': takeover['height']}
|
[{'name': takeover['normalized'], 'height': takeover['height']}
|
||||||
for takeover in await db.get_takeovers(0, 291)]
|
for takeover in await db.get_takeovers(0, 291)]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -449,18 +448,6 @@ class TestMultiBlockFileSyncing(BasicBlockchainTestCase):
|
||||||
self.assertEqual(3610, await db.get_claim_metadata_count(0, 500))
|
self.assertEqual(3610, await db.get_claim_metadata_count(0, 500))
|
||||||
self.assertEqual(0, await db.get_claim_metadata_count(500, 1000))
|
self.assertEqual(0, await db.get_claim_metadata_count(500, 1000))
|
||||||
|
|
||||||
# get_claim_metadata
|
|
||||||
self.assertEqual(
|
|
||||||
[
|
|
||||||
{'name': b'one', 'activation_height': 102, 'takeover_height': 102, 'is_controlling': True},
|
|
||||||
{'name': b'two', 'activation_height': 102, 'takeover_height': 102, 'is_controlling': True},
|
|
||||||
],
|
|
||||||
[{
|
|
||||||
'name': r['name'], 'is_controlling': bool(r['is_controlling']),
|
|
||||||
'activation_height': r['activation_height'], 'takeover_height': r['takeover_height'],
|
|
||||||
} for r in sorted(await db.get_claim_metadata(102, 102), key=lambda r: r['name']) if r['is_controlling']]
|
|
||||||
)
|
|
||||||
|
|
||||||
# get_support_metadata_count
|
# get_support_metadata_count
|
||||||
self.assertEqual(2, await db.get_support_metadata_count(0, 500))
|
self.assertEqual(2, await db.get_support_metadata_count(0, 500))
|
||||||
self.assertEqual(0, await db.get_support_metadata_count(500, 1000))
|
self.assertEqual(0, await db.get_support_metadata_count(500, 1000))
|
||||||
|
|
Loading…
Reference in a new issue