fix and add test for abandoning a controlling in the same block a new claim is made

This commit is contained in:
Jack Robison 2021-10-01 13:52:33 -04:00 committed by Victor Shyba
parent d0ed7593de
commit afa710dcb5
2 changed files with 12 additions and 1 deletions

View file

@ -784,7 +784,7 @@ class BlockProcessor:
nothing_is_controlling = not controlling nothing_is_controlling = not controlling
staged_is_controlling = False if not controlling else claim_hash == controlling.claim_hash staged_is_controlling = False if not controlling else claim_hash == controlling.claim_hash
controlling_is_abandoned = False if not controlling else \ controlling_is_abandoned = False if not controlling else \
controlling.claim_hash in names_with_abandoned_or_updated_controlling_claims name in names_with_abandoned_or_updated_controlling_claims
if nothing_is_controlling or staged_is_controlling or controlling_is_abandoned: if nothing_is_controlling or staged_is_controlling or controlling_is_abandoned:
delay = 0 delay = 0

View file

@ -1379,6 +1379,17 @@ class ResolveClaimTakeovers(BaseResolveTestCase):
len((await self.conductor.spv_node.server.bp.db.search_index.search(claim_name=name))[0]), 2 len((await self.conductor.spv_node.server.bp.db.search_index.search(claim_name=name))[0]), 2
) )
async def test_abandon_controlling_same_block_as_new_claim(self):
name = 'derp'
first_claim_id = (await self.stream_create(name, '0.1'))['outputs'][0]['claim_id']
await self.generate(64)
await self.assertNameState(271, name, first_claim_id, last_takeover_height=207, non_winning_claims=[])
await self.daemon.jsonrpc_txo_spend(type='stream', claim_id=first_claim_id)
second_claim_id = (await self.stream_create(name, '0.1', allow_duplicate_name=True))['outputs'][0]['claim_id']
await self.assertNameState(272, name, second_claim_id, last_takeover_height=272, non_winning_claims=[])
async def test_trending(self): async def test_trending(self):
async def get_trending_score(claim_id): async def get_trending_score(claim_id):
return (await self.conductor.spv_node.server.bp.db.search_index.search( return (await self.conductor.spv_node.server.bp.db.search_index.search(