From 2b950ff5ddb99bc1cda90907ffcfd9c86771f0ce Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 14 May 2021 12:25:40 -0400 Subject: [PATCH 1/2] fix bug in collection_update --replace --- lbry/extras/daemon/daemon.py | 3 --- tests/integration/blockchain/test_claim_commands.py | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lbry/extras/daemon/daemon.py b/lbry/extras/daemon/daemon.py index e16f3e763..de401ed33 100644 --- a/lbry/extras/daemon/daemon.py +++ b/lbry/extras/daemon/daemon.py @@ -3938,9 +3938,6 @@ class Daemon(metaclass=JSONRPCServerType): if replace: claim = Claim() - claim.collection.message.source.CopyFrom( - old_txo.claim.collection.message.source - ) claim.collection.update(**kwargs) else: claim = Claim.from_bytes(old_txo.claim.to_bytes()) diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 8ded93654..6ce35e39a 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -2169,7 +2169,7 @@ class CollectionCommands(CommandTestCase): tx = await self.collection_create('radjingles', claims=claim_ids, allow_duplicate_name=True) claim_id2 = self.get_claim_id(tx) self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 2) - + # with clear_claims await self.collection_update(claim_id, clear_claims=True, claims=claim_ids[:2]) collections = await self.out(self.daemon.jsonrpc_collection_list()) self.assertEquals(len(collections['items']), 2) @@ -2177,7 +2177,8 @@ class CollectionCommands(CommandTestCase): resolved_collections = await self.out(self.daemon.jsonrpc_collection_list(resolve=True)) self.assertIn('canonical_url', resolved_collections['items'][0]) - + # with replace + # TODO await self.collection_abandon(claim_id) self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1) From 3784db3308abb2ee7a8f493ae4f937f52dda5620 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sat, 15 May 2021 03:26:46 -0300 Subject: [PATCH 2/2] test collections update with --replace --- .../integration/blockchain/test_claim_commands.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/integration/blockchain/test_claim_commands.py b/tests/integration/blockchain/test_claim_commands.py index 6ce35e39a..a644b394d 100644 --- a/tests/integration/blockchain/test_claim_commands.py +++ b/tests/integration/blockchain/test_claim_commands.py @@ -2172,18 +2172,27 @@ class CollectionCommands(CommandTestCase): # with clear_claims await self.collection_update(claim_id, clear_claims=True, claims=claim_ids[:2]) collections = await self.out(self.daemon.jsonrpc_collection_list()) - self.assertEquals(len(collections['items']), 2) + self.assertEqual(len(collections['items']), 2) self.assertNotIn('canonical_url', collections['items'][0]) resolved_collections = await self.out(self.daemon.jsonrpc_collection_list(resolve=True)) self.assertIn('canonical_url', resolved_collections['items'][0]) # with replace - # TODO + await self.collection_update(claim_id, replace=True, claims=claim_ids[::-1][:2], tags=['cool']) + updated = await self.claim_search(claim_id=claim_id) + self.assertEqual(updated[0]['value']['tags'], ['cool']) + self.assertEqual(updated[0]['value']['claims'], claim_ids[::-1][:2]) + await self.collection_update(claim_id, replace=True, claims=claim_ids[:4], languages=['en', 'pt-BR']) + updated = await self.resolve(f'radjingles:{claim_id}') + self.assertEqual(updated['value']['claims'], claim_ids[:4]) + self.assertNotIn('tags', updated['value']) + self.assertEqual(updated['value']['languages'], ['en', 'pt-BR']) + await self.collection_abandon(claim_id) self.assertItemCount(await self.daemon.jsonrpc_collection_list(), 1) collections = await self.out(self.daemon.jsonrpc_collection_list(resolve_claims=2)) - self.assertEquals(len(collections['items'][0]['claims']), 2) + self.assertEqual(len(collections['items'][0]['claims']), 2) collections = await self.out(self.daemon.jsonrpc_collection_list(resolve_claims=10)) self.assertEqual(len(collections['items'][0]['claims']), 4)