2019-09-17 07:19:57 +02:00
|
|
|
from lbry.testcase import CommandTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class AddressManagement(CommandTestCase):
|
|
|
|
|
|
|
|
async def test_address_list(self):
|
2019-09-20 15:25:50 +02:00
|
|
|
addresses = await self.out(self.daemon.jsonrpc_address_list())
|
2019-10-26 05:34:44 +02:00
|
|
|
self.assertItemCount(addresses, 27)
|
2019-09-17 07:19:57 +02:00
|
|
|
|
2019-10-26 05:34:44 +02:00
|
|
|
single = await self.out(self.daemon.jsonrpc_address_list(addresses['items'][11]['address']))
|
|
|
|
self.assertItemCount(single, 1)
|
|
|
|
self.assertEqual(single['items'][0], addresses['items'][11])
|
2019-11-22 21:15:54 +01:00
|
|
|
|
2020-02-18 22:57:52 +01:00
|
|
|
|
2019-11-22 21:27:03 +01:00
|
|
|
class SettingsManagement(CommandTestCase):
|
|
|
|
|
2019-11-22 21:15:54 +01:00
|
|
|
async def test_settings(self):
|
2021-06-14 19:33:07 +02:00
|
|
|
self.assertEqual(self.daemon.jsonrpc_settings_get()['lbryum_servers'][0], ('localhost', 50002))
|
2019-11-22 21:15:54 +01:00
|
|
|
|
2019-11-23 03:41:27 +01:00
|
|
|
setting = self.daemon.jsonrpc_settings_set('lbryum_servers', ['server:50001'])
|
2019-11-22 22:20:24 +01:00
|
|
|
self.assertEqual(setting['lbryum_servers'][0], ('server', 50001))
|
2019-11-23 03:41:27 +01:00
|
|
|
self.assertEqual(self.daemon.jsonrpc_settings_get()['lbryum_servers'][0], ('server', 50001))
|
2019-11-22 22:20:24 +01:00
|
|
|
|
2019-11-23 03:41:27 +01:00
|
|
|
setting = self.daemon.jsonrpc_settings_clear('lbryum_servers')
|
2020-02-11 22:13:55 +01:00
|
|
|
self.assertEqual(setting['lbryum_servers'][0], ('spv11.lbry.com', 50001))
|
|
|
|
self.assertEqual(self.daemon.jsonrpc_settings_get()['lbryum_servers'][0], ('spv11.lbry.com', 50001))
|
2020-02-18 22:57:52 +01:00
|
|
|
|
|
|
|
# test_privacy_settings (merged for reducing test time, unmerge when its fast)
|
|
|
|
# tests that changing share_usage_data propagates to the relevant properties
|
|
|
|
self.assertFalse(self.daemon.jsonrpc_settings_get()['share_usage_data'])
|
|
|
|
self.daemon.jsonrpc_settings_set('share_usage_data', True)
|
|
|
|
self.assertTrue(self.daemon.jsonrpc_settings_get()['share_usage_data'])
|
|
|
|
self.assertTrue(self.daemon.analytics_manager.enabled)
|
|
|
|
self.daemon.jsonrpc_settings_set('share_usage_data', False)
|
2020-03-11 00:50:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TroubleshootingCommands(CommandTestCase):
|
|
|
|
async def test_tracemalloc_commands(self):
|
2020-03-16 15:29:16 +01:00
|
|
|
self.addCleanup(self.daemon.jsonrpc_tracemalloc_disable)
|
2020-03-16 10:39:42 +01:00
|
|
|
self.assertFalse(self.daemon.jsonrpc_tracemalloc_disable())
|
|
|
|
self.assertTrue(self.daemon.jsonrpc_tracemalloc_enable())
|
2020-03-11 01:39:42 +01:00
|
|
|
|
|
|
|
class WeirdObject():
|
|
|
|
pass
|
|
|
|
hold_em = [WeirdObject() for _ in range(500)]
|
2020-03-11 21:59:56 +01:00
|
|
|
top = self.daemon.jsonrpc_tracemalloc_top(1)
|
|
|
|
self.assertEqual(1, len(top))
|
|
|
|
self.assertEqual('hold_em = [WeirdObject() for _ in range(500)]', top[0]['code'])
|
|
|
|
self.assertTrue(top[0]['line'].startswith('other/test_other_commands.py:'))
|
|
|
|
self.assertGreaterEqual(top[0]['count'], 500)
|
|
|
|
self.assertGreater(top[0]['size'], 0) # just matters that its a positive integer
|