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')
|
2020-03-20 08:50:48 +00:00
|
|
|
bl2 = insert('test data2')
|
|
|
|
l = requests.get(f"http://{best_ip}:{i}/blist/0").text
|
|
|
|
if bl not in l or bl2 not in l:
|
2020-03-19 06:44:44 +00:00
|
|
|
raise ValueError
|
|
|
|
if onionrblockapi.Block(bl).raw != requests.get(f"http://{best_ip}:{i}/get/{bl}").content:
|
|
|
|
raise ValueError
|
2020-03-20 08:50:48 +00:00
|
|
|
|
2020-03-16 07:28:41 +00:00
|
|
|
break
|
2020-03-20 08:50:48 +00:00
|
|
|
|
2020-03-16 07:28:41 +00:00
|
|
|
except requests.exceptions.ConnectionError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise ValueError
|