Skip to content

Commit 65cc7aa

Browse files
author
MarcoFalke
committed
Merge #10556: Move stop/start functions from utils.py into BitcoinTestFramework
5ba83c1 [tests] fix nits. (John Newbery) 05b8c08 [tests] reorganize utils.py module (code move only) (John Newbery) 0d473c5 [tests] move mocktime property and functions to BitcoinTestFramework (John Newbery) cad967a [tests] Move stop_node and start_node methods to BitcoinTestFramework (John Newbery) f1fe536 [tests] fix flake8 warnings in test_framework.py and util.py (John Newbery) 37065d2 [tests] remove unused imports from utils.py (John Newbery) Tree-SHA512: 461db412c57c4d0030e27fe3f78f17bcaf00b966f319a9e613460cca897508ff70a29db7138133fe1be8d447dad6702ba2778f9eddfe929016e560d71c20b09f
2 parents 4c72cc3 + 5ba83c1 commit 65cc7aa

15 files changed

+421
-453
lines changed

test/functional/bip9-softforks.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515
test that enforcement has not triggered (which triggers ACTIVE)
1616
test that enforcement has triggered
1717
"""
18+
from io import BytesIO
19+
import shutil
20+
import time
21+
import itertools
1822

1923
from test_framework.test_framework import ComparisonTestFramework
2024
from test_framework.util import *
2125
from test_framework.mininode import CTransaction, NetworkThread
2226
from test_framework.blocktools import create_coinbase, create_block
2327
from test_framework.comptool import TestInstance, TestManager
2428
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
25-
from io import BytesIO
26-
import time
27-
import itertools
2829

2930
class BIP9SoftForksTest(ComparisonTestFramework):
3031

test/functional/blockchain.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
import http.client
2222
import subprocess
2323

24-
from test_framework.test_framework import BitcoinTestFramework
24+
from test_framework.test_framework import (BitcoinTestFramework, BITCOIND_PROC_WAIT_TIMEOUT)
2525
from test_framework.util import (
2626
assert_equal,
2727
assert_raises,
2828
assert_raises_jsonrpc,
2929
assert_is_hex_string,
3030
assert_is_hash_string,
31-
bitcoind_processes,
32-
BITCOIND_PROC_WAIT_TIMEOUT,
3331
)
3432

3533

@@ -141,13 +139,13 @@ def _test_stopatheight(self):
141139
self.nodes[0].generate(6)
142140
assert_equal(self.nodes[0].getblockcount(), 206)
143141
self.log.debug('Node should not stop at this height')
144-
assert_raises(subprocess.TimeoutExpired, lambda: bitcoind_processes[0].wait(timeout=3))
142+
assert_raises(subprocess.TimeoutExpired, lambda: self.bitcoind_processes[0].wait(timeout=3))
145143
try:
146144
self.nodes[0].generate(1)
147145
except (ConnectionError, http.client.BadStatusLine):
148146
pass # The node already shut down before response
149147
self.log.debug('Node should stop at this height...')
150-
bitcoind_processes[0].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
148+
self.bitcoind_processes[0].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
151149
self.nodes[0] = self.start_node(0, self.options.tmpdir)
152150
assert_equal(self.nodes[0].getblockcount(), 207)
153151

test/functional/bumpfee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def setup_network(self, split=False):
4242

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

test/functional/dbcrash.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def restart_node(self, node_index, expected_tip):
8888
# An exception here should mean the node is about to crash.
8989
# If bitcoind exits, then try again. wait_for_node_exit()
9090
# should raise an exception if bitcoind doesn't exit.
91-
wait_for_node_exit(node_index, timeout=10)
91+
self.wait_for_node_exit(node_index, timeout=10)
9292
self.crashed_on_restart += 1
9393
time.sleep(1)
9494

@@ -140,7 +140,7 @@ def sync_node3blocks(self, block_hashes):
140140
if not self.submit_block_catch_error(i, block):
141141
# TODO: more carefully check that the crash is due to -dbcrashratio
142142
# (change the exit code perhaps, and check that here?)
143-
wait_for_node_exit(i, timeout=30)
143+
self.wait_for_node_exit(i, timeout=30)
144144
self.log.debug("Restarting node %d after block hash %s", i, block_hash)
145145
nodei_utxo_hash = self.restart_node(i, block_hash)
146146
assert nodei_utxo_hash is not None

test/functional/fundrawtransaction.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test the fundrawtransaction RPC."""
66

7-
from test_framework.test_framework import BitcoinTestFramework
7+
from test_framework.test_framework import BitcoinTestFramework, BITCOIND_PROC_WAIT_TIMEOUT
88
from test_framework.util import *
99

1010

@@ -452,7 +452,7 @@ def run_test(self):
452452
self.stop_node(2)
453453
self.stop_node(3)
454454
self.nodes[1].encryptwallet("test")
455-
bitcoind_processes[1].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
455+
self.bitcoind_processes[1].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
456456

457457
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

test/functional/keypool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def run_test(self):
1818

1919
# Encrypt wallet and wait to terminate
2020
nodes[0].encryptwallet('test')
21-
bitcoind_processes[0].wait()
21+
self.bitcoind_processes[0].wait()
2222
# Restart node 0
2323
nodes[0] = self.start_node(0, self.options.tmpdir)
2424
# Keep creating keys

test/functional/listtransactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __init__(self):
2323

2424
def setup_nodes(self):
2525
#This test requires mocktime
26-
enable_mocktime()
26+
self.enable_mocktime()
2727
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir)
2828

2929
def run_test(self):

test/functional/receivedby.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self):
3131

3232
def setup_nodes(self):
3333
#This test requires mocktime
34-
enable_mocktime()
34+
self.enable_mocktime()
3535
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir)
3636

3737
def run_test(self):

test/functional/rpcbind_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def run_bind_test(self, allow_ips, connect_to, addresses, expected):
3737
base_args += ['-rpcallowip=' + x for x in allow_ips]
3838
binds = ['-rpcbind='+addr for addr in addresses]
3939
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to)
40-
pid = bitcoind_processes[0].pid
40+
pid = self.bitcoind_processes[0].pid
4141
assert_equal(set(get_bind_addrs(pid)), set(expected))
4242
self.stop_nodes()
4343

0 commit comments

Comments
 (0)