aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-03-26 08:52:51 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-03-26 08:52:59 +0100
commit9b48b3ac42294410cb56e7da24a261fa69ddb503 (patch)
treebfcaeefa6ad12913f9d9e4c127c25b56ee97d5d0 /test
parent9217f9fe7351d9c36803456f88ae561e23f17ac9 (diff)
parent4f2653a89018fa4d24bd2a551832a7410b682600 (diff)
downloadbitcoin-9b48b3ac42294410cb56e7da24a261fa69ddb503.tar.xz
Merge #21390: test: Test improvements for UTXO set hash tests
4f2653a89018fa4d24bd2a551832a7410b682600 test: Use deterministic chain in utxo set hash test (Fabian Jahr) 4973c5175c5fd1f4791ea26e8ddefd6fb11ac1c3 test: Remove wallet dependency of utxo set hash test (Fabian Jahr) 1a27af1d7b5ec18b4248ead1eaf0f381047b4b24 rpc: Improve gettxoutsetinfo help (Fabian Jahr) Pull request description: Follow-ups to #19145: - Small improvement on the help text of RPC gettxoutsetinfo - Using deterministic blockchain in the test `functional/feature_utxo_set_hash.py` - Removing wallet dependency in the test `functional/feature_utxo_set_hash.py` Split out of #19521. ACKs for top commit: MarcoFalke: review ACK 4f2653a89018fa4d24bd2a551832a7410b682600 👲 Tree-SHA512: 92927b3aa22b6324eb4fc9d346755313dec44d973aa69a0ebf80a8569b5f3a7cf3539721ebdba183737534b9e29b3e33f412515890f0d0b819878032a3bba8f9
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/feature_utxo_set_hash.py30
-rw-r--r--test/functional/test_framework/wallet.py3
2 files changed, 15 insertions, 18 deletions
diff --git a/test/functional/feature_utxo_set_hash.py b/test/functional/feature_utxo_set_hash.py
index 6e6046d84d..ce00faffee 100755
--- a/test/functional/feature_utxo_set_hash.py
+++ b/test/functional/feature_utxo_set_hash.py
@@ -6,7 +6,6 @@
import struct
-from test_framework.blocktools import create_transaction
from test_framework.messages import (
CBlock,
COutPoint,
@@ -15,38 +14,30 @@ from test_framework.messages import (
from test_framework.muhash import MuHash3072
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
+from test_framework.wallet import MiniWallet
class UTXOSetHashTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
- def skip_test_if_missing_module(self):
- self.skip_if_no_wallet()
-
- def test_deterministic_hash_results(self):
- self.log.info("Test deterministic UTXO set hash results")
-
- # These depend on the setup_clean_chain option, the chain loaded from the cache
- assert_equal(self.nodes[0].gettxoutsetinfo()['hash_serialized_2'], "b32ec1dda5a53cd025b95387aad344a801825fe46a60ff952ce26528f01d3be8")
- assert_equal(self.nodes[0].gettxoutsetinfo("muhash")['muhash'], "dd5ad2a105c2d29495f577245c357409002329b9f4d6182c0af3dc2f462555c8")
-
def test_muhash_implementation(self):
self.log.info("Test MuHash implementation consistency")
node = self.nodes[0]
+ wallet = MiniWallet(node)
+ mocktime = node.getblockheader(node.getblockhash(0))['time'] + 1
+ node.setmocktime(mocktime)
# Generate 100 blocks and remove the first since we plan to spend its
# coinbase
- block_hashes = node.generate(100)
+ block_hashes = wallet.generate(1) + node.generate(99)
blocks = list(map(lambda block: FromHex(CBlock(), node.getblock(block, False)), block_hashes))
- spending = blocks.pop(0)
+ blocks.pop(0)
# Create a spending transaction and mine a block which includes it
- tx = create_transaction(node, spending.vtx[0].rehash(), node.getnewaddress(), amount=49)
- txid = node.sendrawtransaction(hexstring=tx.serialize_with_witness().hex(), maxfeerate=0)
-
- tx_block = node.generateblock(output=node.getnewaddress(), transactions=[txid])
+ txid = wallet.send_self_transfer(from_node=node)['txid']
+ tx_block = node.generateblock(output=wallet.get_address(), transactions=[txid])
blocks.append(FromHex(CBlock(), node.getblock(tx_block['hash'], False)))
# Serialize the outputs that should be in the UTXO set and add them to
@@ -77,8 +68,11 @@ class UTXOSetHashTest(BitcoinTestFramework):
assert_equal(finalized[::-1].hex(), node_muhash)
+ self.log.info("Test deterministic UTXO set hash results")
+ assert_equal(node.gettxoutsetinfo()['hash_serialized_2'], "5b1b44097406226c0eb8e1362cd17a1f346522cf9390a8175a57a5262cb1963f")
+ assert_equal(node.gettxoutsetinfo("muhash")['muhash'], "4b8803075d7151d06fad3e88b68ba726886794873fbfa841d12aefb2cc2b881b")
+
def run_test(self):
- self.test_deterministic_hash_results()
self.test_muhash_implementation()
diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py
index 38fbf3c1a6..a906a21dd0 100644
--- a/test/functional/test_framework/wallet.py
+++ b/test/functional/test_framework/wallet.py
@@ -49,6 +49,9 @@ class MiniWallet:
self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
return blocks
+ def get_address(self):
+ return self._address
+
def get_utxo(self, *, txid=''):
"""
Returns a utxo and marks it as spent (pops it from the internal list)