forked from LBRYCommunity/lbry-sdk
reorgs do not hang the wallet server
This commit is contained in:
parent
bfeed40bfe
commit
fd6cbe0f6c
2 changed files with 32 additions and 2 deletions
|
@ -310,7 +310,7 @@ class SQLDB:
|
|||
claims = self._upsertable_claims(txos, header)
|
||||
if claims:
|
||||
self.db.executemany("""
|
||||
INSERT INTO claim (
|
||||
INSERT OR IGNORE INTO claim (
|
||||
claim_hash, claim_id, claim_name, normalized, txo_hash, tx_position, amount,
|
||||
claim_type, media_type, stream_type, timestamp, creation_timestamp, height,
|
||||
creation_height, release_time, activation_height, expiration_height, short_url)
|
||||
|
|
|
@ -9,7 +9,7 @@ from lbrynet.schema.compat import OldClaimMessage
|
|||
from torba.client.hash import sha256, Base58
|
||||
|
||||
|
||||
class ResolveCommand(CommandTestCase):
|
||||
class BaseResolveTestCase(CommandTestCase):
|
||||
|
||||
def get_claim_id(self, tx):
|
||||
return tx['outputs'][0]['claim_id']
|
||||
|
@ -21,6 +21,9 @@ class ResolveCommand(CommandTestCase):
|
|||
else:
|
||||
self.assertEqual(claim_id, other['claim_id'])
|
||||
|
||||
|
||||
class ResolveCommand(BaseResolveTestCase):
|
||||
|
||||
async def test_resolve_response(self):
|
||||
channel_id = self.get_claim_id(
|
||||
await self.channel_create('@abc', '0.01')
|
||||
|
@ -306,6 +309,33 @@ class ResolveCommand(CommandTestCase):
|
|||
self.assertFalse(called_again.is_set())
|
||||
|
||||
|
||||
class ResolveAfterReorg(BaseResolveTestCase):
|
||||
|
||||
async def reorg(self, start):
|
||||
blocks = self.ledger.headers.height - start
|
||||
self.blockchain._block_expected = start - 1
|
||||
# go back to start
|
||||
await self.blockchain.invalidate_block(self.ledger.headers.hash(start).decode())
|
||||
# go to previous + 1
|
||||
await self.generate(blocks + 2)
|
||||
|
||||
async def test_reorg(self):
|
||||
self.assertEqual(self.ledger.headers.height, 206)
|
||||
|
||||
name = '@abc'
|
||||
channel_id = self.get_claim_id(
|
||||
await self.channel_create(name, '0.01')
|
||||
)
|
||||
self.assertNotIn('error', (await self.resolve(name))[name])
|
||||
await self.reorg(206)
|
||||
self.assertNotIn('error', (await self.resolve(name))[name])
|
||||
|
||||
await self.channel_abandon(channel_id)
|
||||
self.assertIn('error', (await self.resolve(name))[name])
|
||||
await self.reorg(206)
|
||||
self.assertIn('error', (await self.resolve(name))[name])
|
||||
|
||||
|
||||
def generate_signed_legacy(address: bytes, output: Output):
|
||||
decoded_address = Base58.decode(address)
|
||||
claim = OldClaimMessage()
|
||||
|
|
Loading…
Reference in a new issue