From 1a5292aaf4a84a3b7e1c63b095b5205291201328 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 23 Sep 2020 00:20:08 -0300 Subject: [PATCH] add expiration_height --- lbry/db/queries/search.py | 1 + lbry/db/queries/txio.py | 2 +- lbry/schema/result.py | 2 +- tests/integration/blockchain/test_blockchain.py | 9 +++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lbry/db/queries/search.py b/lbry/db/queries/search.py index 8b16efce1..fc79b5369 100644 --- a/lbry/db/queries/search.py +++ b/lbry/db/queries/search.py @@ -75,6 +75,7 @@ BASE_SELECT_CLAIM_COLUMNS = BASE_SELECT_TXO_COLUMNS + [ Claim.c.activation_height, Claim.c.takeover_height, Claim.c.creation_height, + Claim.c.expiration_height, Claim.c.is_controlling, Claim.c.channel_hash, Claim.c.reposted_count, diff --git a/lbry/db/queries/txio.py b/lbry/db/queries/txio.py index 05f680b1c..a8c8f6ad8 100644 --- a/lbry/db/queries/txio.py +++ b/lbry/db/queries/txio.py @@ -372,7 +372,7 @@ META_ATTRS = ( 'activation_height', 'takeover_height', 'creation_height', 'staked_amount', 'short_url', 'canonical_url', 'staked_support_amount', 'staked_support_count', 'signed_claim_count', 'signed_support_count', 'is_signature_valid', - 'reposted_count', + 'reposted_count', 'expiration_height' ) diff --git a/lbry/schema/result.py b/lbry/schema/result.py index 3d197de0b..48f43a1a9 100644 --- a/lbry/schema/result.py +++ b/lbry/schema/result.py @@ -196,7 +196,7 @@ class Outputs: # txo_message.claim.take_over_height = txo['last_take_over_height'] txo_message.claim.creation_height = txo.meta['creation_height'] txo_message.claim.activation_height = txo.meta['activation_height'] - #txo_message.claim.expiration_height = txo['expiration_height'] + txo_message.claim.expiration_height = txo.meta['expiration_height'] if txo.meta['signed_claim_count'] is not None: txo_message.claim.claims_in_channel = txo.meta['signed_claim_count'] txo_message.claim.effective_amount = txo.meta['staked_amount'] diff --git a/tests/integration/blockchain/test_blockchain.py b/tests/integration/blockchain/test_blockchain.py index a24c9b3bb..f23e7211b 100644 --- a/tests/integration/blockchain/test_blockchain.py +++ b/tests/integration/blockchain/test_blockchain.py @@ -924,6 +924,15 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase): results = await self.db.search_claims(effective_amount=42000000, amount_order=1, order_by=["effective_amount"]) self.assertEqual(claim.claim_id, results[0].claim_id) + async def test_meta_fields_are_translated_to_protobuf(self): + chan_ab = await self.get_claim( + await self.create_claim(claim_id_startswith='ab', is_channel=True)) + await self.create_claim(claim_id_startswith='cd', sign=chan_ab) + await self.generate(1) + resolutions = Outputs.from_base64(await self.db.protobuf_resolve(["@foo#ab/foo#cd"])) + claim = resolutions.txos[0].claim + self.assertEqual(claim.effective_amount, 1000000) + self.assertEqual(claim.expiration_height, 602)