Skip to content

Commit c49971f

Browse files
author
MarcoFalke
committed
Merge #18584: test: Check that the version message does not leak the local address
fa404f1 test: Check that the version message does not leak the local address of the node (MarcoFalke) Pull request description: Add test for #8740 ACKs for top commit: theStack: ACK bitcoin/bitcoin@fa404f1 Tree-SHA512: 4d1c10d1c02fba4b51bd8b9eb3a0d9a682b6aac8c3f6924e295fdca3faefa5ecc3eaa87d347cfec5d2b2bc49963c10fe0a37c463f36088ed0304a2e3716b963b
2 parents a2b282c + fa404f1 commit c49971f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

test/functional/p2p_leak.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
from test_framework.messages import msg_getaddr, msg_ping, msg_verack
1616
from test_framework.mininode import mininode_lock, P2PInterface
1717
from test_framework.test_framework import BitcoinTestFramework
18-
from test_framework.util import wait_until
18+
from test_framework.util import (
19+
assert_equal,
20+
assert_greater_than_or_equal,
21+
wait_until,
22+
)
1923

2024
banscore = 10
2125

@@ -86,6 +90,14 @@ def on_version(self, message):
8690
self.send_message(msg_getaddr())
8791

8892

93+
class P2PVersionStore(P2PInterface):
94+
version_received = None
95+
96+
def on_version(self, msg):
97+
super().on_version(msg)
98+
self.version_received = msg
99+
100+
89101
class P2PLeakTest(BitcoinTestFramework):
90102
def set_test_params(self):
91103
self.num_nodes = 1
@@ -123,6 +135,18 @@ def run_test(self):
123135
assert no_version_idlenode.unexpected_msg == False
124136
assert no_verack_idlenode.unexpected_msg == False
125137

138+
self.log.info('Check that the version message does not leak the local address of the node')
139+
time_begin = int(time.time())
140+
p2p_version_store = self.nodes[0].add_p2p_connection(P2PVersionStore())
141+
time_end = time.time()
142+
ver = p2p_version_store.version_received
143+
assert_greater_than_or_equal(ver.nTime, time_begin)
144+
assert_greater_than_or_equal(time_end, ver.nTime)
145+
assert_equal(ver.addrFrom.port, 0)
146+
assert_equal(ver.addrFrom.ip, '0.0.0.0')
147+
assert_equal(ver.nStartingHeight, 201)
148+
assert_equal(ver.nRelay, 1)
149+
126150

127151
if __name__ == '__main__':
128152
P2PLeakTest().main()

0 commit comments

Comments
 (0)