fix blocking and filtering

This commit is contained in:
Victor Shyba 2021-09-21 03:59:35 -03:00 committed by Jack Robison
parent aa50e6ee66
commit 82fe2a4c8d
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
2 changed files with 9 additions and 3 deletions

View file

@ -129,12 +129,12 @@ class LevelDB:
self.blocked_streams = {}
self.blocked_channels = {}
self.blocking_channel_hashes = {
bytes.fromhex(channel_id)[::-1] for channel_id in blocking_channels if channel_id
bytes.fromhex(channel_id) for channel_id in blocking_channels if channel_id
}
self.filtered_streams = {}
self.filtered_channels = {}
self.filtering_channel_hashes = {
bytes.fromhex(channel_id)[::-1] for channel_id in filtering_channels if channel_id
bytes.fromhex(channel_id) for channel_id in filtering_channels if channel_id
}
self.tx_counts = None

View file

@ -1537,7 +1537,13 @@ class StreamCommands(ClaimTestCase):
blocking_channel_id = self.get_claim_id(
await self.channel_create('@blocking', '0.1')
)
self.conductor.spv_node.server.db.blocking_channel_hashes.add(bytes.fromhex(blocking_channel_id))
# test setting from env vars and starting from scratch
await self.conductor.spv_node.stop(False)
await self.conductor.spv_node.start(self.conductor.blockchain_node,
extraconf={'BLOCKING_CHANNEL_IDS': blocking_channel_id,
'FILTERING_CHANNEL_IDS': filtering_channel_id})
await self.daemon.wallet_manager.reset()
self.assertEqual(0, len(self.conductor.spv_node.server.db.blocked_streams))
await self.stream_repost(bad_content_id, 'block1', '0.1', channel_name='@blocking')
self.assertEqual(1, len(self.conductor.spv_node.server.db.blocked_streams))