forked from LBRYCommunity/lbry-sdk
fix effective_amount
This commit is contained in:
parent
9c1d593e54
commit
4783e6da1f
2 changed files with 21 additions and 0 deletions
|
@ -32,6 +32,15 @@ BASE_SELECT_SUPPORT_COLUMNS = BASE_SELECT_TXO_COLUMNS + [
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def compat_layer(**constraints):
|
||||||
|
# for old sdk, to be removed later
|
||||||
|
replacements = {"effective_amount": "staked_amount"}
|
||||||
|
for old_key, new_key in replacements.items():
|
||||||
|
if old_key in constraints:
|
||||||
|
constraints[new_key] = constraints.pop(old_key)
|
||||||
|
return constraints
|
||||||
|
|
||||||
|
|
||||||
def select_supports(cols: List = None, **constraints) -> Select:
|
def select_supports(cols: List = None, **constraints) -> Select:
|
||||||
if cols is None:
|
if cols is None:
|
||||||
cols = BASE_SELECT_SUPPORT_COLUMNS
|
cols = BASE_SELECT_SUPPORT_COLUMNS
|
||||||
|
@ -82,6 +91,7 @@ BASE_SELECT_CLAIM_COLUMNS = BASE_SELECT_TXO_COLUMNS + [
|
||||||
|
|
||||||
|
|
||||||
def select_claims(cols: List = None, for_count=False, **constraints) -> Select:
|
def select_claims(cols: List = None, for_count=False, **constraints) -> Select:
|
||||||
|
constraints = compat_layer(**constraints)
|
||||||
if cols is None:
|
if cols is None:
|
||||||
cols = BASE_SELECT_CLAIM_COLUMNS
|
cols = BASE_SELECT_CLAIM_COLUMNS
|
||||||
if 'order_by' in constraints:
|
if 'order_by' in constraints:
|
||||||
|
|
|
@ -919,6 +919,17 @@ class TestGeneralBlockchainSync(SyncingBlockchainTestCase):
|
||||||
resolutions = Outputs.from_base64(await self.db.protobuf_resolve(["@notfound#ab/notfound"]))
|
resolutions = Outputs.from_base64(await self.db.protobuf_resolve(["@notfound#ab/notfound"]))
|
||||||
self.assertEqual(resolutions.txos[0].error.text, "Could not find channel in \"@notfound#ab/notfound\".")
|
self.assertEqual(resolutions.txos[0].error.text, "Could not find channel in \"@notfound#ab/notfound\".")
|
||||||
|
|
||||||
|
async def test_claim_search_effective_amount(self):
|
||||||
|
claim = await self.get_claim(await self.create_claim(claim_id_startswith='ab', is_channel=True, amount='0.42'))
|
||||||
|
await self.generate(1)
|
||||||
|
results = await self.db.search_claims(staked_amount=42000000)
|
||||||
|
self.assertEqual(claim.claim_id, results[0].claim_id)
|
||||||
|
# compat layer
|
||||||
|
results = await self.db.search_claims(effective_amount=42000000)
|
||||||
|
self.assertEqual(claim.claim_id, results[0].claim_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestClaimtrieSync(SyncingBlockchainTestCase):
|
class TestClaimtrieSync(SyncingBlockchainTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue