2020-03-16 07:28:41 +00:00
|
|
|
import requests
|
|
|
|
|
|
|
|
from lan.getip import best_ip
|
|
|
|
|
2020-03-19 06:44:44 +00:00
|
|
|
from onionrblocks import insert, onionrblockapi
|
|
|
|
|
2020-03-16 07:28:41 +00:00
|
|
|
def test_lan_server(testmanager):
|
|
|
|
|
|
|
|
for i in range(1024, 65536):
|
|
|
|
try:
|
|
|
|
if requests.get(f"http://{best_ip}:{i}/ping").text == 'pong!':
|
2020-03-19 06:44:44 +00:00
|
|
|
bl = insert('test data')
|
|
|
|
if bl not in requests.get(f"http://{best_ip}:{i}/blist/0").text:
|
|
|
|
raise ValueError
|
|
|
|
if onionrblockapi.Block(bl).raw != requests.get(f"http://{best_ip}:{i}/get/{bl}").content:
|
|
|
|
raise ValueError
|
2020-03-16 07:28:41 +00:00
|
|
|
break
|
|
|
|
except requests.exceptions.ConnectionError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise ValueError
|