Add a test for addr with own IP
This commit is contained in:
parent
af5a8acd21
commit
6146c6ccd6
|
@ -142,8 +142,11 @@ class TestNetwork(unittest.TestCase):
|
||||||
time_offset_connections(nodes, -4000)
|
time_offset_connections(nodes, -4000)
|
||||||
|
|
||||||
|
|
||||||
class TestListener(TestProcessProto):
|
class TestConnection(TestProcessProto):
|
||||||
"""A separate test case for Listener with a process with --trusted-peer"""
|
"""
|
||||||
|
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']
|
_process_cmd = ['minode', '--trusted-peer', '127.0.0.1']
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -154,6 +157,10 @@ class TestListener(TestProcessProto):
|
||||||
super().tearDownClass()
|
super().tearDownClass()
|
||||||
shared.shutting_down = False
|
shared.shutting_down = False
|
||||||
|
|
||||||
|
|
||||||
|
class TestListener(TestConnection):
|
||||||
|
"""A separate test case for Listener"""
|
||||||
|
|
||||||
def test_listener(self):
|
def test_listener(self):
|
||||||
"""Start Listener and try to connect"""
|
"""Start Listener and try to connect"""
|
||||||
with run_listener() as listener:
|
with run_listener() as listener:
|
||||||
|
@ -215,3 +222,16 @@ class TestListener(TestProcessProto):
|
||||||
if c.status == 'fully_established':
|
if c.status == 'fully_established':
|
||||||
self.fail('Established a connection')
|
self.fail('Established a connection')
|
||||||
time.sleep(0.5)
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user