aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/data/rpc_psbt.json8
-rwxr-xr-xtest/functional/feature_help.py43
-rwxr-xr-xtest/functional/feature_reindex.py2
-rwxr-xr-xtest/functional/mempool_accept.py1
-rwxr-xr-xtest/functional/mempool_reorg.py3
-rwxr-xr-xtest/functional/mempool_resurrect.py3
-rwxr-xr-xtest/functional/mempool_spend_coinbase.py3
-rwxr-xr-xtest/functional/p2p_invalid_locator.py43
-rwxr-xr-xtest/functional/rpc_bind.py6
-rwxr-xr-xtest/functional/rpc_blockchain.py11
-rwxr-xr-xtest/functional/rpc_getblockstats.py14
-rwxr-xr-xtest/functional/rpc_users.py3
-rwxr-xr-xtest/functional/test_framework/messages.py1
-rwxr-xr-xtest/functional/test_framework/mininode.py9
-rwxr-xr-xtest/functional/test_framework/test_framework.py50
-rwxr-xr-xtest/functional/test_framework/test_node.py7
-rwxr-xr-xtest/functional/test_runner.py1
-rwxr-xr-xtest/functional/wallet_txn_clone.py8
-rwxr-xr-xtest/functional/wallet_txn_doublespend.py4
-rw-r--r--test/util/data/txcreatesignv1.hex2
-rw-r--r--test/util/data/txcreatesignv1.json16
21 files changed, 143 insertions, 95 deletions
diff --git a/test/functional/data/rpc_psbt.json b/test/functional/data/rpc_psbt.json
index 4e2f08f274..d800fa97a5 100644
--- a/test/functional/data/rpc_psbt.json
+++ b/test/functional/data/rpc_psbt.json
@@ -57,14 +57,6 @@
],
"psbt" : "cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuyq911AAAAAAD/////g40EJ9DsZQpoqka7CwmK6kQiwHGyyng1Kgd5WdB86h0BAAAAAP////8CcKrwCAAAAAAWABTYXCtx0AYLCcmIauuBXlCZHdoSTQDh9QUAAAAAFgAUAK6pouXw+HaliN9VRuh0LR2HAI8AAAAAAAEAuwIAAAABqtc5MQGL0l+ErkALaISL4J23BurCrBgpi6vucatlb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AAAQRHUiEClYO/Oa4KYJdHrRma3dY0+mEIVZ1sXNObTCGD8auW4H8hAtq2H/SaFNtqfQKwzR+7ePxLGDErW05U2uTbovv+9TbXUq4iBgKVg785rgpgl0etGZrd1jT6YQhVnWxc05tMIYPxq5bgfxDZDGpPAAAAgAAAAIAAAACAIgYC2rYf9JoU22p9ArDNH7t4/EsYMStbTlTa5Nui+/71NtcQ2QxqTwAAAIAAAACAAQAAgAABASAAwusLAAAAABepFLf1+vQOPUClpFmx2zU18rcvqSHohyICAjrdkE89bc9Z3bkGsN7iNSm3/7ntUOXoYVGSaGAiHw5zRzBEAiBl9FulmYtZon/+GnvtAWrx8fkNVLOqj3RQql9WolEDvQIgf3JHA60e25ZoCyhLVtT/y4j3+3Weq74IqjDym4UTg9IBAQMEAQAAAAEEIgAgjCNTFzdDtZXftKB7crqOQuN5fadOh/59nXSX47ICiQMBBUdSIQMIncEMesbbVPkTKa9hczPbOIzq0MIx9yM3nRuZAwsC3CECOt2QTz1tz1nduQaw3uI1Kbf/ue1Q5ehhUZJoYCIfDnNSriIGAjrdkE89bc9Z3bkGsN7iNSm3/7ntUOXoYVGSaGAiHw5zENkMak8AAACAAAAAgAMAAIAiBgMIncEMesbbVPkTKa9hczPbOIzq0MIx9yM3nRuZAwsC3BDZDGpPAAAAgAAAAIACAACAACICA6mkw39ZltOqJdusa1cK8GUDlEkpQkYLNUdT7Z7spYdxENkMak8AAACAAAAAgAQAAIAAIgICf2OZdX0u/1WhNq0CxoSxg4tlVuXxtrNCgqlLa1AFEJYQ2QxqTwAAAIAAAACABQAAgAA="
}
],
"combiner" : [
diff --git a/test/functional/feature_help.py b/test/functional/feature_help.py
index d38275a9ca..ed1d25c0d6 100755
--- a/test/functional/feature_help.py
+++ b/test/functional/feature_help.py
@@ -3,7 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Verify that starting bitcoin with -h works as expected."""
-import subprocess
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
@@ -17,41 +16,47 @@ class HelpTest(BitcoinTestFramework):
self.add_nodes(self.num_nodes)
# Don't start the node
+ def get_node_output(self, *, ret_code_expected):
+ ret_code = self.nodes[0].process.wait(timeout=5)
+ assert_equal(ret_code, ret_code_expected)
+ self.nodes[0].stdout.seek(0)
+ self.nodes[0].stderr.seek(0)
+ out = self.nodes[0].stdout.read()
+ err = self.nodes[0].stderr.read()
+ self.nodes[0].stdout.close()
+ self.nodes[0].stderr.close()
+
+ # Clean up TestNode state
+ self.nodes[0].running = False
+ self.nodes[0].process = None
+ self.nodes[0].rpc_connected = False
+ self.nodes[0].rpc = None
+
+ return out, err
+
def run_test(self):
self.log.info("Start bitcoin with -h for help text")
- self.nodes[0].start(extra_args=['-h'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.nodes[0].start(extra_args=['-h'])
# Node should exit immediately and output help to stdout.
- ret_code = self.nodes[0].process.wait(timeout=1)
- assert_equal(ret_code, 0)
- output = self.nodes[0].process.stdout.read()
+ output, _ = self.get_node_output(ret_code_expected=0)
assert b'Options' in output
self.log.info("Help text received: {} (...)".format(output[0:60]))
- self.nodes[0].running = False
self.log.info("Start bitcoin with -version for version information")
- self.nodes[0].start(extra_args=['-version'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.nodes[0].start(extra_args=['-version'])
# Node should exit immediately and output version to stdout.
- ret_code = self.nodes[0].process.wait(timeout=1)
- assert_equal(ret_code, 0)
- output = self.nodes[0].process.stdout.read()
+ output, _ = self.get_node_output(ret_code_expected=0)
assert b'version' in output
self.log.info("Version text received: {} (...)".format(output[0:60]))
# Test that arguments not in the help results in an error
self.log.info("Start bitcoind with -fakearg to make sure it does not start")
- self.nodes[0].start(extra_args=['-fakearg'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ self.nodes[0].start(extra_args=['-fakearg'])
# Node should exit immediately and output an error to stderr
- ret_code = self.nodes[0].process.wait(timeout=1)
- assert_equal(ret_code, 1)
- output = self.nodes[0].process.stderr.read()
+ _, output = self.get_node_output(ret_code_expected=1)
assert b'Error parsing command line arguments' in output
self.log.info("Error message received: {} (...)".format(output[0:60]))
- # Clean up TestNode state
- self.nodes[0].running = False
- self.nodes[0].process = None
- self.nodes[0].rpc_connected = False
- self.nodes[0].rpc = None
if __name__ == '__main__':
HelpTest().main()
diff --git a/test/functional/feature_reindex.py b/test/functional/feature_reindex.py
index 712de401ec..f30e1191e3 100755
--- a/test/functional/feature_reindex.py
+++ b/test/functional/feature_reindex.py
@@ -22,7 +22,7 @@ class ReindexTest(BitcoinTestFramework):
self.nodes[0].generate(3)
blockcount = self.nodes[0].getblockcount()
self.stop_nodes()
- extra_args = [["-reindex-chainstate" if justchainstate else "-reindex", "-checkblockindex=1"]]
+ extra_args = [["-reindex-chainstate" if justchainstate else "-reindex"]]
self.start_nodes(extra_args)
wait_until(lambda: self.nodes[0].getblockcount() == blockcount)
self.log.info("Success")
diff --git a/test/functional/mempool_accept.py b/test/functional/mempool_accept.py
index 7cdb24c6a5..44426a0ff7 100755
--- a/test/functional/mempool_accept.py
+++ b/test/functional/mempool_accept.py
@@ -35,7 +35,6 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.extra_args = [[
- '-checkmempool',
'-txindex',
'-reindex', # Need reindex for txindex
'-acceptnonstdtxn=0', # Try to mimic main-net
diff --git a/test/functional/mempool_reorg.py b/test/functional/mempool_reorg.py
index afacd69d54..7d1e7e0478 100755
--- a/test/functional/mempool_reorg.py
+++ b/test/functional/mempool_reorg.py
@@ -12,11 +12,10 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
from test_framework.util import *
-# Create one-input, one-output, no-fee transaction:
+
class MempoolCoinbaseTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 2
- self.extra_args = [["-checkmempool"]] * 2
alert_filename = None # Set by setup_network
diff --git a/test/functional/mempool_resurrect.py b/test/functional/mempool_resurrect.py
index 3625e011eb..7ae0d95b90 100755
--- a/test/functional/mempool_resurrect.py
+++ b/test/functional/mempool_resurrect.py
@@ -8,11 +8,10 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
from test_framework.util import *
-# Create one-input, one-output, no-fee transaction:
+
class MempoolCoinbaseTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
- self.extra_args = [["-checkmempool"]]
def run_test(self):
node0_address = self.nodes[0].getnewaddress()
diff --git a/test/functional/mempool_spend_coinbase.py b/test/functional/mempool_spend_coinbase.py
index 74a3634a6c..9370c77183 100755
--- a/test/functional/mempool_spend_coinbase.py
+++ b/test/functional/mempool_spend_coinbase.py
@@ -16,11 +16,10 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
from test_framework.util import *
-# Create one-input, one-output, no-fee transaction:
+
class MempoolSpendCoinbaseTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
- self.extra_args = [["-checkmempool"]]
def run_test(self):
chain_height = self.nodes[0].getblockcount()
diff --git a/test/functional/p2p_invalid_locator.py b/test/functional/p2p_invalid_locator.py
new file mode 100755
index 0000000000..3b1654f920
--- /dev/null
+++ b/test/functional/p2p_invalid_locator.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+# Copyright (c) 2015-2017 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""Test node responses to invalid locators.
+"""
+
+from test_framework.messages import msg_getheaders, msg_getblocks, MAX_LOCATOR_SZ
+from test_framework.mininode import P2PInterface
+from test_framework.test_framework import BitcoinTestFramework
+
+
+class InvalidLocatorTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 1
+ self.setup_clean_chain = False
+
+ def run_test(self):
+ node = self.nodes[0] # convenience reference to the node
+ node.generate(1) # Get node out of IBD
+
+ self.log.info('Test max locator size')
+ block_count = node.getblockcount()
+ for msg in [msg_getheaders(), msg_getblocks()]:
+ self.log.info('Wait for disconnect when sending {} hashes in locator'.format(MAX_LOCATOR_SZ + 1))
+ node.add_p2p_connection(P2PInterface())
+ msg.locator.vHave = [int(node.getblockhash(i - 1), 16) for i in range(block_count, block_count - (MAX_LOCATOR_SZ + 1), -1)]
+ node.p2p.send_message(msg)
+ node.p2p.wait_for_disconnect()
+ node.disconnect_p2ps()
+
+ self.log.info('Wait for response when sending {} hashes in locator'.format(MAX_LOCATOR_SZ))
+ node.add_p2p_connection(P2PInterface())
+ msg.locator.vHave = [int(node.getblockhash(i - 1), 16) for i in range(block_count, block_count - (MAX_LOCATOR_SZ), -1)]
+ node.p2p.send_message(msg)
+ if type(msg) == msg_getheaders:
+ node.p2p.wait_for_header(int(node.getbestblockhash(), 16))
+ else:
+ node.p2p.wait_for_block(int(node.getbestblockhash(), 16))
+
+
+if __name__ == '__main__':
+ InvalidLocatorTest().main()
diff --git a/test/functional/rpc_bind.py b/test/functional/rpc_bind.py
index ef82b7e507..ef060f993a 100755
--- a/test/functional/rpc_bind.py
+++ b/test/functional/rpc_bind.py
@@ -20,9 +20,9 @@ class RPCBindTest(BitcoinTestFramework):
self.add_nodes(self.num_nodes, None)
def add_options(self, parser):
- parser.add_option("--ipv4", action='store_true', dest="run_ipv4", help="Run ipv4 tests only", default=False)
- parser.add_option("--ipv6", action='store_true', dest="run_ipv6", help="Run ipv6 tests only", default=False)
- parser.add_option("--nonloopback", action='store_true', dest="run_nonloopback", help="Run non-loopback tests only", default=False)
+ parser.add_argument("--ipv4", action='store_true', dest="run_ipv4", help="Run ipv4 tests only", default=False)
+ parser.add_argument("--ipv6", action='store_true', dest="run_ipv6", help="Run ipv6 tests only", default=False)
+ parser.add_argument("--nonloopback", action='store_true', dest="run_nonloopback", help="Run non-loopback tests only", default=False)
def run_bind_test(self, allow_ips, connect_to, addresses, expected):
'''
diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py
index 49f44b0c6d..d681cdc8ab 100755
--- a/test/functional/rpc_blockchain.py
+++ b/test/functional/rpc_blockchain.py
@@ -194,13 +194,10 @@ class BlockchainTest(BitcoinTestFramework):
node.reconsiderblock(b1hash)
res3 = node.gettxoutsetinfo()
- assert_equal(res['total_amount'], res3['total_amount'])
- assert_equal(res['transactions'], res3['transactions'])
- assert_equal(res['height'], res3['height'])
- assert_equal(res['txouts'], res3['txouts'])
- assert_equal(res['bogosize'], res3['bogosize'])
- assert_equal(res['bestblock'], res3['bestblock'])
- assert_equal(res['hash_serialized_2'], res3['hash_serialized_2'])
+ # The field 'disk_size' is non-deterministic and can thus not be
+ # compared between res and res3. Everything else should be the same.
+ del res['disk_size'], res3['disk_size']
+ assert_equal(res, res3)
def _test_getblockheader(self):
node = self.nodes[0]
diff --git a/test/functional/rpc_getblockstats.py b/test/functional/rpc_getblockstats.py
index 37ef9f2b68..af9a544fd7 100755
--- a/test/functional/rpc_getblockstats.py
+++ b/test/functional/rpc_getblockstats.py
@@ -35,13 +35,13 @@ class GetblockstatsTest(BitcoinTestFramework):
]
def add_options(self, parser):
- parser.add_option('--gen-test-data', dest='gen_test_data',
- default=False, action='store_true',
- help='Generate test data')
- parser.add_option('--test-data', dest='test_data',
- default='data/rpc_getblockstats.json',
- action='store', metavar='FILE',
- help='Test data file')
+ parser.add_argument('--gen-test-data', dest='gen_test_data',
+ default=False, action='store_true',
+ help='Generate test data')
+ parser.add_argument('--test-data', dest='test_data',
+ default='data/rpc_getblockstats.json',
+ action='store', metavar='FILE',
+ help='Test data file')
def set_test_params(self):
self.num_nodes = 2
diff --git a/test/functional/rpc_users.py b/test/functional/rpc_users.py
index d631cd022b..102dd22594 100755
--- a/test/functional/rpc_users.py
+++ b/test/functional/rpc_users.py
@@ -18,6 +18,7 @@ import subprocess
from random import SystemRandom
import string
import configparser
+import sys
class HTTPBasicsTest(BitcoinTestFramework):
@@ -36,7 +37,7 @@ class HTTPBasicsTest(BitcoinTestFramework):
config = configparser.ConfigParser()
config.read_file(open(self.options.configfile))
gen_rpcauth = config['environment']['RPCAUTH']
- p = subprocess.Popen([gen_rpcauth, self.user], stdout=subprocess.PIPE, universal_newlines=True)
+ p = subprocess.Popen([sys.executable, gen_rpcauth, self.user], stdout=subprocess.PIPE, universal_newlines=True)
lines = p.stdout.read().splitlines()
rpcauth3 = lines[1]
self.password = lines[3]
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index 259b9fb019..7276f6b450 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -32,6 +32,7 @@ MY_SUBVERSION = b"/python-mininode-tester:0.0.3/"
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
MAX_INV_SZ = 50000
+MAX_LOCATOR_SZ = 101
MAX_BLOCK_BASE_SIZE = 1000000
COIN = 100000000 # 1 btc in satoshis
diff --git a/test/functional/test_framework/mininode.py b/test/functional/test_framework/mininode.py
index b7dce3dcb9..ba37e17930 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -332,6 +332,15 @@ class P2PInterface(P2PConnection):
test_function = lambda: self.last_message.get("block") and self.last_message["block"].block.rehash() == blockhash
wait_until(test_function, timeout=timeout, lock=mininode_lock)
+ def wait_for_header(self, blockhash, timeout=60):
+ def test_function():
+ last_headers = self.last_message.get('headers')
+ if not last_headers:
+ return False
+ return last_headers.headers[0].rehash() == blockhash
+
+ wait_until(test_function, timeout=timeout, lock=mininode_lock)
+
def wait_for_getdata(self, timeout=60):
"""Waits for a getdata message.
diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index e69919605d..b876d9bd76 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -7,7 +7,7 @@
import configparser
from enum import Enum
import logging
-import optparse
+import argparse
import os
import pdb
import shutil
@@ -96,31 +96,31 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def main(self):
"""Main function. This should not be overridden by the subclass test scripts."""
- parser = optparse.OptionParser(usage="%prog [options]")
- parser.add_option("--nocleanup", dest="nocleanup", default=False, action="store_true",
- help="Leave bitcoinds and test.* datadir on exit or error")
- parser.add_option("--noshutdown", dest="noshutdown", default=False, action="store_true",
- help="Don't stop bitcoinds after the test execution")
- parser.add_option("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
- help="Directory for caching pregenerated datadirs (default: %default)")
- parser.add_option("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
- parser.add_option("-l", "--loglevel", dest="loglevel", default="INFO",
- help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.")
- parser.add_option("--tracerpc", dest="trace_rpc", default=False, action="store_true",
- help="Print out all RPC calls as they are made")
- parser.add_option("--portseed", dest="port_seed", default=os.getpid(), type='int',
- help="The seed to use for assigning port numbers (default: current process id)")
- parser.add_option("--coveragedir", dest="coveragedir",
- help="Write tested RPC commands into this directory")
- parser.add_option("--configfile", dest="configfile",
- default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../config.ini"),
- help="Location of the test framework config file (default: %default)")
- parser.add_option("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
- help="Attach a python debugger if test fails")
- parser.add_option("--usecli", dest="usecli", default=False, action="store_true",
- help="use bitcoin-cli instead of RPC for all commands")
+ parser = argparse.ArgumentParser(usage="%(prog)s [options]")
+ parser.add_argument("--nocleanup", dest="nocleanup", default=False, action="store_true",
+ help="Leave bitcoinds and test.* datadir on exit or error")
+ parser.add_argument("--noshutdown", dest="noshutdown", default=False, action="store_true",
+ help="Don't stop bitcoinds after the test execution")
+ parser.add_argument("--cachedir", dest="cachedir", default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../cache"),
+ help="Directory for caching pregenerated datadirs (default: %(default)s)")
+ parser.add_argument("--tmpdir", dest="tmpdir", help="Root directory for datadirs")
+ parser.add_argument("-l", "--loglevel", dest="loglevel", default="INFO",
+ help="log events at this level and higher to the console. Can be set to DEBUG, INFO, WARNING, ERROR or CRITICAL. Passing --loglevel DEBUG will output all logs to console. Note that logs at all levels are always written to the test_framework.log file in the temporary test directory.")
+ parser.add_argument("--tracerpc", dest="trace_rpc", default=False, action="store_true",
+ help="Print out all RPC calls as they are made")
+ parser.add_argument("--portseed", dest="port_seed", default=os.getpid(), type=int,
+ help="The seed to use for assigning port numbers (default: current process id)")
+ parser.add_argument("--coveragedir", dest="coveragedir",
+ help="Write tested RPC commands into this directory")
+ parser.add_argument("--configfile", dest="configfile",
+ default=os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../../config.ini"),
+ help="Location of the test framework config file (default: %(default)s)")
+ parser.add_argument("--pdbonfailure", dest="pdbonfailure", default=False, action="store_true",
+ help="Attach a python debugger if test fails")
+ parser.add_argument("--usecli", dest="usecli", default=False, action="store_true",
+ help="use bitcoin-cli instead of RPC for all commands")
self.add_options(parser)
- (self.options, self.args) = parser.parse_args()
+ self.options = parser.parse_args()
PortSeed.n = self.options.port_seed
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 56ea110f16..0d00cc2082 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -122,7 +122,7 @@ class TestNode():
assert self.rpc_connected and self.rpc is not None, self._node_msg("Error: no RPC connection")
return getattr(self.rpc, name)
- def start(self, extra_args=None, stdout=None, stderr=None, *args, **kwargs):
+ def start(self, extra_args=None, *, stdout=None, stderr=None, **kwargs):
"""Start the node."""
if extra_args is None:
extra_args = self.extra_args
@@ -143,7 +143,7 @@ class TestNode():
# add environment variable LIBC_FATAL_STDERR_=1 so that libc errors are written to stderr and not the terminal
subp_env = dict(os.environ, LIBC_FATAL_STDERR_="1")
- self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, *args, **kwargs)
+ self.process = subprocess.Popen(self.args + extra_args, env=subp_env, stdout=stdout, stderr=stderr, **kwargs)
self.running = True
self.log.debug("bitcoind started, waiting for RPC to come up")
@@ -200,6 +200,9 @@ class TestNode():
if stderr != expected_stderr:
raise AssertionError("Unexpected stderr {} != {}".format(stderr, expected_stderr))
+ self.stdout.close()
+ self.stderr.close()
+
del self.p2ps[:]
def is_node_stopped(self):
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index dd4a7b2161..feea2a327a 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -115,6 +115,7 @@ BASE_SCRIPTS = [
'wallet_keypool.py',
'p2p_mempool.py',
'mining_prioritisetransaction.py',
+ 'p2p_invalid_locator.py',
'p2p_invalid_block.py',
'p2p_invalid_tx.py',
'rpc_createmultisig.py',
diff --git a/test/functional/wallet_txn_clone.py b/test/functional/wallet_txn_clone.py
index 2fce6eae8a..4ca4ee14e9 100755
--- a/test/functional/wallet_txn_clone.py
+++ b/test/functional/wallet_txn_clone.py
@@ -17,10 +17,10 @@ class TxnMallTest(BitcoinTestFramework):
self.num_nodes = 4
def add_options(self, parser):
- parser.add_option("--mineblock", dest="mine_block", default=False, action="store_true",
- help="Test double-spend of 1-confirmed transaction")
- parser.add_option("--segwit", dest="segwit", default=False, action="store_true",
- help="Test behaviour with SegWit txn (which should fail")
+ parser.add_argument("--mineblock", dest="mine_block", default=False, action="store_true",
+ help="Test double-spend of 1-confirmed transaction")
+ parser.add_argument("--segwit", dest="segwit", default=False, action="store_true",
+ help="Test behaviour with SegWit txn (which should fail")
def setup_network(self):
# Start with split network:
diff --git a/test/functional/wallet_txn_doublespend.py b/test/functional/wallet_txn_doublespend.py
index 8903fc0e0e..6811f6ab73 100755
--- a/test/functional/wallet_txn_doublespend.py
+++ b/test/functional/wallet_txn_doublespend.py
@@ -19,8 +19,8 @@ class TxnMallTest(BitcoinTestFramework):
self.num_nodes = 4
def add_options(self, parser):
- parser.add_option("--mineblock", dest="mine_block", default=False, action="store_true",
- help="Test double-spend of 1-confirmed transaction")
+ parser.add_argument("--mineblock", dest="mine_block", default=False, action="store_true",
+ help="Test double-spend of 1-confirmed transaction")
def setup_network(self):
# Start with split network:
diff --git a/test/util/data/txcreatesignv1.hex b/test/util/data/txcreatesignv1.hex
index a46fcc88cb..40039319bd 100644
--- a/test/util/data/txcreatesignv1.hex
+++ b/test/util/data/txcreatesignv1.hex
@@ -1 +1 @@
-01000000018594c5bdcaec8f06b78b596f31cd292a294fd031e24eec716f43dac91ea7494d000000008b48304502210096a75056c9e2cc62b7214777b3d2a592cfda7092520126d4ebfcd6d590c99bd8022051bb746359cf98c0603f3004477eac68701132380db8facba19c89dc5ab5c5e201410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff01a0860100000000001976a9145834479edbbe0539b31ffd3a8f8ebadc2165ed0188ac00000000
+01000000018594c5bdcaec8f06b78b596f31cd292a294fd031e24eec716f43dac91ea7494d000000008a4730440220131432090a6af42da3e8335ff110831b41a44f4e9d18d88f5d50278380696c7202200fc2e48938f323ad13625890c0ea926c8a189c08b8efc38376b20c8a2188e96e01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff01a0860100000000001976a9145834479edbbe0539b31ffd3a8f8ebadc2165ed0188ac00000000
diff --git a/test/util/data/txcreatesignv1.json b/test/util/data/txcreatesignv1.json
index 64e5137f4b..7a06aa9ffe 100644
--- a/test/util/data/txcreatesignv1.json
+++ b/test/util/data/txcreatesignv1.json
@@ -1,18 +1,18 @@
{
- "txid": "977e7cd286cb72cd470d539ba6cb48400f8f387d97451d45cdb8819437a303af",
- "hash": "977e7cd286cb72cd470d539ba6cb48400f8f387d97451d45cdb8819437a303af",
+ "txid": "ffc7e509ec3fd60a182eb712621d41a47dc7d4ff310a70826c2fb0e9afb3fa02",
+ "hash": "ffc7e509ec3fd60a182eb712621d41a47dc7d4ff310a70826c2fb0e9afb3fa02",
"version": 1,
- "size": 224,
- "vsize": 224,
- "weight": 896,
+ "size": 223,
+ "vsize": 223,
+ "weight": 892,
"locktime": 0,
"vin": [
{
"txid": "4d49a71ec9da436f71ec4ee231d04f292a29cd316f598bb7068feccabdc59485",
"vout": 0,
"scriptSig": {
- "asm": "304502210096a75056c9e2cc62b7214777b3d2a592cfda7092520126d4ebfcd6d590c99bd8022051bb746359cf98c0603f3004477eac68701132380db8facba19c89dc5ab5c5e2[ALL] 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",
- "hex": "48304502210096a75056c9e2cc62b7214777b3d2a592cfda7092520126d4ebfcd6d590c99bd8022051bb746359cf98c0603f3004477eac68701132380db8facba19c89dc5ab5c5e201410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
+ "asm": "30440220131432090a6af42da3e8335ff110831b41a44f4e9d18d88f5d50278380696c7202200fc2e48938f323ad13625890c0ea926c8a189c08b8efc38376b20c8a2188e96e[ALL] 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",
+ "hex": "4730440220131432090a6af42da3e8335ff110831b41a44f4e9d18d88f5d50278380696c7202200fc2e48938f323ad13625890c0ea926c8a189c08b8efc38376b20c8a2188e96e01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"
},
"sequence": 4294967295
}
@@ -32,5 +32,5 @@
}
}
],
- "hex": "01000000018594c5bdcaec8f06b78b596f31cd292a294fd031e24eec716f43dac91ea7494d000000008b48304502210096a75056c9e2cc62b7214777b3d2a592cfda7092520126d4ebfcd6d590c99bd8022051bb746359cf98c0603f3004477eac68701132380db8facba19c89dc5ab5c5e201410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff01a0860100000000001976a9145834479edbbe0539b31ffd3a8f8ebadc2165ed0188ac00000000"
+ "hex": "01000000018594c5bdcaec8f06b78b596f31cd292a294fd031e24eec716f43dac91ea7494d000000008a4730440220131432090a6af42da3e8335ff110831b41a44f4e9d18d88f5d50278380696c7202200fc2e48938f323ad13625890c0ea926c8a189c08b8efc38376b20c8a2188e96e01410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ffffffff01a0860100000000001976a9145834479edbbe0539b31ffd3a8f8ebadc2165ed0188ac00000000"
}