Skip to content

Commit 329fc1d

Browse files
author
MarcoFalke
committed
Merge #10359: [tests] functional tests should call BitcoinTestFramework start/stop node methods
53f6775 fixup: fix nits (John Newbery) a433d8a [tests] Update start/stop node functions to be private module functions (John Newbery) d8c218f [tests] Functional tests call self.start_node(s) and self.stop_node(s) (John Newbery) Tree-SHA512: 9cc01584a5e57686b7e7cb1c4c5186ad8cc7eb650d6d4f27b06bdb5e249a10966705814bdfb22d9ff2d5d3326911e489bf3d22257d751a299c0b24b7f40bffb5
2 parents 1aefc94 + 53f6775 commit 329fc1d

30 files changed

+125
-128
lines changed

test/functional/abandonconflict.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def run_test(self):
7373

7474
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool
7575
# TODO: redo with eviction
76-
stop_node(self.nodes[0],0)
77-
self.nodes[0]=start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.0001"])
76+
self.stop_node(0)
77+
self.nodes[0] = self.start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.0001"])
7878

7979
# Verify txs no longer in either node's mempool
8080
assert_equal(len(self.nodes[0].getrawmempool()), 0)
@@ -100,8 +100,8 @@ def run_test(self):
100100
balance = newbalance
101101

102102
# Verify that even with a low min relay fee, the tx is not reaccepted from wallet on startup once abandoned
103-
stop_node(self.nodes[0],0)
104-
self.nodes[0]=start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.00001"])
103+
self.stop_node(0)
104+
self.nodes[0] = self.start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.00001"])
105105
assert_equal(len(self.nodes[0].getrawmempool()), 0)
106106
assert_equal(self.nodes[0].getbalance(), balance)
107107

@@ -120,8 +120,8 @@ def run_test(self):
120120
balance = newbalance
121121

122122
# Remove using high relay fee again
123-
stop_node(self.nodes[0],0)
124-
self.nodes[0]=start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.0001"])
123+
self.stop_node(0)
124+
self.nodes[0] = self.start_node(0, self.options.tmpdir, ["-minrelaytxfee=0.0001"])
125125
assert_equal(len(self.nodes[0].getrawmempool()), 0)
126126
newbalance = self.nodes[0].getbalance()
127127
assert_equal(newbalance, balance - Decimal("24.9996"))

test/functional/assumevalid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
msg_headers)
4646
from test_framework.script import (CScript, OP_TRUE)
4747
from test_framework.test_framework import BitcoinTestFramework
48-
from test_framework.util import (start_node, p2p_port, assert_equal)
48+
from test_framework.util import (p2p_port, assert_equal)
4949

5050
class BaseNode(NodeConnCB):
5151
def send_header_for_blocks(self, new_blocks):
@@ -63,7 +63,7 @@ def setup_network(self):
6363
# Start node0. We don't start the other nodes yet since
6464
# we need to pre-mine a block with an invalid transaction
6565
# signature so we can pass in the block hash as assumevalid.
66-
self.nodes = [start_node(0, self.options.tmpdir)]
66+
self.nodes = [self.start_node(0, self.options.tmpdir)]
6767

6868
def send_blocks_until_disconnected(self, node):
6969
"""Keep sending blocks to the node until we're disconnected."""
@@ -162,14 +162,14 @@ def run_test(self):
162162
height += 1
163163

164164
# Start node1 and node2 with assumevalid so they accept a block with a bad signature.
165-
self.nodes.append(start_node(1, self.options.tmpdir,
165+
self.nodes.append(self.start_node(1, self.options.tmpdir,
166166
["-assumevalid=" + hex(block102.sha256)]))
167167
node1 = BaseNode() # connects to node1
168168
connections.append(NodeConn('127.0.0.1', p2p_port(1), self.nodes[1], node1))
169169
node1.add_connection(connections[1])
170170
node1.wait_for_verack()
171171

172-
self.nodes.append(start_node(2, self.options.tmpdir,
172+
self.nodes.append(self.start_node(2, self.options.tmpdir,
173173
["-assumevalid=" + hex(block102.sha256)]))
174174
node2 = BaseNode() # connects to node2
175175
connections.append(NodeConn('127.0.0.1', p2p_port(2), self.nodes[2], node2))

test/functional/bip9-softforks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignatu
239239

240240
# Restart all
241241
self.test.clear_all_connections()
242-
stop_nodes(self.nodes)
242+
self.stop_nodes()
243243
shutil.rmtree(self.options.tmpdir + "/node0")
244244
self.setup_chain()
245245
self.setup_network()

test/functional/bumpfee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ def __init__(self):
3838
def setup_network(self, split=False):
3939
extra_args = [["-prematurewitness", "-walletprematurewitness", "-walletrbf={}".format(i)]
4040
for i in range(self.num_nodes)]
41-
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args)
41+
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir, extra_args)
4242

4343
# Encrypt wallet for test_locked_wallet_fails test
4444
self.nodes[1].encryptwallet(WALLET_PASSPHRASE)
4545
bitcoind_processes[1].wait()
46-
self.nodes[1] = start_node(1, self.options.tmpdir, extra_args[1])
46+
self.nodes[1] = self.start_node(1, self.options.tmpdir, extra_args[1])
4747
self.nodes[1].walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)
4848

4949
connect_nodes_bi(self.nodes, 0, 1)

test/functional/disconnect_ban.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
from test_framework.test_framework import BitcoinTestFramework
1010
from test_framework.util import (assert_equal,
1111
assert_raises_jsonrpc,
12-
connect_nodes_bi,
13-
start_node,
14-
stop_node,
15-
)
12+
connect_nodes_bi)
1613

