From a01e2d346914126c1184e7f35e06b2afed65cec8 Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Mon, 29 Jul 2024 03:53:28 +0300 Subject: [PATCH] Add a test for the saved I2P keys --- minode/tests/test_process.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/minode/tests/test_process.py b/minode/tests/test_process.py index 0cdff39..826007c 100644 --- a/minode/tests/test_process.py +++ b/minode/tests/test_process.py @@ -10,6 +10,7 @@ import unittest import psutil +from minode.i2p import util from minode.structure import NetAddrNoPrefix try: @@ -158,10 +159,21 @@ class TestProcessI2P(TestProcess): else: cls.freezed = True - def test_connections(self): - """Ensure all connections are I2P""" + def setUp(self): + """Fail before any test if I2PController freezed""" if self.freezed: self.fail('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() for c in self.connections(): self.assertEqual(c.raddr[0], '127.0.0.1')