resolve command also returns protobuf

This commit is contained in:
Lex Berezhny 2019-04-21 11:56:19 -04:00
parent 9fae8f5153
commit 6ef1b1dd59
2 changed files with 4 additions and 4 deletions

View file

@ -347,7 +347,7 @@ def _decode_claim_result(claim):
return claim
if 'value' not in claim:
log.warning('Got an invalid claim while parsing, please report: %s', claim)
claim['hex'] = None
claim['protobuf'] = None
claim['value'] = None
backend_message = ' SDK message: ' + claim.get('error', '')
claim['error'] = "Failed to parse: missing value." + backend_message
@ -355,11 +355,11 @@ def _decode_claim_result(claim):
try:
if not isinstance(claim['value'], Claim):
claim['value'] = Claim.from_bytes(unhexlify(claim['value']))
claim['hex'] = hexlify(claim['value'].to_bytes())
claim['protobuf'] = hexlify(claim['value'].to_bytes())
claim['decoded_claim'] = True
except DecodeError:
claim['decoded_claim'] = False
claim['hex'] = claim['value']
claim['protobuf'] = claim['value']
claim['value'] = None
return claim

View file

@ -77,7 +77,7 @@ class ResolveCommand(CommandTestCase):
self.assertSetEqual({'lbry://gibberish'}, set(response))
claim = response['lbry://gibberish']['claim']
self.assertEqual(claim['name'], 'gibberish')
self.assertEqual(claim['hex'], hexlify(b"{'invalid':'json'}").decode())
self.assertEqual(claim['protobuf'], hexlify(b"{'invalid':'json'}").decode())
self.assertFalse(claim['decoded_claim'])
self.assertEqual(claim['txid'], txid)
self.assertEqual(claim['effective_amount'], "0.1")