Skip to content

Commit 74e64f2

Browse files
committed
[tests] Use network_thread_start() in tests.
1 parent 5fc6e71 commit 74e64f2

22 files changed

+37
-34
lines changed

test/functional/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ contains the higher level logic for processing P2P payloads and connecting to
6868
the Bitcoin Core node application logic. For custom behaviour, subclass the
6969
P2PInterface object and override the callback methods.
7070

71-
- Call `NetworkThread.start()` after all `P2PInterface` objects are created to
71+
- Call `network_thread_start()` after all `P2PInterface` objects are created to
7272
start the networking thread. (Continue with the test logic in your existing
7373
thread.)
7474

test/functional/assumevalid.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
CTransaction,
3939
CTxIn,
4040
CTxOut,
41-
NetworkThread,
4241
P2PInterface,
4342
msg_block,
44-
msg_headers)
43+
msg_headers,
44+
network_thread_start)
4545
from test_framework.script import (CScript, OP_TRUE)
4646
from test_framework.test_framework import BitcoinTestFramework
4747
from test_framework.util import assert_equal
@@ -98,7 +98,7 @@ def run_test(self):
9898
# Connect to node0
9999
p2p0 = self.nodes[0].add_p2p_connection(BaseNode())
100100

101-
NetworkThread().start() # Start up network handling in another thread
101+
network_thread_start()
102102
self.nodes[0].p2p.wait_for_verack()
103103

104104
# Build the blockchain

test/functional/bip65-cltv-p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def set_test_params(self):
6868
def run_test(self):
6969
self.nodes[0].add_p2p_connection(P2PInterface())
7070

71-
NetworkThread().start() # Start up network handling in another thread
71+
network_thread_start()
7272

7373
# wait_for_verack ensures that the P2P connection is fully up.
7474
self.nodes[0].p2p.wait_for_verack()

test/functional/bip68-112-113-p2p.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
from test_framework.test_framework import ComparisonTestFramework
4747
from test_framework.util import *
48-
from test_framework.mininode import ToHex, CTransaction, NetworkThread
48+
from test_framework.mininode import ToHex, CTransaction, network_thread_start
4949
from test_framework.blocktools import create_coinbase, create_block
5050
from test_framework.comptool import TestInstance, TestManager
5151
from test_framework.script import *
@@ -100,7 +100,7 @@ def set_test_params(self):
100100
def run_test(self):
101101
test = TestManager(self, self.options.tmpdir)
102102
test.add_all_connections(self.nodes)
103-
NetworkThread().start() # Start up network handling in another thread
103+
network_thread_start()
104104
test.run()
105105

106106
def send_generic_input_tx(self, node, coinbases):

test/functional/bip9-softforks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from test_framework.test_framework import ComparisonTestFramework
2424
from test_framework.util import *
25-
from test_framework.mininode import CTransaction, NetworkThread
25+
from test_framework.mininode import CTransaction, network_thread_start
2626
from test_framework.blocktools import create_coinbase, create_block
2727
from test_framework.comptool import TestInstance, TestManager
2828
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
@@ -36,7 +36,7 @@ def set_test_params(self):
3636
def run_test(self):
3737
self.test = TestManager(self, self.options.tmpdir)
3838
self.test.add_all_connections(self.nodes)
39-
NetworkThread().start() # Start up network handling in another thread
39+
network_thread_start()
4040
self.test.run()
4141

4242
def create_transaction(self, node, coinbase, to_address, amount):
@@ -245,7 +245,7 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
245245
self.setup_chain()
246246
self.setup_network()
247247
self.test.add_all_connections(self.nodes)
248-
NetworkThread().start()
248+
network_thread_start()
249249
self.test.p2p_connections[0].wait_for_verack()
250250

251251
def get_tests(self):

test/functional/bipdersig-p2p.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def set_test_params(self):
5656
def run_test(self):
5757
self.nodes[0].add_p2p_connection(P2PInterface())
5858

59-
NetworkThread().start() # Start up network handling in another thread
59+
network_thread_start()
6060

6161
# wait_for_verack ensures that the P2P connection is fully up.
6262
self.nodes[0].p2p.wait_for_verack()

test/functional/example_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
from test_framework.blocktools import (create_block, create_coinbase)
1818
from test_framework.mininode import (
1919
CInv,
20-
NetworkThread,
2120
P2PInterface,
2221
mininode_lock,
2322
msg_block,
2423
msg_getdata,
24+
network_thread_start,
2525
)
2626
from test_framework.test_framework import BitcoinTestFramework
2727
from test_framework.util import (
@@ -136,7 +136,7 @@ def run_test(self):
136136

137137
# Start up network handling in another thread. This needs to be called
138138
# after the P2P connections have been created.
139-
NetworkThread().start()
139+
network_thread_start()
140140
# wait_for_verack ensures that the P2P connection is fully up.
141141
self.nodes[0].p2p.wait_for_verack()
142142

test/functional/invalidblockrequest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from test_framework.util import *
1616
from test_framework.comptool import TestManager, TestInstance, RejectResult
1717
from test_framework.blocktools import *
18+
from test_framework.mininode import network_thread_start
1819
import copy
1920
import time
2021

@@ -32,7 +33,7 @@ def run_test(self):
3233
test.add_all_connections(self.nodes)
3334
self.tip = None
3435
self.block_time = None
35-
NetworkThread().start() # Start up network handling in another thread
36+
network_thread_start()
3637
test.run()
3738

3839
def get_tests(self):

test/functional/invalidtxrequest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_test(self):
2828
test.add_all_connections(self.nodes)
2929
self.tip = None
3030
self.block_time = None
31-
NetworkThread().start() # Start up network handling in another thread
31+
network_thread_start()
3232
test.run()
3333

3434
def get_tests(self):

test/functional/maxuploadtarget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run_test(self):
5757
for _ in range(3):
5858
p2p_conns.append(self.nodes[0].add_p2p_connection(TestNode()))
5959

60-
NetworkThread().start() # Start up network handling in another thread
60+
network_thread_start()
6161
for p2pc in p2p_conns:
6262
p2pc.wait_for_verack()
6363

@@ -149,7 +149,7 @@ def run_test(self):
149149
# Reconnect to self.nodes[0]
150150
self.nodes[0].add_p2p_connection(TestNode())
151151

152-
NetworkThread().start() # Start up network handling in another thread
152+
network_thread_start()
153153
self.nodes[0].p2p.wait_for_verack()
154154

155155
#retrieve 20 blocks which should be enough to break the 1MB limit

0 commit comments

Comments
 (0)