Skip to content

Commit

Permalink
Merge bitcoin#14180: qa: Run all tests even if wallet is not compiled
Browse files Browse the repository at this point in the history
fac9539 qa: Run all tests even if wallet is not compiled (MarcoFalke)
faa669c qa: Premine to deterministic address with -disablewallet (MarcoFalke)

Pull request description:

  Currently the test_runner would exit if the wallet was not compiled into the Bitcoin Core executable. However, a lot of the tests run without the wallet just fine and there is no need to globally require the wallet to run the tests.

Tree-SHA512: 63177260aa29126fd20f0be217a82b10b62288ab846f96f1cbcc3bd2c52702437703475d91eae3f8d821a3149fc62b725a4c5b2a7b3657b67ffcbc81532a03bb
  • Loading branch information
laanwj committed Sep 13, 2018
2 parents 37b836a + fac9539 commit 288ddf4
Show file tree
Hide file tree
Showing 86 changed files with 502 additions and 133 deletions.
6 changes: 5 additions & 1 deletion test/functional/example_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,11 @@ def custom_function():
# self.log.info("running custom_function") # Oops! Can't run self.log outside the BitcoinTestFramework
pass


class ExampleTest(BitcoinTestFramework):
# Each functional test is a subclass of the BitcoinTestFramework class.

# Override the set_test_params(), add_options(), setup_chain(), setup_network()
# Override the set_test_params(), skip_test_if_missing_module(), add_options(), setup_chain(), setup_network()
# and setup_nodes() methods to customize the test setup as required.

def set_test_params(self):
Expand All @@ -84,6 +85,9 @@ def set_test_params(self):

# self.log.info("I've finished set_test_params") # Oops! Can't run self.log before run_test()

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

# Use add_options() to add specific command-line options for your test.
# In practice this is not used very much, since the tests are mostly written
# to be run in automated environments without command-line options.
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_bip68_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def set_test_params(self):
self.num_nodes = 2
self.extra_args = [[], ["-acceptnonstdtxn=0"]]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.relayfee = self.nodes[0].getnetworkinfo()["relayfee"]

Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.extra_args = [[]]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
node = self.nodes[0] # convenience reference to the node

Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_blocksdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.stop_node(0)
shutil.rmtree(self.nodes[0].datadir)
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_cltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def set_test_params(self):
self.extra_args = [['-whitelist=127.0.0.1', '-par=1']] # Use only one script thread to get the exact reject reason for testing
self.setup_clean_chain = True

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.nodes[0].add_p2p_connection(P2PInterface())

Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_config_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def test_config_file_parser(self):
# Assume node is stopped

Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_csv_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.extra_args = [['-whitelist=127.0.0.1', '-blockversion=4', '-addresstype=legacy']]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def generate_blocks(self, number, version, test_blocks=None):
if test_blocks is None:
test_blocks = []
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_dbcrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def set_test_params(self):
self.node3_args = ["-blockmaxweight=4000000"]
self.extra_args = [self.node0_args, self.node1_args, self.node2_args, self.node3_args]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
self.add_nodes(self.num_nodes, extra_args=self.extra_args)
self.start_nodes()
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_dersig.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ def set_test_params(self):
self.extra_args = [['-whitelist=127.0.0.1', '-par=1', '-enablebip61']] # Use only one script thread to get the exact reject reason for testing
self.setup_clean_chain = True

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.nodes[0].add_p2p_connection(P2PInterface())

