From b9cf1303449f64f1fa0ba03bda16701d97331015 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 25 Sep 2020 15:02:31 -0400 Subject: [PATCH] fix for takeover height calculation --- lbry/blockchain/database.py | 2 +- tests/integration/blockchain/test_blockchain.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lbry/blockchain/database.py b/lbry/blockchain/database.py index baa68eab4..6ef795d3c 100644 --- a/lbry/blockchain/database.py +++ b/lbry/blockchain/database.py @@ -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 diff --git a/tests/integration/blockchain/test_blockchain.py b/tests/integration/blockchain/test_blockchain.py index 148c62130..91b08c74f 100644 --- a/tests/integration/blockchain/test_blockchain.py +++ b/tests/integration/blockchain/test_blockchain.py @@ -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