Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115350
D6396.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D6396.diff
View Options
diff --git a/test/functional/p2p_invalid_messages.py b/test/functional/p2p_invalid_messages.py
--- a/test/functional/p2p_invalid_messages.py
+++ b/test/functional/p2p_invalid_messages.py
@@ -3,10 +3,11 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test node responses to invalid network messages."""
+import asyncio
import struct
from test_framework import messages
-from test_framework.mininode import P2PDataStore
+from test_framework.mininode import P2PDataStore, NetworkThread
from test_framework.test_framework import BitcoinTestFramework
@@ -144,10 +145,19 @@
def test_magic_bytes(self):
conn = self.nodes[0].add_p2p_connection(P2PDataStore())
- # Need to ignore all incoming messages from now, since they come with
- # "invalid" magic bytes
- conn._on_data = lambda: None
- conn.magic_bytes = b'\x00\x11\x22\x32'
+
+ def swap_magic_bytes():
+ # Need to ignore all incoming messages from now, since they come
+ # with "invalid" magic bytes
+ conn._on_data = lambda: None
+ conn.magic_bytes = b'\x00\x11\x22\x32'
+
+ # Call .result() to block until the atomic swap is complete, otherwise
+ # we might run into races later on
+ asyncio.run_coroutine_threadsafe(
+ asyncio.coroutine(swap_magic_bytes)(),
+ NetworkThread.network_event_loop).result()
+
with self.nodes[0].assert_debug_log(['PROCESSMESSAGE: INVALID MESSAGESTART ping']):
conn.send_message(messages.msg_ping(nonce=0xff))
conn.wait_for_disconnect(timeout=1)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 10:55 (11 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5183683
Default Alt Text
D6396.diff (1 KB)
Attached To
D6396: Merge #15697: qa: Make swap_magic_bytes in p2p_invalid_messages atomic
Event Timeline
Log In to Comment