From 816cde32a937b64346b421c122692b2d97c9430b Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sun, 23 Jun 2019 10:56:59 -0400 Subject: [PATCH] fix support reorg error --- lbry/lbry/wallet/server/db.py | 2 +- .../tests/integration/test_resolve_command.py | 34 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lbry/lbry/wallet/server/db.py b/lbry/lbry/wallet/server/db.py index fb5d02cb7..e3757bbc3 100644 --- a/lbry/lbry/wallet/server/db.py +++ b/lbry/lbry/wallet/server/db.py @@ -394,7 +394,7 @@ class SQLDB: )) if supports: self.db.executemany( - "INSERT INTO support (" + "INSERT OR IGNORE INTO support (" " txo_hash, tx_position, height, claim_hash, amount" ") " "VALUES (?, ?, ?, ?, ?)", supports diff --git a/lbry/tests/integration/test_resolve_command.py b/lbry/tests/integration/test_resolve_command.py index 63af54778..72109eb2b 100644 --- a/lbry/tests/integration/test_resolve_command.py +++ b/lbry/tests/integration/test_resolve_command.py @@ -322,18 +322,40 @@ class ResolveAfterReorg(BaseResolveTestCase): async def test_reorg(self): self.assertEqual(self.ledger.headers.height, 206) - name = '@abc' + channel_name = '@abc' channel_id = self.get_claim_id( - await self.channel_create(name, '0.01') + await self.channel_create(channel_name, '0.01') ) - self.assertNotIn('error', (await self.resolve(name))[name]) + self.assertNotIn('error', (await self.resolve(channel_name))[channel_name]) await self.reorg(206) - self.assertNotIn('error', (await self.resolve(name))[name]) + self.assertNotIn('error', (await self.resolve(channel_name))[channel_name]) + + stream_name = 'foo' + stream_id = self.get_claim_id( + await self.stream_create(stream_name, '0.01', channel_id=channel_id) + ) + self.assertNotIn('error', (await self.resolve(stream_name))[stream_name]) + await self.reorg(206) + self.assertNotIn('error', (await self.resolve(stream_name))[stream_name]) + + await self.support_create(stream_id, '0.01') + self.assertNotIn('error', (await self.resolve(stream_name))[stream_name]) + await self.reorg(206) + self.assertNotIn('error', (await self.resolve(stream_name))[stream_name]) + + await self.stream_abandon(stream_id) + self.assertNotIn('error', (await self.resolve(channel_name))[channel_name]) + self.assertIn('error', (await self.resolve(stream_name))[stream_name]) + await self.reorg(206) + self.assertNotIn('error', (await self.resolve(channel_name))[channel_name]) + self.assertIn('error', (await self.resolve(stream_name))[stream_name]) await self.channel_abandon(channel_id) - self.assertIn('error', (await self.resolve(name))[name]) + self.assertIn('error', (await self.resolve(channel_name))[channel_name]) + self.assertIn('error', (await self.resolve(stream_name))[stream_name]) await self.reorg(206) - self.assertIn('error', (await self.resolve(name))[name]) + self.assertIn('error', (await self.resolve(channel_name))[channel_name]) + self.assertIn('error', (await self.resolve(stream_name))[stream_name]) def generate_signed_legacy(address: bytes, output: Output):