Skip to content

Commit b3a93b4

Browse files
committed
test: add functional test for deadlock situation
1 parent 3557aa4 commit b3a93b4

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

test/functional/p2p_net_deadlock.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) 2023-present The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
5+
6+
import threading
7+
from test_framework.test_framework import BitcoinTestFramework
8+
from test_framework.util import random_bytes
9+
10+
11+
class NetDeadlockTest(BitcoinTestFramework):
12+
def set_test_params(self):
13+
self.setup_clean_chain = True
14+
self.num_nodes = 2
15+
16+
def run_test(self):
17+
node0 = self.nodes[0]
18+
node1 = self.nodes[1]
19+
20+
self.log.info("Simultaneously send a large message on both sides")
21+
rand_msg = random_bytes(4000000).hex()
22+
23+
thread0 = threading.Thread(target=node0.sendmsgtopeer, args=(0, "unknown", rand_msg))
24+
thread1 = threading.Thread(target=node1.sendmsgtopeer, args=(0, "unknown", rand_msg))
25+
26+
thread0.start()
27+
thread1.start()
28+
thread0.join()
29+
thread1.join()
30+
31+
self.log.info("Check whether a deadlock happened")
32+
self.generate(node0, 1)
33+
self.sync_blocks()
34+
35+
36+
if __name__ == '__main__':
37+
NetDeadlockTest().main()

test/functional/test_runner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@
267267
'p2p_leak_tx.py',
268268
'p2p_eviction.py',
269269
'p2p_ibd_stalling.py',
270+
'p2p_net_deadlock.py',
270271
'wallet_signmessagewithaddress.py',
271272
'rpc_signmessagewithprivkey.py',
272273
'rpc_generate.py',

0 commit comments

Comments
 (0)