uncomment tests, add remove_duplicates param

Cleanup prints and commented out code

remove print

don't do list claims

cleanup
This commit is contained in:
Jeffrey Picard 2021-06-08 22:07:07 -04:00 committed by Victor Shyba
parent 886587848b
commit 9f65799a3d
6 changed files with 30 additions and 43 deletions

View file

@ -2515,7 +2515,6 @@ class Daemon(metaclass=JSONRPCServerType):
wallet = self.wallet_manager.get_wallet_or_default(kwargs.pop('wallet_id', None))
kwargs.update({'offset': page_size * (page_num - 1), 'limit': page_size})
txos, blocked, _, total = await self.ledger.claim_search(wallet.accounts, **kwargs)
print(len(txos))
result = {
"items": txos,
"blocked": blocked,

View file

@ -639,11 +639,6 @@ class CommandTestCase(IntegrationTestCase):
return await self.out(self.daemon.jsonrpc_txo_plot(*args, **kwargs))
async def claim_list(self, *args, **kwargs):
if os.environ.get("GO_HUB") and os.environ.get("GO_HUB") == "true":
kwargs['new_sdk_server'] = "localhost:50051"
kwargs = fix_kwargs_for_hub(**kwargs)
res = await self.out(self.hub.claim_search(**kwargs))
return res
return (await self.out(self.daemon.jsonrpc_claim_list(*args, **kwargs)))['items']
async def stream_list(self, *args, **kwargs):

View file

@ -1,4 +1,3 @@
import base64
import os
import copy
import time
@ -772,15 +771,11 @@ class Ledger(metaclass=LedgerRegistry):
include_received_tips=False,
hub_server=False) -> Tuple[List[Output], dict, int, int]:
encoded_outputs = await query
# log.warning(base64.b64decode(encoded_outputs))
# if os.environ.get("GO_HUB") and os.environ.get("GO_HUB") == "true":
if hub_server:
outputs = Outputs.from_grpc(encoded_outputs)
else:
outputs = Outputs.from_base64(encoded_outputs or b'') # TODO: why is the server returning None?
txs: List[Transaction] = []
log.warning(outputs)
log.warning(outputs.txs)
if len(outputs.txs) > 0:
async for tx in self.request_transactions(tuple(outputs.txs), cached=True):
txs.extend(tx.values())

View file

@ -1,6 +1,7 @@
import logging
import asyncio
import json
import os
import socket
import random
from time import perf_counter
@ -478,15 +479,15 @@ class Network:
return result['result']
async def new_claim_search(self, server, **kwargs):
if "offset" in kwargs and type(kwargs["offset"]) == int:
kwargs["offset"] = {"value": kwargs["offset"]}
if "limit" in kwargs and type(kwargs["limit"]) == int:
kwargs["limit"] = {"value": kwargs["limit"]}
async with grpc.aio.insecure_channel(server) as channel:
stub = hub_pb2_grpc.HubStub(channel)
log.warning(kwargs)
response = await stub.Search(SearchRequest(**kwargs))
return response
if os.environ.get("GO_HUB") and os.environ.get("GO_HUB") == "true":
if "offset" in kwargs and type(kwargs["offset"]) == int:
kwargs["offset"] = {"value": kwargs["offset"]}
if "limit" in kwargs and type(kwargs["limit"]) == int:
kwargs["limit"] = {"value": kwargs["limit"]}
async with grpc.aio.insecure_channel(server) as channel:
stub = hub_pb2_grpc.HubStub(channel)
response = await stub.Search(SearchRequest(**kwargs))
return response
kwargs['protobuf'] = True
message = {"method": "claim_search", "params": kwargs}

View file

@ -497,7 +497,7 @@ def fix_kwargs_for_hub(**kwargs):
"fee_currency", "media_type", "stream_type", "claim_type", "description", "author", "title",
"canonical_url", "short_url", "claim_id"}
value_fields = {"offset", "limit", "has_channel_signature", "has_source", "has_no_source",
"limit_claims_per_channel", "tx_nout",
"limit_claims_per_channel", "tx_nout", "remove_duplicates",
"signature_valid", "is_controlling", "amount_order"}
ops = {'<=': 'lte', '>=': 'gte', '<': 'lt', '>': 'gt'}
for key in list(kwargs.keys()):

View file