Expand Down
8 changes: 8 additions & 0 deletions test/functional/feature_fee_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class EstimateFeeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 3

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
"""
We'll setup the network to have 3 nodes that all mine with different parameters.
Expand Down Expand Up @@ -168,6 +171,11 @@ def transact_and_mine(self, numblocks, mining_node):
newmem.append(utx)
self.memutxo = newmem

def import_deterministic_coinbase_privkeys(self):
self.start_nodes()
super().import_deterministic_coinbase_privkeys()
self.stop_nodes()

def run_test(self):
self.log.info("This test is time consuming, please be patient")
self.log.info("Splitting inputs so we can generate tx's")
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def relative_log_path(self, name):
return os.path.join(self.nodes[0].datadir, "regtest", name)

Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_maxuploadtarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def set_test_params(self):
# Cache for utxos, as the listunspent may take a long time later in the test
self.utxo_cache = []

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
# Before we connect anything, we first set the time on the node
# to be in the past, otherwise things break because the CNode
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_minchainwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def set_test_params(self):
self.extra_args = [[], ["-minimumchainwork=0x65"], ["-minimumchainwork=0x65"]]
self.node_min_work = [0, 101, 101]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
# This test relies on the chain setup being:
# node0 <- node1 <- node2
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def set_test_params(self):
self.num_nodes = 2
self.setup_clean_chain = True

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
self.block_filename = os.path.join(self.options.tmpdir, "blocks.txt")
Expand Down
5 changes: 4 additions & 1 deletion test/functional/feature_nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ def set_test_params(self):
# normal segwit activation here (and don't use the default always-on behaviour).
self.extra_args = [['-whitelist=127.0.0.1', '-vbparams=segwit:0:999999999999', '-addresstype=legacy', "-deprecatedrpc=addwitnessaddress"]]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
self.address = self.nodes[0].getnewaddress()
self.ms_address = self.nodes[0].addmultisigaddress(1,[self.address])['address']
self.ms_address = self.nodes[0].addmultisigaddress(1, [self.address])['address']
self.wit_address = self.nodes[0].addwitnessaddress(self.address)
self.wit_ms_address = self.nodes[0].addmultisigaddress(1, [self.address], '', 'p2sh-segwit')['address']

Expand Down
19 changes: 12 additions & 7 deletions test/functional/feature_pruning.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ def set_test_params(self):

# Create nodes 0 and 1 to mine.
# Create node 2 to test pruning.
self.full_node_default_args = ["-maxreceivebuffer=20000", "-checkblocks=5", "-limitdescendantcount=100", "-limitdescendantsize=5000", "-limitancestorcount=100", "-limitancestorsize=5000" ]
self.full_node_default_args = ["-maxreceivebuffer=20000", "-checkblocks=5", "-limitdescendantcount=100", "-limitdescendantsize=5000", "-limitancestorcount=100", "-limitancestorsize=5000"]
# Create nodes 3 and 4 to test manual pruning (they will be re-started with manual pruning later)
# Create nodes 5 to test wallet in prune mode, but do not connect
self.extra_args = [self.full_node_default_args,
self.full_node_default_args,
["-maxreceivebuffer=20000", "-prune=550"],
["-maxreceivebuffer=20000"],
["-maxreceivebuffer=20000"],
["-prune=550"]]
self.extra_args = [
self.full_node_default_args,
self.full_node_default_args,
["-maxreceivebuffer=20000", "-prune=550"],
["-maxreceivebuffer=20000"],
["-maxreceivebuffer=20000"],
["-prune=550"],
]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
self.setup_nodes()
Expand Down
25 changes: 17 additions & 8 deletions test/functional/feature_rbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,26 @@ def make_utxo(node, amount, confirmed=True, scriptPubKey=CScript([1])):

return COutPoint(int(txid, 16), 0)

class ReplaceByFeeTest(BitcoinTestFramework):

class ReplaceByFeeTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
self.extra_args= [["-maxorphantx=1000",
"-whitelist=127.0.0.1",
"-limitancestorcount=50",
"-limitancestorsize=101",
"-limitdescendantcount=200",
"-limitdescendantsize=101"],
["-mempoolreplacement=0"]]
self.extra_args = [
[
"-maxorphantx=1000",
"-whitelist=127.0.0.1",
"-limitancestorcount=50",
"-limitancestorsize=101",
"-limitdescendantcount=200",
"-limitdescendantsize=101",
],
[
"-mempoolreplacement=0",
],
]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
# Leave IBD
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_reindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def reindex(self, justchainstate=False):
self.nodes[0].generate(3)
blockcount = self.nodes[0].getblockcount()
Expand Down
27 changes: 24 additions & 3 deletions test/functional/feature_segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,30 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 3
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
self.extra_args = [["-rpcserialversion=0", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
["-blockversion=4", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"],
["-blockversion=536870915", "-vbparams=segwit:0:999999999999", "-addresstype=legacy", "-deprecatedrpc=addwitnessaddress"]]
self.extra_args = [
[
"-rpcserialversion=0",
"-vbparams=segwit:0:999999999999",
"-addresstype=legacy",
"-deprecatedrpc=addwitnessaddress",
],
[
"-blockversion=4",
"-rpcserialversion=1",
"-vbparams=segwit:0:999999999999",
"-addresstype=legacy",
"-deprecatedrpc=addwitnessaddress",
],
[
"-blockversion=536870915",
"-vbparams=segwit:0:999999999999",
"-addresstype=legacy",
"-deprecatedrpc=addwitnessaddress",
],
]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
super().setup_network()
Expand Down
3 changes: 3 additions & 0 deletions test/functional/feature_versionbits_warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def setup_network(self):
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
# Open and close to create zero-length file
Expand Down
3 changes: 3 additions & 0 deletions test/functional/interface_bitcoin_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
"""Main test logic"""

Expand Down
3 changes: 3 additions & 0 deletions test/functional/interface_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def set_test_params(self):
self.num_nodes = 2
self.extra_args = [["-rest"], []]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def test_rest_request(self, uri, http_method='GET', req_type=ReqType.JSON, body='', status=200, ret_type=RetType.JSON):
rest_uri = '/rest' + uri
if req_type == ReqType.JSON:
Expand Down
32 changes: 22 additions & 10 deletions test/functional/interface_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"""Test the ZMQ notification interface."""
import struct

from test_framework.test_framework import (
BitcoinTestFramework, skip_if_no_bitcoind_zmq, skip_if_no_py3_zmq)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import CTransaction
from test_framework.util import (assert_equal,
bytes_to_hex_str,
hash256,
)
from test_framework.util import (
assert_equal,
bytes_to_hex_str,
hash256,
)
from io import BytesIO


class ZMQSubscriber:
def __init__(self, socket, topic):
self.sequence = 0
Expand All @@ -37,9 +38,18 @@ class ZMQTest (BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2

def skip_test_if_missing_module(self):
self.skip_if_no_py3_zmq()
self.skip_if_no_bitcoind_zmq()
self.skip_if_no_wallet()

def setup_nodes(self):
skip_if_no_py3_zmq()
skip_if_no_bitcoind_zmq(self)
# Import keys
self.add_nodes(self.num_nodes)
self.start_nodes()
super().import_deterministic_coinbase_privkeys()
self.stop_nodes()

import zmq

# Initialize ZMQ context and socket.
Expand All @@ -59,10 +69,12 @@ def setup_nodes(self):
self.rawblock = ZMQSubscriber(socket, b"rawblock")
self.rawtx = ZMQSubscriber(socket, b"rawtx")

self.extra_args = [["-zmqpub%s=%s" % (sub.topic.decode(), address) for sub in [self.hashblock, self.hashtx, self.rawblock, self.rawtx]], []]
self.add_nodes(self.num_nodes, self.extra_args)
self.nodes[0].extra_args = ["-zmqpub%s=%s" % (sub.topic.decode(), address) for sub in [self.hashblock, self.hashtx, self.rawblock, self.rawtx]]
self.start_nodes()

def import_deterministic_coinbase_privkeys(self):
pass

def run_test(self):
try:
self._zmq_test()
Expand Down
3 changes: 3 additions & 0 deletions test/functional/mempool_accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def set_test_params(self):
'-acceptnonstdtxn=0', # Try to mimic main-net
]] * self.num_nodes

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def check_mempool_result(self, result_expected, *args, **kwargs):
"""Wrapper to check result of testmempoolaccept on node_0's mempool"""
result_test = self.nodes[0].testmempoolaccept(*args, **kwargs)
Expand Down
3 changes: 3 additions & 0 deletions test/functional/mempool_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def set_test_params(self):
self.num_nodes = 1
self.extra_args = [["-maxmempool=5", "-spendzeroconfchange=0"]]

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
txouts = gen_return_txouts()
relayfee = self.nodes[0].getnetworkinfo()['relayfee']
Expand Down
Loading

0 comments on commit 288ddf4

Please sign in to comment.