Skip to content

Commit

Permalink
test: add functional test for deadlock situation
Browse files Browse the repository at this point in the history
  • Loading branch information
mzumsande committed Aug 22, 2023
1 parent 3557aa4 commit b3a93b4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/functional/p2p_net_deadlock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# Copyright (c) 2023-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.

import threading
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import random_bytes


class NetDeadlockTest(BitcoinTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2

def run_test(self):
node0 = self.nodes[0]
node1 = self.nodes[1]

self.log.info("Simultaneously send a large message on both sides")
rand_msg = random_bytes(4000000).hex()

thread0 = threading.Thread(target=node0.sendmsgtopeer, args=(0, "unknown", rand_msg))
thread1 = threading.Thread(target=node1.sendmsgtopeer, args=(0, "unknown", rand_msg))

thread0.start()
thread1.start()
thread0.join()
thread1.join()

self.log.info("Check whether a deadlock happened")
self.generate(node0, 1)
self.sync_blocks()


if __name__ == '__main__':
NetDeadlockTest().main()
1 change: 1 addition & 0 deletions test/functional/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
'p2p_leak_tx.py',
'p2p_eviction.py',
'p2p_ibd_stalling.py',
'p2p_net_deadlock.py',
'wallet_signmessagewithaddress.py',
'rpc_signmessagewithprivkey.py',
'rpc_generate.py',
Expand Down

0 comments on commit b3a93b4

Please sign in to comment.