Skip to content

Commit

Permalink
Merge #10556: Move stop/start functions from utils.py into BitcoinTes…
Browse files Browse the repository at this point in the history
…tFramework

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
  • Loading branch information
MarcoFalke committed Jun 29, 2017
2 parents 4c72cc3 + 5ba83c1 commit 65cc7aa
Show file tree
Hide file tree
Showing 15 changed files with 421 additions and 453 deletions.
7 changes: 4 additions & 3 deletions test/functional/bip9-softforks.py
Expand Up @@ -15,16 +15,17 @@
test that enforcement has not triggered (which triggers ACTIVE)
test that enforcement has triggered
"""
from io import BytesIO
import shutil
import time
import itertools

from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.mininode import CTransaction, NetworkThread
from test_framework.blocktools import create_coinbase, create_block
from test_framework.comptool import TestInstance, TestManager
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKSEQUENCEVERIFY, OP_DROP
from io import BytesIO
import time
import itertools

class BIP9SoftForksTest(ComparisonTestFramework):

Expand Down
8 changes: 3 additions & 5 deletions test/functional/blockchain.py
Expand Up @@ -21,15 +21,13 @@
import http.client
import subprocess

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import (BitcoinTestFramework, BITCOIND_PROC_WAIT_TIMEOUT)
from test_framework.util import (
assert_equal,
assert_raises,
assert_raises_jsonrpc,
assert_is_hex_string,
assert_is_hash_string,
bitcoind_processes,
BITCOIND_PROC_WAIT_TIMEOUT,
)


Expand Down Expand Up @@ -141,13 +139,13 @@ def _test_stopatheight(self):
self.nodes[0].generate(6)
assert_equal(self.nodes[0].getblockcount(), 206)
self.log.debug('Node should not stop at this height')
assert_raises(subprocess.TimeoutExpired, lambda: bitcoind_processes[0].wait(timeout=3))
assert_raises(subprocess.TimeoutExpired, lambda: self.bitcoind_processes[0].wait(timeout=3))
try:
self.nodes[0].generate(1)
except (ConnectionError, http.client.BadStatusLine):
pass # The node already shut down before response
self.log.debug('Node should stop at this height...')
bitcoind_processes[0].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
self.bitcoind_processes[0].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
self.nodes[0] = self.start_node(0, self.options.tmpdir)
assert_equal(self.nodes[0].getblockcount(), 207)

Expand Down
2 changes: 1 addition & 1 deletion test/functional/bumpfee.py
Expand Up @@ -42,7 +42,7 @@ def setup_network(self, split=False):

# Encrypt wallet for test_locked_wallet_fails test
self.nodes[1].encryptwallet(WALLET_PASSPHRASE)
bitcoind_processes[1].wait()
self.bitcoind_processes[1].wait()
self.nodes[1] = self.start_node(1, self.options.tmpdir, extra_args[1])
self.nodes[1].walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT)

Expand Down
4 changes: 2 additions & 2 deletions test/functional/dbcrash.py
Expand Up @@ -88,7 +88,7 @@ def restart_node(self, node_index, expected_tip):
# An exception here should mean the node is about to crash.
# If bitcoind exits, then try again. wait_for_node_exit()
# should raise an exception if bitcoind doesn't exit.
wait_for_node_exit(node_index, timeout=10)
self.wait_for_node_exit(node_index, timeout=10)
self.crashed_on_restart += 1
time.sleep(1)

Expand Down Expand Up @@ -140,7 +140,7 @@ def sync_node3blocks(self, block_hashes):
if not self.submit_block_catch_error(i, block):
# TODO: more carefully check that the crash is due to -dbcrashratio
# (change the exit code perhaps, and check that here?)
wait_for_node_exit(i, timeout=30)
self.wait_for_node_exit(i, timeout=30)
self.log.debug("Restarting node %d after block hash %s", i, block_hash)
nodei_utxo_hash = self.restart_node(i, block_hash)
assert nodei_utxo_hash is not None
Expand Down
4 changes: 2 additions & 2 deletions test/functional/fundrawtransaction.py
Expand Up @@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the fundrawtransaction RPC."""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BitcoinTestFramework, BITCOIND_PROC_WAIT_TIMEOUT
from test_framework.util import *


Expand Down Expand Up @@ -452,7 +452,7 @@ def run_test(self):
self.stop_node(2)
self.stop_node(3)
self.nodes[1].encryptwallet("test")
bitcoind_processes[1].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)
self.bitcoind_processes[1].wait(timeout=BITCOIND_PROC_WAIT_TIMEOUT)

self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir)
# This test is not meant to test fee estimation and we'd like
Expand Down
2 changes: 1 addition & 1 deletion test/functional/keypool.py
Expand Up @@ -18,7 +18,7 @@ def run_test(self):

# Encrypt wallet and wait to terminate
nodes[0].encryptwallet('test')
bitcoind_processes[0].wait()
self.bitcoind_processes[0].wait()
# Restart node 0
nodes[0] = self.start_node(0, self.options.tmpdir)
# Keep creating keys
Expand Down
2 changes: 1 addition & 1 deletion test/functional/listtransactions.py
Expand Up @@ -23,7 +23,7 @@ def __init__(self):

def setup_nodes(self):
#This test requires mocktime
enable_mocktime()
self.enable_mocktime()
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir)

def run_test(self):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/receivedby.py
Expand Up @@ -31,7 +31,7 @@ def __init__(self):

def setup_nodes(self):
#This test requires mocktime
enable_mocktime()
self.enable_mocktime()
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir)

def run_test(self):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpcbind_test.py
Expand Up @@ -37,7 +37,7 @@ def run_bind_test(self, allow_ips, connect_to, addresses, expected):
base_args += ['-rpcallowip=' + x for x in allow_ips]
binds = ['-rpcbind='+addr for addr in addresses]
self.nodes = self.start_nodes(self.num_nodes, self.options.tmpdir, [base_args + binds], connect_to)
pid = bitcoind_processes[0].pid
pid = self.bitcoind_processes[0].pid
assert_equal(set(get_bind_addrs(pid)), set(expected))
self.stop_nodes()

Expand Down

0 comments on commit 65cc7aa

Please sign in to comment.