Skip to content

Commit 4973c51

Browse files
committed
test: Remove wallet dependency of utxo set hash test
1 parent 1a27af1 commit 4973c51

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

test/functional/feature_utxo_set_hash.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import struct
88

9-
from test_framework.blocktools import create_transaction
109
from test_framework.messages import (
1110
CBlock,
1211
COutPoint,
@@ -15,15 +14,13 @@
1514
from test_framework.muhash import MuHash3072
1615
from test_framework.test_framework import BitcoinTestFramework
1716
from test_framework.util import assert_equal
17+
from test_framework.wallet import MiniWallet
1818

1919
class UTXOSetHashTest(BitcoinTestFramework):
2020
def set_test_params(self):
2121
self.num_nodes = 1
2222
self.setup_clean_chain = True
2323

24-
def skip_test_if_missing_module(self):
25-
self.skip_if_no_wallet()
26-
2724
def test_deterministic_hash_results(self):
2825
self.log.info("Test deterministic UTXO set hash results")
2926

@@ -35,18 +32,17 @@ def test_muhash_implementation(self):
3532
self.log.info("Test MuHash implementation consistency")
3633

3734
node = self.nodes[0]
35+
wallet = MiniWallet(node)
3836

3937
# Generate 100 blocks and remove the first since we plan to spend its
4038
# coinbase
41-
block_hashes = node.generate(100)
39+
block_hashes = wallet.generate(1) + node.generate(99)
4240
blocks = list(map(lambda block: FromHex(CBlock(), node.getblock(block, False)), block_hashes))
43-
spending = blocks.pop(0)
41+
blocks.pop(0)
4442

4543
# Create a spending transaction and mine a block which includes it
46-
tx = create_transaction(node, spending.vtx[0].rehash(), node.getnewaddress(), amount=49)
47-
txid = node.sendrawtransaction(hexstring=tx.serialize_with_witness().hex(), maxfeerate=0)
48-
49-
tx_block = node.generateblock(output=node.getnewaddress(), transactions=[txid])
44+
txid = wallet.send_self_transfer(from_node=node)['txid']
45+
tx_block = node.generateblock(output=wallet.get_address(), transactions=[txid])
5046
blocks.append(FromHex(CBlock(), node.getblock(tx_block['hash'], False)))
5147

5248
# Serialize the outputs that should be in the UTXO set and add them to

test/functional/test_framework/wallet.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ def generate(self, num_blocks):
4949
self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
5050
return blocks
5151

52+
def get_address(self):
53+
return self._address
54+
5255
def get_utxo(self, *, txid=''):
5356
"""
5457
Returns a utxo and marks it as spent (pops it from the internal list)

0 commit comments

Comments
 (0)