Compare commits

..

3 Commits

Author SHA1 Message Date
d106078dac
Skip tests instead of failing if I2PController freezes
All checks were successful
Testing / default (push) Successful in 6m0s
2024-07-30 01:32:02 +03:00
a01e2d3469
Add a test for the saved I2P keys 2024-07-29 15:44:36 +03:00
0c898f687b
Expect I2PController to start in TestProcess._wait_time before checks,
thus increasing the maximum wait time, but increase also _connection_limit,
because 2 connections it is only the controller and the listener.
2024-07-29 15:43:09 +03:00

View File

@ -1,14 +1,16 @@
"""Blind tests, starting the minode process"""
import unittest
import os
import signal
import socket
import subprocess
import sys
import tempfile
import time
import unittest
import psutil
from minode.i2p import util
from minode.structure import NetAddrNoPrefix
try:
@ -138,10 +140,39 @@ class TestProcess(TestProcessProto):
class TestProcessI2P(TestProcess):
"""Test minode process with --i2p and no IP"""
_process_cmd = ['minode', '--i2p', '--no-ip']
_connection_limit = 4
_listen = True
_listening_port = 8448
@classmethod
def setUpClass(cls):
cls.freezed = False
cls.keyfile = os.path.join(cls.home, 'i2p_dest.pub')
saved = os.path.isfile(cls.keyfile)
super().setUpClass()
for _ in range(cls._wait_time):
if saved:
if cls.process.num_threads() > 3:
break
elif os.path.isfile(cls.keyfile):
break
time.sleep(1)
else:
cls.freezed = True
def setUp(self):
"""Skip any test if I2PController freezed"""
if self.freezed:
raise unittest.SkipTest(
'I2PController has probably failed to start')
def test_saved_keys(self):
"""Check saved i2p keys"""
with open(self.keyfile, 'br') as src:
i2p_dest_pub = src.read()
with open(os.path.join(self.home, 'i2p_dest_priv.key'), 'br') as src:
i2p_dest_priv = src.read()
self.assertEqual(util.pub_from_priv(i2p_dest_priv), i2p_dest_pub)
def test_connections(self):
"""Ensure all connections are I2P"""
super().test_connections()