@ -73,10 +73,10 @@ class ClaimSearchCommand(ClaimTestCase):
if os.environ.get("GO_HUB") and os.environ["GO_HUB"] == "true":
kwargs['new_sdk_server'] = self.hub.hostname + ":" + str(self.hub.rpcport)
results = await self.claim_search(**kwargs)
# for claim, result in zip(claims, results):
# print((claim['txid'], self.get_claim_id(claim)),
# (result['txid'], result['claim_id'], result['height']))
self.assertEqual(len(claims), len(results))
for claim, result in zip(claims, results):
print((claim['txid'], self.get_claim_id(claim)),
(result['txid'], result['claim_id'], result['height']))
for claim, result in zip(claims, results):
self.assertEqual(
(claim['txid'], self.get_claim_id(claim)),
@ -95,7 +95,7 @@ class ClaimSearchCommand(ClaimTestCase):
# f"(expected {claim['outputs'][0]['name']}) != (got {result['name']})"
# )
@skip("okay")
# @skip("okay")
async def test_basic_claim_search(self):
await self.create_channel()
channel_txo = self.channel['outputs'][0]
@ -180,7 +180,7 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([three], claim_id=self.get_claim_id(three))
await self.assertFindsClaims([three], claim_id=self.get_claim_id(three), text='*')
@skip("okay")
# @skip("okay")
async def test_source_filter(self):
channel = await self.channel_create('@abc')
no_source = await self.stream_create('no-source', data=None)
@ -195,22 +195,19 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([channel_repost, no_source_repost, normal_repost, normal, no_source, channel])
# await self.assertListsClaims([channel_repost, no_source_repost, normal_repost, normal, no_source, channel])
@skip("Okay???")
# @skip("okay")
async def test_pagination(self):
await self.create_channel()
await self.create_lots_of_streams()
channel_id = (await self.daemon.jsonrpc_resolve(f"@abc"))["@abc"].claim_id
# FIXME: this doesn't work when jsonrpc_claim_search is called directly
new_sdk_server = self.hub.hostname + ":" + str(self.hub.rpcport)
# with and without totals
results = await self.daemon.jsonrpc_claim_search(new_sdk_server=new_sdk_server)
results = await self.daemon.jsonrpc_claim_search()
self.assertEqual(results['total_pages'], 2)
self.assertEqual(results['total_items'], 25)
# FIXME: Do we still need to support this?
# results = await self.daemon.jsonrpc_claim_search(no_totals=True, new_sdk_server=new_sdk_server)
# self.assertNotIn('total_pages', results)
# self.assertNotIn('total_items', results)
results = await self.daemon.jsonrpc_claim_search(no_totals=True)
self.assertNotIn('total_pages', results)
self.assertNotIn('total_items', results)
# defaults
page = await self.claim_search(channel_id=channel_id, order_by=['height', '^name'])
@ -240,7 +237,7 @@ class ClaimSearchCommand(ClaimTestCase):
out_of_bounds = await self.claim_search(page=4, page_size=20, channel_id=channel_id)
self.assertEqual(out_of_bounds, [])
@skip("okay")
# @skip("okay")
async def test_tag_search(self):
claim1 = await self.stream_create('claim1', tags=['aBc'])
claim2 = await self.stream_create('claim2', tags=['#abc', 'def'])
@ -277,7 +274,7 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([claim3], all_tags=['abc', 'ghi'], any_tags=['jkl'], not_tags=['mno'])
await self.assertFindsClaims([claim4, claim3, claim2], all_tags=['abc'], any_tags=['def', 'ghi'])
@skip("okay")
# @skip("okay")
async def test_order_by(self):
height = self.ledger.network.remote_height
claims = [await self.stream_create(f'claim{i}') for i in range(5)]
@ -294,7 +291,7 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims(claims, order_by=["^name"])
@skip("okay")
# @skip("okay")
async def test_search_by_fee(self):
claim1 = await self.stream_create('claim1', fee_amount='1.0', fee_currency='lbc')
claim2 = await self.stream_create('claim2', fee_amount='0.9', fee_currency='lbc')
@ -309,7 +306,7 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([claim3], fee_amount='0.5', fee_currency='lbc')
await self.assertFindsClaims([claim5], fee_currency='usd')
@skip("okay")
# @skip("okay")
async def test_search_by_language(self):
claim1 = await self.stream_create('claim1', fee_amount='1.0', fee_currency='lbc')
claim2 = await self.stream_create('claim2', fee_amount='0.9', fee_currency='lbc')
@ -324,7 +321,7 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([claim5, claim4, claim3], any_languages=['en', 'es'])
await self.assertFindsClaims([], fee_currency='foo')
@skip("okay")
# @skip("okay")
async def test_search_by_channel(self):
match = self.assertFindsClaims
@ -380,7 +377,7 @@ class ClaimSearchCommand(ClaimTestCase):
not_channel_ids=[chan2_id], has_channel_signature=True, valid_channel_signature=True)
await match([], not_channel_ids=[chan1_id, chan2_id], has_channel_signature=True, valid_channel_signature=True)
@skip("okay")
# @skip("okay")
async def test_limit_claims_per_channel(self):
match = self.assertFindsClaims
chan1_id = self.get_claim_id(await self.channel_create('@chan1'))
@ -426,7 +423,7 @@ class ClaimSearchCommand(ClaimTestCase):
height='>218', limit_claims_per_channel=1,
remove_duplicates=True, order_by=['height'])
@skip("okay")
# @skip("okay")
async def test_limit_claims_per_channel_across_sorted_pages(self):
await self.generate(10)
match = self.assertFindsClaims
@ -459,7 +456,7 @@ class ClaimSearchCommand(ClaimTestCase):
limit_claims_per_channel=1, claim_type='stream', order_by=['^height']
)
@skip("okay")
# @skip("okay")
async def test_claim_type_and_media_type_search(self):
# create an invalid/unknown claim
address = await self.account.receiving.get_or_create_usable_address()
@ -502,7 +499,7 @@ class ClaimSearchCommand(ClaimTestCase):
await self.assertFindsClaims([], duration='>100')
await self.assertFindsClaims([], duration='<14')
@skip("okay")
# @skip("okay")
async def test_search_by_text(self):
chan1_id = self.get_claim_id(await self.channel_create('@SatoshiNakamoto'))
chan2_id = self.get_claim_id(await self.channel_create('@Bitcoin'))