Skip to content

Commit 2fbf6a5

Browse files
author
MarcoFalke
committed
Merge #15330: test: Fix race in p2p_invalid_messages
fac3a05 test: Fix race in p2p_invalid_messages (MarcoFalke) Pull request description: After we change our magic bytes, the node may or may not send us messages such as feefilter or sendheaders, which would be rejected by `_on_data`. Solve that by replacing `_on_data` with a noop. Tree-SHA512: bd25a81f0c6e31f09155e00abab8062777d827b9210d6a9b85ef35cfe5069338f100fecf058842f41a1f134fdb3cf7ac1fe80db493e4dab7988acdacb33149df
2 parents 6e6b859 + fac3a05 commit 2fbf6a5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/functional/p2p_invalid_messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2015-2018 The Bitcoin Core developers
2+
# Copyright (c) 2015-2019 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test node responses to invalid network messages."""
@@ -143,6 +143,7 @@ def run_test(self):
143143

144144
def test_magic_bytes(self):
145145
conn = self.nodes[0].add_p2p_connection(P2PDataStore())
146+
conn._on_data = lambda: None # Need to ignore all incoming messages from now, since they come with "invalid" magic bytes
146147
conn.magic_bytes = b'\x00\x11\x22\x32'
147148
with self.nodes[0].assert_debug_log(['PROCESSMESSAGE: INVALID MESSAGESTART ping']):
148149
conn.send_message(messages.msg_ping(nonce=0xff))
@@ -211,6 +212,5 @@ def _tweak_msg_data_size(self, message, wrong_size):
211212
return raw_msg_with_wrong_size
212213

213214

214-
215215
if __name__ == '__main__':
216216
InvalidMessagesTest().main()

0 commit comments

Comments
 (0)