diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-04-10 10:54:30 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-04-10 10:48:56 -0400 |
commit | fa404f1e4718e8155581f23826480086dfbcfaa6 (patch) | |
tree | 4ceb283536e72108f11e6fbdf40685c77104ba1f /test/functional/p2p_leak.py | |
parent | 29893ec8751f51f281f694453bd439f92ccf3ab2 (diff) |
test: Check that the version message does not leak the local address of the node
Diffstat (limited to 'test/functional/p2p_leak.py')
-rwxr-xr-x | test/functional/p2p_leak.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/test/functional/p2p_leak.py b/test/functional/p2p_leak.py index 2751ae6a5b..08e1f0bcd4 100755 --- a/test/functional/p2p_leak.py +++ b/test/functional/p2p_leak.py @@ -15,7 +15,11 @@ import time from test_framework.messages import msg_getaddr, msg_ping, msg_verack from test_framework.mininode import mininode_lock, P2PInterface from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import wait_until +from test_framework.util import ( + assert_equal, + assert_greater_than_or_equal, + wait_until, +) banscore = 10 @@ -90,6 +94,14 @@ class CNodeNoVerackIdle(CLazyNode): self.send_message(msg_getaddr()) +class P2PVersionStore(P2PInterface): + version_received = None + + def on_version(self, msg): + super().on_version(msg) + self.version_received = msg + + class P2PLeakTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 @@ -127,6 +139,18 @@ class P2PLeakTest(BitcoinTestFramework): assert no_version_idlenode.unexpected_msg == False assert no_verack_idlenode.unexpected_msg == False + self.log.info('Check that the version message does not leak the local address of the node') + time_begin = int(time.time()) + p2p_version_store = self.nodes[0].add_p2p_connection(P2PVersionStore()) + time_end = time.time() + ver = p2p_version_store.version_received + assert_greater_than_or_equal(ver.nTime, time_begin) + assert_greater_than_or_equal(time_end, ver.nTime) + assert_equal(ver.addrFrom.port, 0) + assert_equal(ver.addrFrom.ip, '0.0.0.0') + assert_equal(ver.nStartingHeight, 201) + assert_equal(ver.nRelay, 1) + if __name__ == '__main__': P2PLeakTest().main() |