aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/feature_assumevalid.py1
-rwxr-xr-xtest/functional/feature_bip68_sequence.py2
-rwxr-xr-xtest/functional/feature_block.py1
-rwxr-xr-xtest/functional/feature_csv_activation.py1
-rwxr-xr-xtest/functional/feature_dersig.py4
-rwxr-xr-xtest/functional/feature_nulldummy.py1
-rwxr-xr-xtest/functional/feature_taproot.py2
-rwxr-xr-xtest/functional/feature_txindex_compatibility.py92
-rwxr-xr-xtest/functional/p2p_invalid_block.py4
-rwxr-xr-xtest/functional/p2p_segwit.py2
-rwxr-xr-xtest/functional/test_runner.py3
-rwxr-xr-xtest/functional/wallet_bumpfee.py1
-rwxr-xr-xtest/functional/wallet_multisig_descriptor_psbt.py2
-rwxr-xr-xtest/functional/wallet_resendwallettransactions.py1
14 files changed, 95 insertions, 22 deletions
diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py
index a4480307a7..66092de317 100755
--- a/test/functional/feature_assumevalid.py
+++ b/test/functional/feature_assumevalid.py
@@ -126,7 +126,6 @@ class AssumeValidTest(BitcoinTestFramework):
self.block_time += 1
block102.vtx.extend([tx])
block102.hashMerkleRoot = block102.calc_merkle_root()
- block102.rehash()
block102.solve()
self.blocks.append(block102)
self.tip = block102.sha256
diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py
index d962b622fe..0c29a782b1 100755
--- a/test/functional/feature_bip68_sequence.py
+++ b/test/functional/feature_bip68_sequence.py
@@ -335,7 +335,6 @@ class BIP68Test(BitcoinTestFramework):
# tx3 to be removed.
for i in range(2):
block = create_block(tmpl=tmpl, ntime=cur_time)
- block.rehash()
block.solve()
tip = block.sha256
assert_equal(None if i == 1 else 'inconclusive', self.nodes[0].submitblock(block.serialize().hex()))
@@ -392,7 +391,6 @@ class BIP68Test(BitcoinTestFramework):
block = create_block(tmpl=self.nodes[0].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS))
block.vtx.extend([tx1, tx2, tx3])
block.hashMerkleRoot = block.calc_merkle_root()
- block.rehash()
add_witness_commitment(block)
block.solve()
diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py
index b06ea8542b..7831984b81 100755
--- a/test/functional/feature_block.py
+++ b/test/functional/feature_block.py
@@ -612,7 +612,6 @@ class FullBlockTest(BitcoinTestFramework):
b45.nBits = 0x207fffff
b45.vtx.append(non_coinbase)
b45.hashMerkleRoot = b45.calc_merkle_root()
- b45.calc_sha256()
b45.solve()
self.block_heights[b45.sha256] = self.block_heights[self.tip.sha256] + 1
self.tip = b45
diff --git a/test/functional/feature_csv_activation.py b/test/functional/feature_csv_activation.py
index 5255b13bd1..c4e2252487 100755
--- a/test/functional/feature_csv_activation.py
+++ b/test/functional/feature_csv_activation.py
@@ -177,7 +177,6 @@ class BIP68_112_113Test(BitcoinTestFramework):
block.nVersion = 4
block.vtx.extend(txs)
block.hashMerkleRoot = block.calc_merkle_root()
- block.rehash()
block.solve()
return block
diff --git a/test/functional/feature_dersig.py b/test/functional/feature_dersig.py
index 28aff1f2f9..eba3809d24 100755
--- a/test/functional/feature_dersig.py
+++ b/test/functional/feature_dersig.py
@@ -88,7 +88,6 @@ class BIP66Test(BitcoinTestFramework):
block = create_block(int(tip, 16), create_coinbase(DERSIG_HEIGHT - 1), block_time)
block.vtx.append(spendtx)
block.hashMerkleRoot = block.calc_merkle_root()
- block.rehash()
block.solve()
assert_equal(self.nodes[0].getblockcount(), DERSIG_HEIGHT - 2)
@@ -103,7 +102,6 @@ class BIP66Test(BitcoinTestFramework):
block_time += 1
block = create_block(tip, create_coinbase(DERSIG_HEIGHT), block_time)
block.nVersion = 2
- block.rehash()
block.solve()
with self.nodes[0].assert_debug_log(expected_msgs=[f'{block.hash}, bad-version(0x00000002)']):
@@ -133,7 +131,6 @@ class BIP66Test(BitcoinTestFramework):
# Now we verify that a block with this transaction is also invalid.
block.vtx.append(spendtx)
block.hashMerkleRoot = block.calc_merkle_root()
- block.rehash()
block.solve()
with self.nodes[0].assert_debug_log(expected_msgs=[f'CheckInputScripts on {block.vtx[-1].hash} failed with non-mandatory-script-verify-flag (Non-canonical DER signature)']):
@@ -144,7 +141,6 @@ class BIP66Test(BitcoinTestFramework):
self.log.info("Test that a block with a DERSIG-compliant transaction is accepted")
block.vtx[1] = self.create_tx(self.coinbase_txids[1])
block.hashMerkleRoot = block.calc_merkle_root()
- block.rehash()
block.solve()
self.test_dersig_info(is_active=True) # Not active as of current tip, but next block must obey rules
diff --git a/test/functional/feature_nulldummy.py b/test/functional/feature_nulldummy.py
index 217a38050d..04c4e7e50c 100755
--- a/test/functional/feature_nulldummy.py
+++ b/test/functional/feature_nulldummy.py
@@ -130,7 +130,6 @@ class NULLDUMMYTest(BitcoinTestFramework):
block.hashMerkleRoot = block.calc_merkle_root()
if with_witness:
add_witness_commitment(block)
- block.rehash()
block.solve()
assert_equal(None if accept else NULLDUMMY_ERROR, node.submitblock(block.serialize().hex()))
if accept:
diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py
index 50a25ee1ef..5f90e49de1 100755
--- a/test/functional/feature_taproot.py
+++ b/test/functional/feature_taproot.py
@@ -1240,7 +1240,6 @@ class TaprootTest(BitcoinTestFramework):
block.vtx.append(tx)
block.hashMerkleRoot = block.calc_merkle_root()
witness and add_witness_commitment(block)
- block.rehash()
block.solve()
block_response = node.submitblock(block.serialize().hex())
if err_msg is not None:
@@ -1488,7 +1487,6 @@ class TaprootTest(BitcoinTestFramework):
# Mine a block with the transaction
block = create_block(tmpl=self.nodes[1].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS), txlist=[rawtx])
add_witness_commitment(block)
- block.rehash()
block.solve()
assert_equal(None, self.nodes[1].submitblock(block.serialize().hex()))
self.sync_blocks()
diff --git a/test/functional/feature_txindex_compatibility.py b/test/functional/feature_txindex_compatibility.py
new file mode 100755
index 0000000000..bbe1d1b537
--- /dev/null
+++ b/test/functional/feature_txindex_compatibility.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python3
+# Copyright (c) 2021 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 that legacy txindex will be disabled on upgrade.
+
+Previous releases are required by this test, see test/README.md.
+"""
+
+import os
+import shutil
+
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.wallet import MiniWallet
+
+
+class MempoolCompatibilityTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 3
+ self.extra_args = [
+ ["-reindex", "-txindex"],
+ [],
+ [],
+ ]
+
+ def skip_test_if_missing_module(self):
+ self.skip_if_no_previous_releases()
+
+ def setup_network(self):
+ self.add_nodes(
+ self.num_nodes,
+ self.extra_args,
+ versions=[
+ 160300, # Last release with legacy txindex
+ None, # For MiniWallet, without migration code
+ 200100, # Any release with migration code (0.17.x - 22.x)
+ ],
+ )
+ self.start_nodes()
+ self.connect_nodes(0, 1)
+ self.connect_nodes(1, 2)
+
+ def run_test(self):
+ mini_wallet = MiniWallet(self.nodes[1])
+ mini_wallet.rescan_utxos()
+ spend_utxo = mini_wallet.get_utxo()
+ mini_wallet.send_self_transfer(from_node=self.nodes[1], utxo_to_spend=spend_utxo)
+ self.generate(self.nodes[1], 1)
+
+ self.log.info("Check legacy txindex")
+ self.nodes[0].getrawtransaction(txid=spend_utxo["txid"]) # Requires -txindex
+
+ self.stop_nodes()
+ legacy_chain_dir = os.path.join(self.nodes[0].datadir, self.chain)
+
+ self.log.info("Migrate legacy txindex")
+ migrate_chain_dir = os.path.join(self.nodes[2].datadir, self.chain)
+ shutil.rmtree(migrate_chain_dir)
+ shutil.copytree(legacy_chain_dir, migrate_chain_dir)
+ with self.nodes[2].assert_debug_log([
+ "Upgrading txindex database...",
+ "txindex is enabled at height 200",
+ ]):
+ self.start_node(2, extra_args=["-txindex"])
+ self.nodes[2].getrawtransaction(txid=spend_utxo["txid"]) # Requires -txindex
+
+ self.log.info("Drop legacy txindex")
+ drop_index_chain_dir = os.path.join(self.nodes[1].datadir, self.chain)
+ shutil.rmtree(drop_index_chain_dir)
+ shutil.copytree(legacy_chain_dir, drop_index_chain_dir)
+ self.nodes[1].assert_start_raises_init_error(
+ extra_args=["-txindex"],
+ expected_msg="Error: The block index db contains a legacy 'txindex'. To clear the occupied disk space, run a full -reindex, otherwise ignore this error. This error message will not be displayed again.",
+ )
+ # Build txindex from scratch and check there is no error this time
+ self.start_node(1, extra_args=["-txindex"])
+ self.nodes[2].getrawtransaction(txid=spend_utxo["txid"]) # Requires -txindex
+
+ self.stop_nodes()
+
+ self.log.info("Check migrated txindex can not be read by legacy node")
+ err_msg = f": You need to rebuild the database using -reindex to change -txindex.{os.linesep}Please restart with -reindex or -reindex-chainstate to recover."
+ shutil.rmtree(legacy_chain_dir)
+ shutil.copytree(migrate_chain_dir, legacy_chain_dir)
+ self.nodes[0].assert_start_raises_init_error(extra_args=["-txindex"], expected_msg=err_msg)
+ shutil.rmtree(legacy_chain_dir)
+ shutil.copytree(drop_index_chain_dir, legacy_chain_dir)
+ self.nodes[0].assert_start_raises_init_error(extra_args=["-txindex"], expected_msg=err_msg)
+
+
+if __name__ == "__main__":
+ MempoolCompatibilityTest().main()
diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py
index 875ab52db4..6eb8b8767d 100755
--- a/test/functional/p2p_invalid_block.py
+++ b/test/functional/p2p_invalid_block.py
@@ -75,7 +75,6 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
block2.vtx.extend([tx1, tx2])
block2.hashMerkleRoot = block2.calc_merkle_root()
- block2.rehash()
block2.solve()
orig_hash = block2.sha256
block2_orig = copy.deepcopy(block2)
@@ -95,7 +94,6 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
block2_dup.vtx[2].vin.append(block2_dup.vtx[2].vin[0])
block2_dup.vtx[2].rehash()
block2_dup.hashMerkleRoot = block2_dup.calc_merkle_root()
- block2_dup.rehash()
block2_dup.solve()
peer.send_blocks_and_test([block2_dup], node, success=False, reject_reason='bad-txns-inputs-duplicate')
@@ -107,7 +105,6 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
block3.vtx[0].sha256 = None
block3.vtx[0].calc_sha256()
block3.hashMerkleRoot = block3.calc_merkle_root()
- block3.rehash()
block3.solve()
peer.send_blocks_and_test([block3], node, success=False, reject_reason='bad-cb-amount')
@@ -134,7 +131,6 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
tx3.rehash()
block4.vtx.append(tx3)
block4.hashMerkleRoot = block4.calc_merkle_root()
- block4.rehash()
block4.solve()
self.log.info("Test inflation by duplicating input")
peer.send_blocks_and_test([block4], node, success=False, reject_reason='bad-txns-inputs-duplicate')
diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py
index 968fd6fe98..99bf34912f 100755
--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -790,7 +790,6 @@ class SegWitTest(BitcoinTestFramework):
block_3.vtx[0].vout.append(CTxOut(0, CScript([OP_RETURN, WITNESS_COMMITMENT_HEADER + ser_uint256(2), 10])))
block_3.vtx[0].rehash()
block_3.hashMerkleRoot = block_3.calc_merkle_root()
- block_3.rehash()
block_3.solve()
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=False, reason='bad-witness-merkle-match')
@@ -804,7 +803,6 @@ class SegWitTest(BitcoinTestFramework):
block_3.vtx[0].vout[-1].nValue += 1
block_3.vtx[0].rehash()
block_3.hashMerkleRoot = block_3.calc_merkle_root()
- block_3.rehash()
assert len(block_3.vtx[0].vout) == 4 # 3 OP_returns
block_3.solve()
test_witness_block(self.nodes[0], self.test_node, block_3, accepted=True)
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index 916cd94b79..37fc549922 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -296,6 +296,7 @@ BASE_SCRIPTS = [
'rpc_deriveaddresses.py --usecli',
'p2p_ping.py',
'rpc_scantxoutset.py',
+ 'feature_txindex_compatibility.py',
'feature_logging.py',
'feature_anchors.py',
'feature_coinstatsindex.py',
@@ -347,7 +348,7 @@ def main():
parser.add_argument('--keepcache', '-k', action='store_true', help='the default behavior is to flush the cache directory on startup. --keepcache retains the cache from the previous testrun.')
parser.add_argument('--quiet', '-q', action='store_true', help='only print dots, results summary and failure logs')
parser.add_argument('--tmpdirprefix', '-t', default=tempfile.gettempdir(), help="Root directory for datadirs")
- parser.add_argument('--failfast', action='store_true', help='stop execution after the first test failure')
+ parser.add_argument('--failfast', '-F', action='store_true', help='stop execution after the first test failure')
parser.add_argument('--filter', help='filter scripts to run by regular expression')
args, unknown_args = parser.parse_known_args()
diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py
index 34ee06b2fe..063211d5c3 100755
--- a/test/functional/wallet_bumpfee.py
+++ b/test/functional/wallet_bumpfee.py
@@ -598,7 +598,6 @@ def submit_block_with_tx(node, tx):
block_time = node.getblockheader(tip)["mediantime"] + 1
block = create_block(int(tip, 16), create_coinbase(height), block_time)
block.vtx.append(ctx)
- block.rehash()
block.hashMerkleRoot = block.calc_merkle_root()
add_witness_commitment(block)
block.solve()
diff --git a/test/functional/wallet_multisig_descriptor_psbt.py b/test/functional/wallet_multisig_descriptor_psbt.py
index ed855d2525..64799fccda 100755
--- a/test/functional/wallet_multisig_descriptor_psbt.py
+++ b/test/functional/wallet_multisig_descriptor_psbt.py
@@ -85,7 +85,7 @@ class WalletMultisigDescriptorPSBTTest(BitcoinTestFramework):
# This wallet will be the participant's `signer` for the resulting multisig. Avoid reusing this wallet for any other purpose (for privacy reasons).
"signers": [node.get_wallet_rpc(node.createwallet(wallet_name=f"participant_{self.nodes.index(node)}", descriptors=True)["name"]) for node in self.nodes],
# After participants generate and exchange their xpubs they will each create their own watch-only multisig.
- # Note: these multisigs are all the same, this justs highlights that each participant can independently verify everything on their own node.
+ # Note: these multisigs are all the same, this just highlights that each participant can independently verify everything on their own node.
"multisigs": []
}
diff --git a/test/functional/wallet_resendwallettransactions.py b/test/functional/wallet_resendwallettransactions.py
index 37dee219e7..1e0c4f2883 100755
--- a/test/functional/wallet_resendwallettransactions.py
+++ b/test/functional/wallet_resendwallettransactions.py
@@ -48,7 +48,6 @@ class ResendWalletTransactionsTest(BitcoinTestFramework):
block_time = int(time.time()) + 6 * 60
node.setmocktime(block_time)
block = create_block(int(node.getbestblockhash(), 16), create_coinbase(node.getblockcount() + 1), block_time)
- block.rehash()
block.solve()
node.submitblock(block.serialize().hex())