2019-02-12 03:35:07 +01:00
|
|
|
from integration.testcase import CommandTestCase
|
2019-02-11 23:25:00 +01:00
|
|
|
|
|
|
|
|
|
|
|
class ResolveCommand(CommandTestCase):
|
|
|
|
|
|
|
|
async def test_resolve(self):
|
2019-03-26 03:06:36 +01:00
|
|
|
tx = await self.channel_create('@abc', '0.01')
|
2019-03-24 21:55:04 +01:00
|
|
|
channel_id = tx['outputs'][0]['claim_id']
|
2019-02-11 23:25:00 +01:00
|
|
|
|
|
|
|
# resolving a channel @abc
|
|
|
|
response = await self.resolve('lbry://@abc')
|
|
|
|
self.assertSetEqual({'lbry://@abc'}, set(response))
|
|
|
|
self.assertIn('certificate', response['lbry://@abc'])
|
|
|
|
self.assertNotIn('claim', response['lbry://@abc'])
|
|
|
|
self.assertEqual(response['lbry://@abc']['certificate']['name'], '@abc')
|
|
|
|
self.assertEqual(response['lbry://@abc']['claims_in_channel'], 0)
|
|
|
|
|
2019-03-26 03:06:36 +01:00
|
|
|
await self.stream_create('foo', '0.01', channel_id=channel_id)
|
|
|
|
await self.stream_create('foo2', '0.01', channel_id=channel_id)
|
2019-02-11 23:25:00 +01:00
|
|
|
|
|
|
|
# resolving a channel @abc with some claims in it
|
|
|
|
response = await self.resolve('lbry://@abc')
|
|
|
|
self.assertSetEqual({'lbry://@abc'}, set(response))
|
|
|
|
self.assertIn('certificate', response['lbry://@abc'])
|
|
|
|
self.assertNotIn('claim', response['lbry://@abc'])
|
|
|
|
self.assertEqual(response['lbry://@abc']['certificate']['name'], '@abc')
|
|
|
|
self.assertEqual(response['lbry://@abc']['claims_in_channel'], 2)
|
|
|
|
|
|
|
|
# resolving claim foo within channel @abc
|
|
|
|
response = await self.resolve('lbry://@abc/foo')
|
|
|
|
self.assertSetEqual({'lbry://@abc/foo'}, set(response))
|
|
|
|
claim = response['lbry://@abc/foo']
|
|
|
|
self.assertIn('certificate', claim)
|
|
|
|
self.assertIn('claim', claim)
|
|
|
|
self.assertEqual(claim['claim']['name'], 'foo')
|
|
|
|
self.assertEqual(claim['claim']['channel_name'], '@abc')
|
|
|
|
self.assertEqual(claim['certificate']['name'], '@abc')
|
|
|
|
self.assertEqual(claim['claims_in_channel'], 0)
|
|
|
|
|
|
|
|
# resolving claim foo by itself
|
|
|
|
response = await self.resolve('lbry://foo')
|
|
|
|
self.assertSetEqual({'lbry://foo'}, set(response))
|
|
|
|
claim = response['lbry://foo']
|
|
|
|
self.assertIn('certificate', claim)
|
|
|
|
self.assertIn('claim', claim)
|
|
|
|
self.assertEqual(claim['claim']['name'], 'foo')
|
|
|
|
self.assertEqual(claim['claim']['channel_name'], '@abc')
|
|
|
|
self.assertEqual(claim['certificate']['name'], '@abc')
|
|
|
|
self.assertEqual(claim['claims_in_channel'], 0)
|
2019-02-12 03:35:07 +01:00
|
|
|
|
2019-04-04 00:44:31 +02:00
|
|
|
# resolving from the given permanent url
|
|
|
|
new_response = await self.resolve(claim['claim']['permanent_url'])
|
|
|
|
self.assertEqual(new_response[claim['claim']['permanent_url']], claim)
|
|
|
|
|
2019-02-12 03:35:07 +01:00
|
|
|
# resolving multiple at once
|
|
|
|
response = await self.resolve(['lbry://foo', 'lbry://foo2'])
|
|
|
|
self.assertSetEqual({'lbry://foo', 'lbry://foo2'}, set(response))
|
|
|
|
claim = response['lbry://foo2']
|
|
|
|
self.assertIn('certificate', claim)
|
|
|
|
self.assertIn('claim', claim)
|
|
|
|
self.assertEqual(claim['claim']['name'], 'foo2')
|
|
|
|
self.assertEqual(claim['claim']['channel_name'], '@abc')
|
|
|
|
self.assertEqual(claim['certificate']['name'], '@abc')
|
|
|
|
self.assertEqual(claim['claims_in_channel'], 0)
|
2019-03-29 00:30:58 +01:00
|
|
|
|
|
|
|
# resolve handles invalid data
|
2019-04-01 00:27:38 +02:00
|
|
|
txid = await self.blockchain_claim_name("gibberish", "cafecafe", "0.1")
|
2019-03-29 00:30:58 +01:00
|
|
|
await self.generate(1)
|
|
|
|
response = await self.resolve("lbry://gibberish")
|
|
|
|
self.assertSetEqual({'lbry://gibberish'}, set(response))
|
|
|
|
claim = response['lbry://gibberish']['claim']
|
|
|
|
self.assertEqual(claim['name'], 'gibberish')
|
|
|
|
self.assertEqual(claim['hex'], 'cafecafe')
|
|
|
|
self.assertFalse(claim['decoded_claim'])
|
|
|
|
self.assertEqual(claim['txid'], txid)
|
|
|
|
self.assertEqual(claim['effective_amount'], "0.1")
|