aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/data/rpc_getblockstats.json24
-rw-r--r--test/functional/data/rpc_psbt.json8
-rwxr-xr-xtest/functional/feature_bip68_sequence.py8
-rwxr-xr-xtest/functional/feature_cltv.py12
-rwxr-xr-xtest/functional/feature_csv_activation.py13
-rwxr-xr-xtest/functional/feature_dbcrash.py5
-rwxr-xr-xtest/functional/feature_dersig.py14
-rwxr-xr-xtest/functional/feature_fee_estimation.py2
-rwxr-xr-xtest/functional/feature_help.py43
-rwxr-xr-xtest/functional/feature_maxuploadtarget.py5
-rwxr-xr-xtest/functional/feature_nulldummy.py19
-rwxr-xr-xtest/functional/feature_pruning.py3
-rwxr-xr-xtest/functional/feature_rbf.py8
-rwxr-xr-xtest/functional/feature_reindex.py2
-rwxr-xr-xtest/functional/feature_segwit.py12
-rwxr-xr-xtest/functional/interface_http.py2
-rwxr-xr-xtest/functional/interface_zmq.py2
-rwxr-xr-xtest/functional/mempool_accept.py1
-rwxr-xr-xtest/functional/mempool_limit.py4
-rwxr-xr-xtest/functional/mempool_packages.py6
-rwxr-xr-xtest/functional/mempool_persist.py3
-rwxr-xr-xtest/functional/mempool_reorg.py19
-rwxr-xr-xtest/functional/mempool_resurrect.py19
-rwxr-xr-xtest/functional/mempool_spend_coinbase.py11
-rwxr-xr-xtest/functional/mining_basic.py2
-rwxr-xr-xtest/functional/mining_getblocktemplate_longpoll.py4
-rwxr-xr-xtest/functional/mining_prioritisetransaction.py6
-rwxr-xr-xtest/functional/p2p_compactblocks.py11
-rwxr-xr-xtest/functional/p2p_feefilter.py8
-rwxr-xr-xtest/functional/p2p_fingerprint.py4
-rwxr-xr-xtest/functional/p2p_invalid_locator.py43
-rwxr-xr-xtest/functional/p2p_leak.py7
-rwxr-xr-xtest/functional/p2p_mempool.py5
-rwxr-xr-xtest/functional/p2p_node_network_limited.py6
-rwxr-xr-xtest/functional/p2p_sendheaders.py2
-rwxr-xr-xtest/functional/p2p_timeouts.py4
-rwxr-xr-xtest/functional/p2p_unrequested_blocks.py8
-rwxr-xr-xtest/functional/rpc_bind.py10
-rwxr-xr-xtest/functional/rpc_blockchain.py11
-rwxr-xr-xtest/functional/rpc_decodescript.py5
-rwxr-xr-xtest/functional/rpc_getblockstats.py16
-rwxr-xr-xtest/functional/rpc_invalidateblock.py4
-rwxr-xr-xtest/functional/rpc_psbt.py5
-rwxr-xr-xtest/functional/rpc_rawtransaction.py3
-rwxr-xr-xtest/functional/rpc_scantxoutset.py3
-rwxr-xr-xtest/functional/rpc_signrawtransaction.py2
-rwxr-xr-xtest/functional/rpc_txoutproof.py5
-rwxr-xr-xtest/functional/rpc_users.py3
-rw-r--r--test/functional/test_framework/blocktools.py12
-rwxr-xr-xtest/functional/test_framework/messages.py1
-rwxr-xr-xtest/functional/test_framework/mininode.py11
-rw-r--r--test/functional/test_framework/script.py3
-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_abandonconflict.py5
-rwxr-xr-xtest/functional/wallet_backup.py4
-rwxr-xr-xtest/functional/wallet_bumpfee.py14
-rwxr-xr-xtest/functional/wallet_disable.py2
-rwxr-xr-xtest/functional/wallet_fallbackfee.py2
-rwxr-xr-xtest/functional/wallet_groups.py3
-rwxr-xr-xtest/functional/wallet_importmulti.py2
-rwxr-xr-xtest/functional/wallet_keypool.py4
-rwxr-xr-xtest/functional/wallet_listtransactions.py2
-rwxr-xr-xtest/functional/wallet_txn_clone.py8
-rwxr-xr-xtest/functional/wallet_txn_doublespend.py4
-rwxr-xr-xtest/lint/lint-format-strings.py38
-rwxr-xr-xtest/lint/lint-python.sh4
-rwxr-xr-xtest/util/bitcoin-util-test.py2
-rw-r--r--test/util/data/txcreatesignv1.hex2
-rw-r--r--test/util/data/txcreatesignv1.json16
71 files changed, 383 insertions, 236 deletions
diff --git a/test/functional/data/rpc_getblockstats.json b/test/functional/data/rpc_getblockstats.json
index 750abc5c42..b8cabe1e5e 100644
--- a/test/functional/data/rpc_getblockstats.json
+++ b/test/functional/data/rpc_getblockstats.json
@@ -112,13 +112,19 @@
"avgfeerate": 0,
"avgtxsize": 0,
"blockhash": "1d7fe80f19d28b8e712af0399ac84006db753441f3033111b3a8d610afab364f",
+ "feerate_percentiles": [
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+ ],
"height": 101,
"ins": 0,
"maxfee": 0,
"maxfeerate": 0,
"maxtxsize": 0,
"medianfee": 0,
- "medianfeerate": 0,
"mediantime": 1525107242,
"mediantxsize": 0,
"minfee": 0,
@@ -144,12 +150,18 @@
"avgtxsize": 187,
"blockhash": "4e21a43675d7a41cb6b944e068c5bcd0a677baf658d9ebe021ae2d2f99397ccc",
"height": 102,
+ "feerate_percentiles": [
+ 20,
+ 20,
+ 20,
+ 20,
+ 20
+ ],
"ins": 1,
"maxfee": 3760,
"maxfeerate": 20,
"maxtxsize": 187,
"medianfee": 3760,
- "medianfeerate": 20,
"mediantime": 1525107242,
"mediantxsize": 187,
"minfee": 3760,
@@ -174,13 +186,19 @@
"avgfeerate": 109,
"avgtxsize": 228,
"blockhash": "22d9b8b9c2a37c81515f3fc84f7241f6c07dbcea85ef16b00bcc33ae400a030f",
+ "feerate_percentiles": [
+ 20,
+ 20,
+ 20,
+ 300,
+ 300
+ ],
"height": 103,
"ins": 3,
"maxfee": 49800,
"maxfeerate": 300,
"maxtxsize": 248,
"medianfee": 3760,
- "medianfeerate": 20,
"mediantime": 1525107243,
"mediantxsize": 248,
"minfee": 3320,
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" : "cHNidP8BAJoCAAAAAljoeiG1ba8MI76OcHBFbDNvfLqlyHV5JPVFiHuy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a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py
index 3a7e39f7fd..4a9445f503 100755
--- a/test/functional/feature_bip68_sequence.py
+++ b/test/functional/feature_bip68_sequence.py
@@ -4,9 +4,13 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP68 implementation."""
+import time
+
+from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
+from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, FromHex, ToHex
+from test_framework.script import CScript
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.blocktools import *
+from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, bytes_to_hex_str, get_bip9_status, satoshi_round, sync_blocks
SEQUENCE_LOCKTIME_DISABLE_FLAG = (1<<31)
SEQUENCE_LOCKTIME_TYPE_FLAG = (1<<22) # this means use time (0 means height)
diff --git a/test/functional/feature_cltv.py b/test/functional/feature_cltv.py
index cc59ea8c9b..8460291831 100755
--- a/test/functional/feature_cltv.py
+++ b/test/functional/feature_cltv.py
@@ -8,11 +8,13 @@ Test that the CHECKLOCKTIMEVERIFY soft-fork activates at (regtest) block height
1351.
"""
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import *
from test_framework.blocktools import create_coinbase, create_block, create_transaction
+from test_framework.messages import CTransaction, msg_block, ToHex
+from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.script import CScript, OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP, CScriptNum
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes, wait_until
+
from io import BytesIO
CLTV_HEIGHT = 1351
@@ -65,7 +67,7 @@ class BIP65Test(BitcoinTestFramework):
self.log.info("Test that an invalid-according-to-CLTV transaction can still appear in a block")
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[0],
- self.nodeaddress, 1.0)
+ self.nodeaddress, amount=1.0)
cltv_invalidate(spendtx)
spendtx.rehash()
@@ -100,7 +102,7 @@ class BIP65Test(BitcoinTestFramework):
block.nVersion = 4
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[1],
- self.nodeaddress, 1.0)
+ self.nodeaddress, amount=1.0)
cltv_invalidate(spendtx)
spendtx.rehash()
diff --git a/test/functional/feature_csv_activation.py b/test/functional/feature_csv_activation.py
index 2d17c3d8c4..af14feb471 100755
--- a/test/functional/feature_csv_activation.py
+++ b/test/functional/feature_csv_activation.py
@@ -94,15 +94,14 @@ def sign_transaction(node, unsignedtx):
return tx
def create_bip112special(node, input, txversion, address):
- tx = create_transaction(node, input, address, Decimal("49.98"))
+ tx = create_transaction(node, input, address, amount=Decimal("49.98"))
tx.nVersion = txversion
signtx = sign_transaction(node, tx)
signtx.vin[0].scriptSig = CScript([-1, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(signtx.vin[0].scriptSig)))
return signtx
def send_generic_input_tx(node, coinbases, address):
- amount = Decimal("49.99")
- return node.sendrawtransaction(ToHex(sign_transaction(node, create_transaction(node, node.getblock(coinbases.pop())['tx'][0], address, amount))))
+ return node.sendrawtransaction(ToHex(sign_transaction(node, create_transaction(node, node.getblock(coinbases.pop())['tx'][0], address, amount=Decimal("49.99")))))
def create_bip68txs(node, bip68inputs, txversion, address, locktime_delta=0):
"""Returns a list of bip68 transactions with different bits set."""
@@ -110,7 +109,7 @@ def create_bip68txs(node, bip68inputs, txversion, address, locktime_delta=0):
assert(len(bip68inputs) >= 16)
for i, (sdf, srhb, stf, srlb) in enumerate(product(*[[True, False]] * 4)):
locktime = relative_locktime(sdf, srhb, stf, srlb)
- tx = create_transaction(node, bip68inputs[i], address, Decimal("49.98"))
+ tx = create_transaction(node, bip68inputs[i], address, amount=Decimal("49.98"))
tx.nVersion = txversion
tx.vin[0].nSequence = locktime + locktime_delta
tx = sign_transaction(node, tx)
@@ -125,7 +124,7 @@ def create_bip112txs(node, bip112inputs, varyOP_CSV, txversion, address, locktim
assert(len(bip112inputs) >= 16)
for i, (sdf, srhb, stf, srlb) in enumerate(product(*[[True, False]] * 4)):
locktime = relative_locktime(sdf, srhb, stf, srlb)
- tx = create_transaction(node, bip112inputs[i], address, Decimal("49.98"))
+ tx = create_transaction(node, bip112inputs[i], address, amount=Decimal("49.98"))
if (varyOP_CSV): # if varying OP_CSV, nSequence is fixed
tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME + locktime_delta
else: # vary nSequence instead, OP_CSV is fixed
@@ -269,10 +268,10 @@ class BIP68_112_113Test(BitcoinTestFramework):
# Test both version 1 and version 2 transactions for all tests
# BIP113 test transaction will be modified before each use to put in appropriate block time
- bip113tx_v1 = create_transaction(self.nodes[0], bip113input, self.nodeaddress, Decimal("49.98"))
+ bip113tx_v1 = create_transaction(self.nodes[0], bip113input, self.nodeaddress, amount=Decimal("49.98"))
bip113tx_v1.vin[0].nSequence = 0xFFFFFFFE
bip113tx_v1.nVersion = 1
- bip113tx_v2 = create_transaction(self.nodes[0], bip113input, self.nodeaddress, Decimal("49.98"))
+ bip113tx_v2 = create_transaction(self.nodes[0], bip113input, self.nodeaddress, amount=Decimal("49.98"))
bip113tx_v2.vin[0].nSequence = 0xFFFFFFFE
bip113tx_v2.nVersion = 2
diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py
index a0535b6cd3..d612dbe2bc 100755
--- a/test/functional/feature_dbcrash.py
+++ b/test/functional/feature_dbcrash.py
@@ -31,10 +31,9 @@ import random
import sys
import time
-from test_framework.mininode import *
-from test_framework.script import *
+from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, ToHex
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, create_confirmed_utxos, hex_str_to_bytes
HTTP_DISCONNECT_ERRORS = [http.client.CannotSendRequest]
try:
diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py
index b53e742681..53e94c436a 100755
--- a/test/functional/feature_dersig.py
+++ b/test/functional/feature_dersig.py
@@ -7,11 +7,12 @@
Test that the DERSIG soft-fork activates at (regtest) height 1251.
"""
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import *
from test_framework.blocktools import create_coinbase, create_block, create_transaction
+from test_framework.messages import msg_block
+from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.script import CScript
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, bytes_to_hex_str, wait_until
DERSIG_HEIGHT = 1251
@@ -54,7 +55,7 @@ class BIP66Test(BitcoinTestFramework):
self.log.info("Test that a transaction with non-DER signature can still appear in a block")
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[0],
- self.nodeaddress, 1.0)
+ self.nodeaddress, amount=1.0)
unDERify(spendtx)
spendtx.rehash()
@@ -91,7 +92,7 @@ class BIP66Test(BitcoinTestFramework):
block.nVersion = 3
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[1],
- self.nodeaddress, 1.0)
+ self.nodeaddress, amount=1.0)
unDERify(spendtx)
spendtx.rehash()
@@ -127,8 +128,7 @@ class BIP66Test(BitcoinTestFramework):
assert b'Non-canonical DER signature' in self.nodes[0].p2p.last_message["reject"].reason
self.log.info("Test that a version 3 block with a DERSIG-compliant transaction is accepted")
- block.vtx[1] = create_transaction(self.nodes[0],
- self.coinbase_txids[1], self.nodeaddress, 1.0)
+ block.vtx[1] = create_transaction(self.nodes[0], self.coinbase_txids[1], self.nodeaddress, amount=1.0)
block.hashMerkleRoot = block.calc_merkle_root()
block.rehash()
block.solve()
diff --git a/test/functional/feature_fee_estimation.py b/test/functional/feature_fee_estimation.py
index 473db5b3d3..709910f2e4 100755
--- a/test/functional/feature_fee_estimation.py
+++ b/test/functional/feature_fee_estimation.py
@@ -6,7 +6,7 @@
from decimal import Decimal
import random
-from test_framework.mininode import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
+from test_framework.messages import CTransaction, CTxIn, CTxOut, COutPoint, ToHex, COIN
from test_framework.script import CScript, OP_1, OP_DROP, OP_2, OP_HASH160, OP_EQUAL, hash160, OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
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_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py
index 88282e9fac..a81ebb4220 100755
--- a/test/functional/feature_maxuploadtarget.py
+++ b/test/functional/feature_maxuploadtarget.py
@@ -13,9 +13,10 @@ if uploadtarget has been reached.
from collections import defaultdict
import time
-from test_framework.mininode import *
+from test_framework.messages import CInv, msg_getdata
+from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, mine_large_block
class TestP2PConn(P2PInterface):
def __init__(self):
diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py
index 21255c89c8..9d1805ec2d 100755
--- a/test/functional/feature_nulldummy.py
+++ b/test/functional/feature_nulldummy.py
@@ -13,11 +13,12 @@ Generate 427 more blocks.
[Policy/Consensus] Check that the new NULLDUMMY rules are enforced on the 432nd block.
"""
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.messages import CTransaction
from test_framework.blocktools import create_coinbase, create_block, create_transaction, add_witness_commitment
+from test_framework.messages import CTransaction
from test_framework.script import CScript
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str
+
import time
NULLDUMMY_ERROR = "non-mandatory-script-verify-flag (Dummy CHECKMULTISIG argument must be zero) (code 64)"
@@ -60,16 +61,16 @@ class NULLDUMMYTest(BitcoinTestFramework):
self.lastblocktime = int(time.time()) + 429
self.log.info("Test 1: NULLDUMMY compliant base transactions should be accepted to mempool and mined before activation [430]")
- test1txs = [create_transaction(self.nodes[0], coinbase_txid[0], self.ms_address, 49)]
+ test1txs = [create_transaction(self.nodes[0], coinbase_txid[0], self.ms_address, amount=49)]
txid1 = self.nodes[0].sendrawtransaction(bytes_to_hex_str(test1txs[0].serialize_with_witness()), True)
- test1txs.append(create_transaction(self.nodes[0], txid1, self.ms_address, 48))
+ test1txs.append(create_transaction(self.nodes[0], txid1, self.ms_address, amount=48))
txid2 = self.nodes[0].sendrawtransaction(bytes_to_hex_str(test1txs[1].serialize_with_witness()), True)
- test1txs.append(create_transaction(self.nodes[0], coinbase_txid[1], self.wit_ms_address, 49))
+ test1txs.append(create_transaction(self.nodes[0], coinbase_txid[1], self.wit_ms_address, amount=49))
txid3 = self.nodes[0].sendrawtransaction(bytes_to_hex_str(test1txs[2].serialize_with_witness()), True)
self.block_submit(self.nodes[0], test1txs, False, True)
self.log.info("Test 2: Non-NULLDUMMY base multisig transaction should not be accepted to mempool before activation")
- test2tx = create_transaction(self.nodes[0], txid2, self.ms_address, 47)
+ test2tx = create_transaction(self.nodes[0], txid2, self.ms_address, amount=47)
trueDummy(test2tx)
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test2tx.serialize_with_witness()), True)
@@ -77,14 +78,14 @@ class NULLDUMMYTest(BitcoinTestFramework):
self.block_submit(self.nodes[0], [test2tx], False, True)
self.log.info("Test 4: Non-NULLDUMMY base multisig transaction is invalid after activation")
- test4tx = create_transaction(self.nodes[0], test2tx.hash, self.address, 46)
+ test4tx = create_transaction(self.nodes[0], test2tx.hash, self.address, amount=46)
test6txs=[CTransaction(test4tx)]
trueDummy(test4tx)
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test4tx.serialize_with_witness()), True)
self.block_submit(self.nodes[0], [test4tx])
self.log.info("Test 5: Non-NULLDUMMY P2WSH multisig transaction invalid after activation")
- test5tx = create_transaction(self.nodes[0], txid3, self.wit_address, 48)
+ test5tx = create_transaction(self.nodes[0], txid3, self.wit_address, amount=48)
test6txs.append(CTransaction(test5tx))
test5tx.wit.vtxinwit[0].scriptWitness.stack[0] = b'\x01'
assert_raises_rpc_error(-26, NULLDUMMY_ERROR, self.nodes[0].sendrawtransaction, bytes_to_hex_str(test5tx.serialize_with_witness()), True)
diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py
index 7b5ea4564f..c8f4b7f8b5 100755
--- a/test/functional/feature_pruning.py
+++ b/test/functional/feature_pruning.py
@@ -10,7 +10,8 @@ This test takes 30 mins or more (up to 2 hours)
"""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, connect_nodes, mine_large_block, sync_blocks, wait_until
+
import os
MIN_BLOCKS_TO_KEEP = 288
diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py
index 8b0e283655..6105da810c 100755
--- a/test/functional/feature_rbf.py
+++ b/test/functional/feature_rbf.py
@@ -4,10 +4,12 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the RBF code."""
+from decimal import Decimal
+
+from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut
+from test_framework.script import CScript, OP_DROP
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.script import *
-from test_framework.mininode import *
+from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, satoshi_round
MAX_REPLACEMENT_LIMIT = 100
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/feature_segwit.py b/test/functional/feature_segwit.py
index ccc4539308..13d7758e13 100755
--- a/test/functional/feature_segwit.py
+++ b/test/functional/feature_segwit.py
@@ -4,19 +4,23 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the SegWit changeover logic."""
+from decimal import Decimal
+
from test_framework.address import (
+ key_to_p2pkh,
key_to_p2sh_p2wpkh,
key_to_p2wpkh,
program_to_witness,
+ script_to_p2sh,
script_to_p2sh_p2wsh,
script_to_p2wsh,
)
from test_framework.blocktools import witness_script, send_to_witness
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import sha256, CTransaction, CTxIn, COutPoint, CTxOut, COIN, ToHex, FromHex
-from test_framework.address import script_to_p2sh, key_to_p2pkh
+from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, FromHex, sha256, ToHex
from test_framework.script import CScript, OP_HASH160, OP_CHECKSIG, OP_0, hash160, OP_EQUAL, OP_DUP, OP_EQUALVERIFY, OP_1, OP_2, OP_CHECKMULTISIG, OP_TRUE, OP_DROP
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes, hex_str_to_bytes, sync_blocks, try_rpc
+
from io import BytesIO
NODE_0 = 0
diff --git a/test/functional/interface_http.py b/test/functional/interface_http.py
index de45d72d64..e4b86f9e1e 100755
--- a/test/functional/interface_http.py
+++ b/test/functional/interface_http.py
@@ -5,7 +5,7 @@
"""Test the RPC HTTP basics."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, str_to_b64str
import http.client
import urllib.parse
diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py
index f1dda0c7d8..72de696259 100755
--- a/test/functional/interface_zmq.py
+++ b/test/functional/interface_zmq.py
@@ -7,7 +7,7 @@ import struct
from test_framework.test_framework import (
BitcoinTestFramework, skip_if_no_bitcoind_zmq, skip_if_no_py3_zmq)
-from test_framework.mininode import CTransaction
+from test_framework.messages import CTransaction
from test_framework.util import (assert_equal,
bytes_to_hex_str,
hash256,
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_limit.py b/test/functional/mempool_limit.py
index 5c2249e7f3..55422b67df 100755
--- a/test/functional/mempool_limit.py
+++ b/test/functional/mempool_limit.py
@@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test mempool limiting together/eviction with the wallet."""
+from decimal import Decimal
+
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, create_confirmed_utxos, create_lots_of_big_transactions, gen_return_txouts
class MempoolLimitTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py
index 7220f0c98c..da254181fe 100755
--- a/test/functional/mempool_packages.py
+++ b/test/functional/mempool_packages.py
@@ -4,9 +4,11 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test descendant package tracking code."""
+from decimal import Decimal
+
+from test_framework.messages import COIN
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import COIN
+from test_framework.util import assert_equal, assert_raises_rpc_error, satoshi_round, sync_blocks, sync_mempools
MAX_ANCESTORS = 25
MAX_DESCENDANTS = 25
diff --git a/test/functional/mempool_persist.py b/test/functional/mempool_persist.py
index ad331fb7f2..6e5f89efb8 100755
--- a/test/functional/mempool_persist.py
+++ b/test/functional/mempool_persist.py
@@ -35,11 +35,12 @@ Test is as follows:
node1 can't write to disk.
"""
+from decimal import Decimal
import os
import time
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error, wait_until
class MempoolPersistTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/mempool_reorg.py b/test/functional/mempool_reorg.py
index afacd69d54..faa00d56cf 100755
--- a/test/functional/mempool_reorg.py
+++ b/test/functional/mempool_reorg.py
@@ -8,15 +8,14 @@ Test re-org scenarios with a mempool that contains transactions
that spend (directly or indirectly) coinbase transactions.
"""
-from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
-from test_framework.util import *
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, assert_raises_rpc_error
+
-# 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
@@ -40,9 +39,9 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
# and make sure the mempool code behaves correctly.
b = [ self.nodes[0].getblockhash(n) for n in range(101, 105) ]
coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ]
- spend_101_raw = create_raw_transaction(self.nodes[0], coinbase_txids[1], node1_address, 49.99)
- spend_102_raw = create_raw_transaction(self.nodes[0], coinbase_txids[2], node0_address, 49.99)
- spend_103_raw = create_raw_transaction(self.nodes[0], coinbase_txids[3], node0_address, 49.99)
+ spend_101_raw = create_raw_transaction(self.nodes[0], coinbase_txids[1], node1_address, amount=49.99)
+ spend_102_raw = create_raw_transaction(self.nodes[0], coinbase_txids[2], node0_address, amount=49.99)
+ spend_103_raw = create_raw_transaction(self.nodes[0], coinbase_txids[3], node0_address, amount=49.99)
# Create a transaction which is time-locked to two blocks in the future
timelock_tx = self.nodes[0].createrawtransaction([{"txid": coinbase_txids[0], "vout": 0}], {node0_address: 49.99})
@@ -58,11 +57,11 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
spend_103_id = self.nodes[0].sendrawtransaction(spend_103_raw)
self.nodes[0].generate(1)
# Time-locked transaction is still too immature to spend
- assert_raises_rpc_error(-26,'non-final', self.nodes[0].sendrawtransaction, timelock_tx)
+ assert_raises_rpc_error(-26, 'non-final', self.nodes[0].sendrawtransaction, timelock_tx)
# Create 102_1 and 103_1:
- spend_102_1_raw = create_raw_transaction(self.nodes[0], spend_102_id, node1_address, 49.98)
- spend_103_1_raw = create_raw_transaction(self.nodes[0], spend_103_id, node1_address, 49.98)
+ spend_102_1_raw = create_raw_transaction(self.nodes[0], spend_102_id, node1_address, amount=49.98)
+ spend_103_1_raw = create_raw_transaction(self.nodes[0], spend_103_id, node1_address, amount=49.98)
# Broadcast and mine 103_1:
spend_103_1_id = self.nodes[0].sendrawtransaction(spend_103_1_raw)
diff --git a/test/functional/mempool_resurrect.py b/test/functional/mempool_resurrect.py
index 3625e011eb..23939f0be5 100755
--- a/test/functional/mempool_resurrect.py
+++ b/test/functional/mempool_resurrect.py
@@ -4,15 +4,14 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test resurrection of mined transactions when the blockchain is re-organized."""
-from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
-from test_framework.util import *
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal
+
-# 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()
@@ -26,16 +25,16 @@ class MempoolCoinbaseTest(BitcoinTestFramework):
# Mine a new block
# ... make sure all the transactions are confirmed again.
- b = [ self.nodes[0].getblockhash(n) for n in range(1, 4) ]
- coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ]
- spends1_raw = [ create_raw_transaction(self.nodes[0], txid, node0_address, 49.99) for txid in coinbase_txids ]
- spends1_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends1_raw ]
+ b = [self.nodes[0].getblockhash(n) for n in range(1, 4)]
+ coinbase_txids = [self.nodes[0].getblock(h)['tx'][0] for h in b]
+ spends1_raw = [create_raw_transaction(self.nodes[0], txid, node0_address, amount=49.99) for txid in coinbase_txids]
+ spends1_id = [self.nodes[0].sendrawtransaction(tx) for tx in spends1_raw]
blocks = []
blocks.extend(self.nodes[0].generate(1))
- spends2_raw = [ create_raw_transaction(self.nodes[0], txid, node0_address, 49.98) for txid in spends1_id ]
- spends2_id = [ self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw ]
+ spends2_raw = [create_raw_transaction(self.nodes[0], txid, node0_address, amount=49.98) for txid in spends1_id]
+ spends2_id = [self.nodes[0].sendrawtransaction(tx) for tx in spends2_raw]
blocks.extend(self.nodes[0].generate(1))
diff --git a/test/functional/mempool_spend_coinbase.py b/test/functional/mempool_spend_coinbase.py
index 74a3634a6c..ce3bc3b7e0 100755
--- a/test/functional/mempool_spend_coinbase.py
+++ b/test/functional/mempool_spend_coinbase.py
@@ -14,13 +14,12 @@ but less mature coinbase spends are NOT.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.blocktools import create_raw_transaction
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error
+
-# 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()
@@ -30,9 +29,9 @@ class MempoolSpendCoinbaseTest(BitcoinTestFramework):
# Coinbase at height chain_height-100+1 ok in mempool, should
# get mined. Coinbase at height chain_height-100+2 is
# is too immature to spend.
- b = [ self.nodes[0].getblockhash(n) for n in range(101, 103) ]
- coinbase_txids = [ self.nodes[0].getblock(h)['tx'][0] for h in b ]
- spends_raw = [ create_raw_transaction(self.nodes[0], txid, node0_address, 49.99) for txid in coinbase_txids ]
+ b = [self.nodes[0].getblockhash(n) for n in range(101, 103)]
+ coinbase_txids = [self.nodes[0].getblock(h)['tx'][0] for h in b]
+ spends_raw = [create_raw_transaction(self.nodes[0], txid, node0_address, amount=49.99) for txid in coinbase_txids]
spend_101_id = self.nodes[0].sendrawtransaction(spends_raw[0])
diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py
index bd24b37f14..fa20a2d2f4 100755
--- a/test/functional/mining_basic.py
+++ b/test/functional/mining_basic.py
@@ -13,7 +13,7 @@ from binascii import b2a_hex
from decimal import Decimal
from test_framework.blocktools import create_coinbase
-from test_framework.mininode import CBlock
+from test_framework.messages import CBlock
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, assert_raises_rpc_error
diff --git a/test/functional/mining_getblocktemplate_longpoll.py b/test/functional/mining_getblocktemplate_longpoll.py
index 3ae5c12aaf..2bcbe8db7b 100755
--- a/test/functional/mining_getblocktemplate_longpoll.py
+++ b/test/functional/mining_getblocktemplate_longpoll.py
@@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test longpolling with getblocktemplate."""
+from decimal import Decimal
+
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import get_rpc_proxy, random_transaction
import threading
diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py
index 8e13e06b8b..bb0cc082ab 100755
--- a/test/functional/mining_prioritisetransaction.py
+++ b/test/functional/mining_prioritisetransaction.py
@@ -4,9 +4,11 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the prioritisetransaction mining RPC."""
+import time
+
+from test_framework.messages import COIN, MAX_BLOCK_BASE_SIZE
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import COIN, MAX_BLOCK_BASE_SIZE
+from test_framework.util import assert_equal, assert_raises_rpc_error, create_confirmed_utxos, create_lots_of_big_transactions, gen_return_txouts
class PrioritiseTransactionTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py
index 334e4048d2..5cec5dc6f0 100755
--- a/test/functional/p2p_compactblocks.py
+++ b/test/functional/p2p_compactblocks.py
@@ -8,12 +8,15 @@ Version 1 compact blocks are pre-segwit (txids)
Version 2 compact blocks are post-segwit (wtxids)
"""
-from test_framework.mininode import *
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from decimal import Decimal
+import random
+
from test_framework.blocktools import create_block, create_coinbase, add_witness_commitment
+from test_framework.messages import BlockTransactions, BlockTransactionsRequest, calculate_shortid, CBlock, CBlockHeader, CInv, COutPoint, CTransaction, CTxIn, CTxInWitness, CTxOut, FromHex, HeaderAndShortIDs, msg_block, msg_blocktxn, msg_cmpctblock, msg_getblocktxn, msg_getdata, msg_getheaders, msg_headers, msg_inv, msg_sendcmpct, msg_sendheaders, msg_tx, msg_witness_block, msg_witness_blocktxn, MSG_WITNESS_FLAG, NODE_NETWORK, NODE_WITNESS, P2PHeaderAndShortIDs, PrefilledTransaction, ser_uint256, ToHex
+from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.script import CScript, OP_TRUE, OP_DROP
-
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, get_bip9_status, satoshi_round, sync_blocks, wait_until
# TestP2PConn: A peer we use to send messages to bitcoind, and store responses.
class TestP2PConn(P2PInterface):
diff --git a/test/functional/p2p_feefilter.py b/test/functional/p2p_feefilter.py
index c348202245..3bc7734e75 100755
--- a/test/functional/p2p_feefilter.py
+++ b/test/functional/p2p_feefilter.py
@@ -4,11 +4,13 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test processing of feefilter messages."""
-from test_framework.mininode import *
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from decimal import Decimal
import time
+from test_framework.messages import msg_feefilter
+from test_framework.mininode import mininode_lock, P2PInterface
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import sync_blocks, sync_mempools
def hashToHex(hash):
return format(hash, '064x')
diff --git a/test/functional/p2p_fingerprint.py b/test/functional/p2p_fingerprint.py
index 7cb22ad940..4a6ffced93 100755
--- a/test/functional/p2p_fingerprint.py
+++ b/test/functional/p2p_fingerprint.py
@@ -11,18 +11,18 @@ the node should pretend that it does not have it to avoid fingerprinting.
import time
from test_framework.blocktools import (create_block, create_coinbase)
+from test_framework.messages import CInv
from test_framework.mininode import (
- CInv,
P2PInterface,
msg_headers,
msg_block,
msg_getdata,
msg_getheaders,
- wait_until,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
+ wait_until,
)
class P2PFingerprintTest(BitcoinTestFramework):
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/p2p_leak.py b/test/functional/p2p_leak.py
index 058d0025c2..dcbf833e7c 100755
--- a/test/functional/p2p_leak.py
+++ b/test/functional/p2p_leak.py
@@ -10,9 +10,12 @@ received a VERACK.
This test connects to a node and sends it a few messages, trying to entice it
into sending us something it shouldn't."""
-from test_framework.mininode import *
+import time
+
+from test_framework.messages import msg_getaddr, msg_ping, msg_verack
+from test_framework.mininode import mininode_lock, P2PInterface
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import wait_until
banscore = 10
diff --git a/test/functional/p2p_mempool.py b/test/functional/p2p_mempool.py
index bdf51778ef..a8fcb181e6 100755
--- a/test/functional/p2p_mempool.py
+++ b/test/functional/p2p_mempool.py
@@ -8,9 +8,10 @@ Test that nodes are disconnected if they send mempool messages when bloom
filters are not enabled.
"""
-from test_framework.mininode import *
+from test_framework.messages import msg_mempool
+from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal
class P2PMempoolTests(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/p2p_node_network_limited.py b/test/functional/p2p_node_network_limited.py
index 0e20b95565..c987bf4b05 100755
--- a/test/functional/p2p_node_network_limited.py
+++ b/test/functional/p2p_node_network_limited.py
@@ -8,10 +8,10 @@ Tests that a node configured with -prune=550 signals NODE_NETWORK_LIMITED correc
and that it responds to getdata requests for blocks correctly:
- send a block within 288 + 2 of the tip
- disconnect peers who request blocks older than that."""
-from test_framework.messages import CInv, msg_getdata, msg_verack
-from test_framework.mininode import NODE_BLOOM, NODE_NETWORK_LIMITED, NODE_WITNESS, P2PInterface, wait_until, mininode_lock
+from test_framework.messages import CInv, msg_getdata, msg_verack, NODE_BLOOM, NODE_NETWORK_LIMITED, NODE_WITNESS
+from test_framework.mininode import P2PInterface, mininode_lock
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import assert_equal, disconnect_nodes, connect_nodes_bi, sync_blocks
+from test_framework.util import assert_equal, disconnect_nodes, connect_nodes_bi, sync_blocks, wait_until
class P2PIgnoreInv(P2PInterface):
firstAddrnServices = 0
diff --git a/test/functional/p2p_sendheaders.py b/test/functional/p2p_sendheaders.py
index 7c987b171c..9cc496d510 100755
--- a/test/functional/p2p_sendheaders.py
+++ b/test/functional/p2p_sendheaders.py
@@ -86,9 +86,9 @@ e. Announce one more that doesn't connect.
Expect: disconnect.
"""
from test_framework.blocktools import create_block, create_coinbase
+from test_framework.messages import CInv
from test_framework.mininode import (
CBlockHeader,
- CInv,
NODE_WITNESS,
P2PInterface,
mininode_lock,
diff --git a/test/functional/p2p_timeouts.py b/test/functional/p2p_timeouts.py
index 788f80cc44..2459a9f243 100755
--- a/test/functional/p2p_timeouts.py
+++ b/test/functional/p2p_timeouts.py
@@ -23,9 +23,9 @@
from time import sleep
-from test_framework.mininode import *
+from test_framework.messages import msg_ping
+from test_framework.mininode import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
class TestP2PConn(P2PInterface):
def on_version(self, message):
diff --git a/test/functional/p2p_unrequested_blocks.py b/test/functional/p2p_unrequested_blocks.py
index 23175bf4a9..2e86954aba 100755
--- a/test/functional/p2p_unrequested_blocks.py
+++ b/test/functional/p2p_unrequested_blocks.py
@@ -51,11 +51,13 @@ Node1 is unused in tests 3-7:
work on its chain).
"""
-from test_framework.mininode import *
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
import time
+
from test_framework.blocktools import create_block, create_coinbase, create_tx_with_script
+from test_framework.messages import CBlockHeader, CInv, msg_block, msg_headers, msg_inv
+from test_framework.mininode import mininode_lock, P2PInterface
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, sync_blocks
class AcceptBlockTest(BitcoinTestFramework):
diff --git a/test/functional/rpc_bind.py b/test/functional/rpc_bind.py
index ef82b7e507..53916d5290 100755
--- a/test/functional/rpc_bind.py
+++ b/test/functional/rpc_bind.py
@@ -6,9 +6,9 @@
import sys
+from test_framework.netutil import all_interfaces, addr_to_hex, get_bind_addrs, test_ipv6_local
from test_framework.test_framework import BitcoinTestFramework, SkipTest
-from test_framework.util import *
-from test_framework.netutil import *
+from test_framework.util import assert_equal, assert_raises_rpc_error, get_rpc_proxy, rpc_port, rpc_url
class RPCBindTest(BitcoinTestFramework):
def set_test_params(self):
@@ -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_decodescript.py b/test/functional/rpc_decodescript.py
index b697fb7aac..940386eee7 100755
--- a/test/functional/rpc_decodescript.py
+++ b/test/functional/rpc_decodescript.py
@@ -4,9 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test decoding scripts via decodescript RPC command."""
+from test_framework.messages import CTransaction, sha256
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import *
+from test_framework.util import assert_equal, bytes_to_hex_str, hex_str_to_bytes
+
from io import BytesIO
class DecodeScriptTest(BitcoinTestFramework):
diff --git a/test/functional/rpc_getblockstats.py b/test/functional/rpc_getblockstats.py
index 37ef9f2b68..b24bed6adf 100755
--- a/test/functional/rpc_getblockstats.py
+++ b/test/functional/rpc_getblockstats.py
@@ -27,7 +27,7 @@ class GetblockstatsTest(BitcoinTestFramework):
'maxfee',
'maxfeerate',
'medianfee',
- 'medianfeerate',
+ 'feerate_percentiles',
'minfee',
'minfeerate',
'totalfee',
@@ -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_invalidateblock.py b/test/functional/rpc_invalidateblock.py
index 5967e534ca..f40710ef74 100755
--- a/test/functional/rpc_invalidateblock.py
+++ b/test/functional/rpc_invalidateblock.py
@@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the invalidateblock RPC."""
+import time
+
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, connect_nodes_bi, sync_blocks
class InvalidateTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index a68327496f..26eca031c0 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -6,7 +6,10 @@
"""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error, find_output
+
+import json
+import os
# Create one-input, one-output, no-fee transaction:
class PSBTTest(BitcoinTestFramework):
diff --git a/test/functional/rpc_rawtransaction.py b/test/functional/rpc_rawtransaction.py
index 3a29b57d0a..1e3ada26f8 100755
--- a/test/functional/rpc_rawtransaction.py
+++ b/test/functional/rpc_rawtransaction.py
@@ -13,10 +13,11 @@ Test the following RPCs:
"""
from collections import OrderedDict
+from decimal import Decimal
from io import BytesIO
from test_framework.messages import CTransaction, ToHex
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes
class multidict(dict):
"""Dictionary that allows duplicate keys.
diff --git a/test/functional/rpc_scantxoutset.py b/test/functional/rpc_scantxoutset.py
index 11c35b9f08..ceb38e969a 100755
--- a/test/functional/rpc_scantxoutset.py
+++ b/test/functional/rpc_scantxoutset.py
@@ -4,8 +4,9 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the scantxoutset rpc call."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal
+from decimal import Decimal
import shutil
import os
diff --git a/test/functional/rpc_signrawtransaction.py b/test/functional/rpc_signrawtransaction.py
index 81ad7a34e4..32b099294f 100755
--- a/test/functional/rpc_signrawtransaction.py
+++ b/test/functional/rpc_signrawtransaction.py
@@ -5,7 +5,7 @@
"""Test transaction signing using the signrawtransaction* RPCs."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error
class SignRawTransactionsTest(BitcoinTestFramework):
diff --git a/test/functional/rpc_txoutproof.py b/test/functional/rpc_txoutproof.py
index a602e98f71..f9f8574646 100755
--- a/test/functional/rpc_txoutproof.py
+++ b/test/functional/rpc_txoutproof.py
@@ -4,10 +4,9 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test gettxoutproof and verifytxoutproof RPCs."""
+from test_framework.messages import CMerkleBlock, FromHex, ToHex
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
-from test_framework.mininode import FromHex, ToHex
-from test_framework.messages import CMerkleBlock
+from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes
class MerkleBlockTest(BitcoinTestFramework):
def set_test_params(self):
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/blocktools.py b/test/functional/test_framework/blocktools.py
index 56f70d9833..987ade4044 100644
--- a/test/functional/test_framework/blocktools.py
+++ b/test/functional/test_framework/blocktools.py
@@ -118,7 +118,7 @@ def create_coinbase(height, pubkey=None):
coinbase.calc_sha256()
return coinbase
-def create_tx_with_script(prevtx, n, script_sig=b"", amount=1, script_pub_key=CScript()):
+def create_tx_with_script(prevtx, n, script_sig=b"", *, amount, script_pub_key=CScript()):
"""Return one-input, one-output transaction object
spending the prevtx's n-th output with the given amount.
@@ -131,26 +131,24 @@ def create_tx_with_script(prevtx, n, script_sig=b"", amount=1, script_pub_key=CS
tx.calc_sha256()
return tx
-def create_transaction(node, txid, to_address, amount):
+def create_transaction(node, txid, to_address, *, amount):
""" Return signed transaction spending the first output of the
input txid. Note that the node must be able to sign for the
output that is being spent, and the node must not be running
multiple wallets.
"""
- raw_tx = create_raw_transaction(node, txid, to_address, amount)
+ raw_tx = create_raw_transaction(node, txid, to_address, amount=amount)
tx = CTransaction()
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx)))
return tx
-def create_raw_transaction(node, txid, to_address, amount):
+def create_raw_transaction(node, txid, to_address, *, amount):
""" Return raw signed transaction spending the first output of the
input txid. Note that the node must be able to sign for the
output that is being spent, and the node must not be running
multiple wallets.
"""
- inputs = [{"txid": txid, "vout": 0}]
- outputs = {to_address: amount}
- rawtx = node.createrawtransaction(inputs, outputs)
+ rawtx = node.createrawtransaction(inputs=[{"txid": txid, "vout": 0}], outputs={to_address: amount})
signresult = node.signrawtransactionwithwallet(rawtx)
assert_equal(signresult["complete"], True)
return signresult['hex']
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..d1ddbbe8ee 100755
--- a/test/functional/test_framework/mininode.py
+++ b/test/functional/test_framework/mininode.py
@@ -21,7 +21,7 @@ import struct
import sys
import threading
-from test_framework.messages import *
+from test_framework.messages import CBlockHeader, MIN_VERSION_SUPPORTED, msg_addr, msg_block, MSG_BLOCK, msg_blocktxn, msg_cmpctblock, msg_feefilter, msg_getaddr, msg_getblocks, msg_getblocktxn, msg_getdata, msg_getheaders, msg_headers, msg_inv, msg_mempool, msg_ping, msg_pong, msg_reject, msg_sendcmpct, msg_sendheaders, msg_tx, MSG_TX, MSG_TYPE_MASK, msg_verack, msg_version, NODE_NETWORK, NODE_WITNESS, sha256
from test_framework.util import wait_until
logger = logging.getLogger("TestFramework.mininode")
@@ -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/script.py b/test/functional/test_framework/script.py
index d1f605a2e0..375d6334f7 100644
--- a/test/functional/test_framework/script.py
+++ b/test/functional/test_framework/script.py
@@ -7,7 +7,8 @@
This file is modified from python-bitcoinlib.
"""
-from .mininode import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string
+from .messages import CTransaction, CTxOut, sha256, hash256, uint256_from_str, ser_uint256, ser_string
+
from binascii import hexlify
import hashlib
import struct
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_abandonconflict.py b/test/functional/wallet_abandonconflict.py
index 7740b2136a..8a57b55ca9 100755
--- a/test/functional/wallet_abandonconflict.py
+++ b/test/functional/wallet_abandonconflict.py
@@ -10,9 +10,10 @@
which are not included in a block and are not currently in the mempool. It has
no effect on transactions which are already abandoned.
"""
-from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from decimal import Decimal
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, disconnect_nodes, sync_blocks, sync_mempools
class AbandonConflictTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py
index 181af9a8d3..4ef8f4776b 100755
--- a/test/functional/wallet_backup.py
+++ b/test/functional/wallet_backup.py
@@ -30,11 +30,13 @@ confirm 1/2/3/4 balances are same as before.
Shutdown again, restore using importwallet,
and confirm again balances are correct.
"""
+from decimal import Decimal
+import os
from random import randint
import shutil
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error, connect_nodes, sync_blocks, sync_mempools
class WalletBackupTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py
index 356393cfa4..dd95bb5e22 100755
--- a/test/functional/wallet_bumpfee.py
+++ b/test/functional/wallet_bumpfee.py
@@ -14,12 +14,12 @@ added in the future, they should try to follow the same convention and not
make assumptions about execution order.
"""
-from test_framework.blocktools import send_to_witness
+from decimal import Decimal
+
+from test_framework.blocktools import add_witness_commitment, create_block, create_coinbase, send_to_witness
+from test_framework.messages import BIP125_SEQUENCE_NUMBER, CTransaction
from test_framework.test_framework import BitcoinTestFramework
-from test_framework import blocktools
-from test_framework.messages import BIP125_SEQUENCE_NUMBER
-from test_framework.mininode import CTransaction
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error, bytes_to_hex_str, connect_nodes_bi, hex_str_to_bytes, sync_mempools
import io
@@ -290,11 +290,11 @@ def submit_block_with_tx(node, tx):
tip = node.getbestblockhash()
height = node.getblockcount() + 1
block_time = node.getblockheader(tip)["mediantime"] + 1
- block = blocktools.create_block(int(tip, 16), blocktools.create_coinbase(height), block_time)
+ block = create_block(int(tip, 16), create_coinbase(height), block_time)
block.vtx.append(ctx)
block.rehash()
block.hashMerkleRoot = block.calc_merkle_root()
- blocktools.add_witness_commitment(block)
+ add_witness_commitment(block)
block.solve()
node.submitblock(bytes_to_hex_str(block.serialize(True)))
return block
diff --git a/test/functional/wallet_disable.py b/test/functional/wallet_disable.py
index 4fec85c1c7..6530c58c78 100755
--- a/test/functional/wallet_disable.py
+++ b/test/functional/wallet_disable.py
@@ -9,7 +9,7 @@
"""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_raises_rpc_error
class DisableWalletTest (BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/wallet_fallbackfee.py b/test/functional/wallet_fallbackfee.py
index f0a643bb4f..91dbae8939 100755
--- a/test/functional/wallet_fallbackfee.py
+++ b/test/functional/wallet_fallbackfee.py
@@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test wallet replace-by-fee capabilities in conjunction with the fallbackfee."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_raises_rpc_error
class WalletRBFTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/wallet_groups.py b/test/functional/wallet_groups.py
index 9fa7eaf07e..12dac145bd 100755
--- a/test/functional/wallet_groups.py
+++ b/test/functional/wallet_groups.py
@@ -5,8 +5,7 @@
"""Test wallet group functionality."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.mininode import FromHex, ToHex
-from test_framework.messages import CTransaction
+from test_framework.messages import CTransaction, FromHex, ToHex
from test_framework.util import (
assert_equal,
)
diff --git a/test/functional/wallet_importmulti.py b/test/functional/wallet_importmulti.py
index 4664e868f9..5f19e1e2c6 100755
--- a/test/functional/wallet_importmulti.py
+++ b/test/functional/wallet_importmulti.py
@@ -4,7 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the importmulti RPC."""
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_greater_than, assert_raises_rpc_error
class ImportMultiTest (BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py
index b00649162e..f52dce04dd 100755
--- a/test/functional/wallet_keypool.py
+++ b/test/functional/wallet_keypool.py
@@ -4,8 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test the wallet keypool and interaction with wallet encryption/locking."""
+import time
+
from test_framework.test_framework import BitcoinTestFramework
-from test_framework.util import *
+from test_framework.util import assert_equal, assert_raises_rpc_error
class KeyPoolTest(BitcoinTestFramework):
def set_test_params(self):
diff --git a/test/functional/wallet_listtransactions.py b/test/functional/wallet_listtransactions.py
index f77fcdc89f..4dc3ff4b26 100755
--- a/test/functional/wallet_listtransactions.py
+++ b/test/functional/wallet_listtransactions.py
@@ -6,7 +6,7 @@
from decimal import Decimal
from io import BytesIO
-from test_framework.mininode import CTransaction, COIN
+from test_framework.messages import COIN, CTransaction
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_array_result,
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/lint/lint-format-strings.py b/test/lint/lint-format-strings.py
index c07dfe317b..60389176c9 100755
--- a/test/lint/lint-format-strings.py
+++ b/test/lint/lint-format-strings.py
@@ -123,6 +123,32 @@ def parse_function_call_and_arguments(function_name, function_call):
['foo(', '123', ')']
>>> parse_function_call_and_arguments("foo", 'foo("foo")')
['foo(', '"foo"', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().to_bytes(buf), err);')
+ ['strprintf(', '"%s (%d)",', ' std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>,wchar_t>().to_bytes(buf),', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo<wchar_t>().to_bytes(buf), err);')
+ ['strprintf(', '"%s (%d)",', ' foo<wchar_t>().to_bytes(buf),', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo().to_bytes(buf), err);')
+ ['strprintf(', '"%s (%d)",', ' foo().to_bytes(buf),', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo << 1, err);')
+ ['strprintf(', '"%s (%d)",', ' foo << 1,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo<bar>() >> 1, err);')
+ ['strprintf(', '"%s (%d)",', ' foo<bar>() >> 1,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo < 1 ? bar : foobar, err);')
+ ['strprintf(', '"%s (%d)",', ' foo < 1 ? bar : foobar,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo < 1, err);')
+ ['strprintf(', '"%s (%d)",', ' foo < 1,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo > 1 ? bar : foobar, err);')
+ ['strprintf(', '"%s (%d)",', ' foo > 1 ? bar : foobar,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo > 1, err);')
+ ['strprintf(', '"%s (%d)",', ' foo > 1,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo <= 1, err);')
+ ['strprintf(', '"%s (%d)",', ' foo <= 1,', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo <= bar<1, 2>(1, 2), err);')
+ ['strprintf(', '"%s (%d)",', ' foo <= bar<1, 2>(1, 2),', ' err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo>foo<1,2>(1,2)?bar:foobar,err)');
+ ['strprintf(', '"%s (%d)",', ' foo>foo<1,2>(1,2)?bar:foobar,', 'err', ')']
+ >>> parse_function_call_and_arguments("strprintf", 'strprintf("%s (%d)", foo>foo<1,2>(1,2),err)');
+ ['strprintf(', '"%s (%d)",', ' foo>foo<1,2>(1,2),', 'err', ')']
"""
assert(type(function_name) is str and type(function_call) is str and function_name)
remaining = normalize(escape(function_call))
@@ -131,9 +157,10 @@ def parse_function_call_and_arguments(function_name, function_call):
parts = [expected_function_call]
remaining = remaining[len(expected_function_call):]
open_parentheses = 1
+ open_template_arguments = 0
in_string = False
parts.append("")
- for char in remaining:
+ for i, char in enumerate(remaining):
parts.append(parts.pop() + char)
if char == "\"":
in_string = not in_string
@@ -151,6 +178,15 @@ def parse_function_call_and_arguments(function_name, function_call):
parts.append(parts.pop()[:-1])
parts.append(char)
break
+ prev_char = remaining[i - 1] if i - 1 >= 0 else None
+ next_char = remaining[i + 1] if i + 1 <= len(remaining) - 1 else None
+ if char == "<" and next_char not in [" ", "<", "="] and prev_char not in [" ", "<"]:
+ open_template_arguments += 1
+ continue
+ if char == ">" and next_char not in [" ", ">", "="] and prev_char not in [" ", ">"] and open_template_arguments > 0:
+ open_template_arguments -= 1
+ if open_template_arguments > 0:
+ continue
if char == ",":
parts.append("")
return parts
diff --git a/test/lint/lint-python.sh b/test/lint/lint-python.sh
index d9d46d86d5..7e73790517 100755
--- a/test/lint/lint-python.sh
+++ b/test/lint/lint-python.sh
@@ -30,6 +30,8 @@ export LC_ALL=C
# E306 expected 1 blank line before a nested definition
# E401 multiple imports on one line
# E402 module level import not at top of file
+# F403 'from foo_module import *' used; unable to detect undefined names
+# F405 foo_function may be undefined, or defined from star imports: bar_module
# E502 the backslash is redundant between brackets
# E701 multiple statements on one line (colon)
# E702 multiple statements on one line (semicolon)
@@ -77,4 +79,4 @@ export LC_ALL=C
# W605 invalid escape sequence "x"
# W606 'async' and 'await' are reserved keywords starting with Python 3.7
-flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
+flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E741,E742,E743,E901,E902,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 .
diff --git a/test/util/bitcoin-util-test.py b/test/util/bitcoin-util-test.py
index 16371a6234..92fef30e13 100755
--- a/test/util/bitcoin-util-test.py
+++ b/test/util/bitcoin-util-test.py
@@ -28,7 +28,7 @@ import sys
def main():
config = configparser.ConfigParser()
config.optionxform = str
- config.readfp(open(os.path.join(os.path.dirname(__file__), "../config.ini"), encoding="utf8"))
+ config.read_file(open(os.path.join(os.path.dirname(__file__), "../config.ini"), encoding="utf8"))
env_conf = dict(config.items('environment'))
parser = argparse.ArgumentParser(description=__doc__)
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"
}