work on lan transport, added service discovery logic
This commit is contained in:
parent
a8290e2ac3
commit
7bb95c3b87
9 changed files with 223 additions and 0 deletions
35
tests/integration-tests/test_lan_discover.py
Normal file
35
tests/integration-tests/test_lan_discover.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
from unittest.mock import patch
|
||||
import sys, os
|
||||
sys.path.append(".")
|
||||
sys.path.append("src/")
|
||||
import unittest, uuid
|
||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
||||
print("Test directory:", TEST_DIR)
|
||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
||||
from utils import createdirs
|
||||
from onionrcommands import parser
|
||||
import onionrsetup as setup
|
||||
from netcontroller.torcontrol import customtorrc
|
||||
from utils import createdirs
|
||||
from onionrsetup import setup_config, setup_default_plugins
|
||||
from coredb import blockmetadb
|
||||
from etc.onionrvalues import BLOCK_EXPORT_FILE_EXT
|
||||
from threading import Thread
|
||||
|
||||
createdirs.create_dirs()
|
||||
setup_config()
|
||||
setup_default_plugins()
|
||||
import config
|
||||
from filepaths import export_location
|
||||
|
||||
class OnionrTests(unittest.TestCase):
|
||||
def test_lan_discover(self):
|
||||
testargs = ['onionr.py', 'start']
|
||||
with patch.object(sys, 'argv', testargs):
|
||||
try:
|
||||
Thread(target=parser.register, daemon=True).start()
|
||||
except SystemExit:
|
||||
pass
|
||||
|
||||
|
||||
unittest.main()
|
23
tests/test_get_lan_ips.py
Normal file
23
tests/test_get_lan_ips.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys, os
|
||||
sys.path.append(".")
|
||||
sys.path.append("src/")
|
||||
import uuid
|
||||
import ipaddress
|
||||
TEST_DIR = 'testdata/%s-%s' % (uuid.uuid4(), os.path.basename(__file__)) + '/'
|
||||
print("Test directory:", TEST_DIR)
|
||||
os.environ["ONIONR_HOME"] = TEST_DIR
|
||||
import unittest
|
||||
|
||||
from lan.getip import lan_ips
|
||||
|
||||
class TestGetLanIps(unittest.TestCase):
|
||||
def test_get_lan_ips(self):
|
||||
self.assertGreater(len(lan_ips), 0)
|
||||
for ip in lan_ips:
|
||||
ip = ipaddress.IPv4Address(ip)
|
||||
if not ip.is_private or ip.is_multicast or ip.is_reserved:
|
||||
raise ValueError
|
||||
|
||||
|
||||
unittest.main()
|
0
tests/test_lan_server_thread.py
Normal file
0
tests/test_lan_server_thread.py
Normal file
Loading…
Add table
Add a link
Reference in a new issue