fixing integration tests

This commit is contained in:
Lex Berezhny 2019-05-05 00:36:58 -04:00
parent 8dee83aac0
commit 7ca01511f4
4 changed files with 14 additions and 21 deletions

View file

@ -3234,7 +3234,7 @@ class Daemon(metaclass=JSONRPCServerType):
raise Exception(claim_info['error']) raise Exception(claim_info['error'])
if claim_info["page"] == 0: if claim_info["page"] == 0:
return {'page': 1, 'page_size': 0, 'comments': []} return {'page': 1, 'page_size': 0, 'comments': []}
claim_uri = claim_info["items"][0]['permanent_url'] claim_uri = claim_info["items"][0].permanent_url
# These two cases need separation since getting replies requires a bit of magic # These two cases need separation since getting replies requires a bit of magic
# to reduce request count from O(n^2) to O(1) # to reduce request count from O(n^2) to O(1)
if parent_comment_id: if parent_comment_id:
@ -3351,7 +3351,7 @@ class Daemon(metaclass=JSONRPCServerType):
else: else:
claim_data = await self.jsonrpc_claim_search(claim_id=claim_id) claim_data = await self.jsonrpc_claim_search(claim_id=claim_id)
if 'error' not in claim_data and claim_data['total_pages'] == 1: if 'error' not in claim_data and claim_data['total_pages'] == 1:
uri = claim_data['items'][0]['permanent_url'] uri = claim_data['items'][0].permanent_url
comment_id = await jsonrpc_post(url, 'comment', uri=uri, comment_id = await jsonrpc_post(url, 'comment', uri=uri,
poster=channel_id, message=message) poster=channel_id, message=message)
else: else:

View file

@ -181,13 +181,7 @@ class JSONResponseEncoder(JSONEncoder):
if self.include_protobuf: if self.include_protobuf:
output['protobuf'] = hexlify(txo.claim.to_bytes()) output['protobuf'] = hexlify(txo.claim.to_bytes())
if txo.channel is not None: if txo.channel is not None:
output['signing_channel'] = { output['signing_channel'] = txo.channel
'name': txo.channel.claim_name,
'normalized': txo.channel.normalized_name,
'claim_id': txo.channel.claim_id,
'value': txo.channel.claim,
'meta': self.encode_claim_meta(txo.channel.meta)
}
if check_signature and txo.claim.is_signed: if check_signature and txo.claim.is_signed:
output['is_channel_signature_valid'] = False output['is_channel_signature_valid'] = False
if txo.channel: if txo.channel:

View file

@ -59,9 +59,8 @@ class BasicTransactionTest(IntegrationTestCase):
self.assertEqual(d2l(await self.account.get_balance()), '7.985786') self.assertEqual(d2l(await self.account.get_balance()), '7.985786')
self.assertEqual(d2l(await self.account.get_balance(include_claims=True)), '9.985786') self.assertEqual(d2l(await self.account.get_balance(include_claims=True)), '9.985786')
response = await self.ledger.resolve(0, 10, 'lbry://@bar/foo') response = await self.ledger.resolve(['lbry://@bar/foo'])
self.assertIn('lbry://@bar/foo', response) self.assertEqual(response['lbry://@bar/foo'].claim.claim_type, 'stream')
self.assertIn('claim', response['lbry://@bar/foo'])
abandon_tx = await Transaction.create([Input.spend(stream_tx.outputs[0])], [], [self.account], self.account) abandon_tx = await Transaction.create([Input.spend(stream_tx.outputs[0])], [], [self.account], self.account)
await self.broadcast(abandon_tx) await self.broadcast(abandon_tx)
@ -69,10 +68,10 @@ class BasicTransactionTest(IntegrationTestCase):
await self.blockchain.generate(1) await self.blockchain.generate(1)
await self.ledger.wait(abandon_tx) await self.ledger.wait(abandon_tx)
response = await self.ledger.resolve(0, 10, 'lbry://@bar/foo') response = await self.ledger.resolve(['lbry://@bar/foo'])
self.assertNotIn('claim', response['lbry://@bar/foo']) self.assertIn('error', response['lbry://@bar/foo'])
# checks for expected format in inexistent URIs # checks for expected format in inexistent URIs
response = await self.ledger.resolve(0, 10, 'lbry://404', 'lbry://@404') response = await self.ledger.resolve(['lbry://404', 'lbry://@404'])
self.assertEqual('URI lbry://404 cannot be resolved', response['lbry://404']['error']) self.assertEqual('lbry://404 did not resolve to a claim', response['lbry://404']['error'])
self.assertEqual('URI lbry://@404 cannot be resolved', response['lbry://@404']['error']) self.assertEqual('lbry://@404 did not resolve to a claim', response['lbry://@404']['error'])

View file

@ -34,12 +34,12 @@ class ResolveCommand(CommandTestCase):
self.assertEqual(claim['signing_channel']['name'], '@abc') self.assertEqual(claim['signing_channel']['name'], '@abc')
self.assertTrue(claim['is_channel_signature_valid']) self.assertTrue(claim['is_channel_signature_valid'])
self.assertEqual( self.assertEqual(
claim['claim']['timestamp'], claim['timestamp'],
self.ledger.headers[claim['claim']['height']]['timestamp'] self.ledger.headers[claim['height']]['timestamp']
) )
self.assertEqual( self.assertEqual(
claim['certificate']['timestamp'], claim['signing_channel']['timestamp'],
self.ledger.headers[claim['certificate']['height']]['timestamp'] self.ledger.headers[claim['signing_channel']['height']]['timestamp']
) )
# resolving claim foo by itself # resolving claim foo by itself