fix for takeover height calculation

This commit is contained in:
Lex Berezhny 2020-09-25 15:02:31 -04:00
parent 85b8877933
commit b9cf130344
2 changed files with 10 additions and 1 deletions

View file

@ -195,7 +195,7 @@ class BlockchainDB:
name, claimID, activationHeight, expirationHeight, originalHeight,
(SELECT
CASE WHEN takeover.claimID = claim.claimID THEN takeover.height END
FROM takeover WHERE takeover.name = claim.name
FROM takeover WHERE takeover.name = claim.nodename
ORDER BY height DESC LIMIT 1
) AS takeoverHeight,
(SELECT find_shortest_id(c.claimid, claim.claimid) FROM claim AS c

View file

@ -984,6 +984,15 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase):
class TestClaimtrieSync(SyncingBlockchainTestCase):
async def test_claimtrie_name_normalization_query_bug(self):
# this used to fail due to bug in sync_get_claim_metadata
await self.generate(150) # enable normalization
txid1 = await self.create_claim(name='Thing')
await self.generate(1)
claim1, = await self.db.search_claims()
self.assertEqual(claim1.meta['takeover_height'], 252)
self.assertEqual(claim1.tx_ref.id, txid1)
async def test_example_from_spec(self):
# https://spec.lbry.com/#claim-activation-example
advance, state = self.advance, self.state