diff --git a/minode/tests/test_network.py b/minode/tests/test_network.py index c8cdd31..ba4b754 100644 --- a/minode/tests/test_network.py +++ b/minode/tests/test_network.py @@ -142,8 +142,11 @@ class TestNetwork(unittest.TestCase): time_offset_connections(nodes, -4000) -class TestListener(TestProcessProto): - """A separate test case for Listener with a process with --trusted-peer""" +class TestConnection(TestProcessProto): + """ + A base class for test cases using a process with --trusted-peer + to connect to a listener instance + """ _process_cmd = ['minode', '--trusted-peer', '127.0.0.1'] def setUp(self): @@ -154,6 +157,10 @@ class TestListener(TestProcessProto): super().tearDownClass() shared.shutting_down = False + +class TestListener(TestConnection): + """A separate test case for Listener""" + def test_listener(self): """Start Listener and try to connect""" with run_listener() as listener: @@ -215,3 +222,16 @@ class TestListener(TestProcessProto): if c.status == 'fully_established': self.fail('Established a connection') time.sleep(0.5) + + +class TestBehavior(TestConnection): + """Test the behavior of the process with --trusted-peer""" + + def test_advertisement(self): + """Ensure it doesn't advertise to connected peers their own IPs""" + started = time.time() + with run_listener() as _: + while time.time() - started < 30: + if ('127.0.0.1', 8444) in shared.unchecked_node_pool: + self.fail('Got own IP in an addr message') + time.sleep(1)