1714
class DisconnectBanTest(BitcoinTestFramework):
1815

@@ -68,9 +65,9 @@ def run_test(self):
6865
self.nodes[1].setmocktime(old_time + 3)
6966
assert_equal(len(self.nodes[1].listbanned()), 3)
7067

71-
stop_node(self.nodes[1], 1)
68+
self.stop_node(1)
7269

73-
self.nodes[1] = start_node(1, self.options.tmpdir)
70+
self.nodes[1] = self.start_node(1, self.options.tmpdir)
7471
listAfterShutdown = self.nodes[1].listbanned()
7572
assert_equal("127.0.0.0/24", listAfterShutdown[0]['address'])
7673
assert_equal("127.0.0.0/32", listAfterShutdown[1]['address'])

test/functional/forknotify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ def setup_network(self):
2121
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
2222
with open(self.alert_filename, 'w', encoding='utf8'):
2323
pass # Just open then close to create zero-length file
24-
self.nodes.append(start_node(0, self.options.tmpdir,
24+
self.nodes.append(self.start_node(0, self.options.tmpdir,
2525
["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]))
2626
# Node1 mines block.version=211 blocks
27-
self.nodes.append(start_node(1, self.options.tmpdir,
27+
self.nodes.append(self.start_node(1, self.options.tmpdir,
2828
["-blockversion=211"]))
2929
connect_nodes(self.nodes[1], 0)
3030

test/functional/fundrawtransaction.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ def run_test(self):
448448

449449
############################################################
450450
# locked wallet test
451+
self.stop_node(0)
452+
self.stop_node(2)
453+
self.stop_node(3)
451454
self.nodes[1].encryptwallet("test")
452455
self.nodes.pop(1)
453-
stop_node(self.nodes[0], 0)
454-
stop_node(self.nodes[1], 2)
455-
stop_node(self.nodes[2], 3)
456456

457-
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir)
457+
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir)
458458
# This test is not meant to test fee estimation and we'd like
459459
# to be sure all txs are sent at a consistent desired feerate
460460
for node in self.nodes:

test/functional/import-rescan.py

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

2222
from test_framework.authproxy import JSONRPCException
2323
from test_framework.test_framework import BitcoinTestFramework
24-
from test_framework.util import (start_nodes, connect_nodes, sync_blocks, assert_equal, set_node_times)
24+
from test_framework.util import (connect_nodes, sync_blocks, assert_equal, set_node_times)
2525

2626
import collections
2727
import enum
@@ -121,7 +121,7 @@ def setup_network(self):
121121
if import_node.prune:
122122
extra_args[i] += ["-prune=1"]
123123

124-
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, extra_args)
124+
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir, extra_args)
125125
for i in range(1, self.num_nodes):
126126
connect_nodes(self.nodes[i], 0)
127127

test/functional/importmulti.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ def run_test (self):
428428

429429

430430
# restart nodes to check for proper serialization/deserialization of watch only address
431-
stop_nodes(self.nodes)
432-
self.nodes = start_nodes(2, self.options.tmpdir)
431+
self.stop_nodes()
432+
self.nodes = self.start_nodes(2, self.options.tmpdir)
433433
address_assert = self.nodes[1].validateaddress(watchonly_address)
434434
assert_equal(address_assert['iswatchonly'], True)
435435
assert_equal(address_assert['ismine'], False)

test/functional/keypool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def run_test(self):
2020
nodes[0].encryptwallet('test')
2121
bitcoind_processes[0].wait()
2222
# Restart node 0
23-
nodes[0] = start_node(0, self.options.tmpdir)
23+
nodes[0] = self.start_node(0, self.options.tmpdir)
2424
# Keep creating keys
2525
addr = nodes[0].getnewaddress()
2626
addr_data = nodes[0].validateaddress(addr)

0 commit comments

Comments
 (0)