mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-14 10:51:27 +02:00
test: Remove wallet dependency of utxo set hash test
This commit is contained in:
parent
1a27af1d7b
commit
4973c5175c
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from test_framework.blocktools import create_transaction
|
|
||||||
from test_framework.messages import (
|
from test_framework.messages import (
|
||||||
CBlock,
|
CBlock,
|
||||||
COutPoint,
|
COutPoint,
|
||||||
@ -15,15 +14,13 @@ from test_framework.messages import (
|
|||||||
from test_framework.muhash import MuHash3072
|
from test_framework.muhash import MuHash3072
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import assert_equal
|
from test_framework.util import assert_equal
|
||||||
|
from test_framework.wallet import MiniWallet
|
||||||
|
|
||||||
class UTXOSetHashTest(BitcoinTestFramework):
|
class UTXOSetHashTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
|
||||||
self.skip_if_no_wallet()
|
|
||||||
|
|
||||||
def test_deterministic_hash_results(self):
|
def test_deterministic_hash_results(self):
|
||||||
self.log.info("Test deterministic UTXO set hash results")
|
self.log.info("Test deterministic UTXO set hash results")
|
||||||
|
|
||||||
@ -35,18 +32,17 @@ class UTXOSetHashTest(BitcoinTestFramework):
|
|||||||
self.log.info("Test MuHash implementation consistency")
|
self.log.info("Test MuHash implementation consistency")
|
||||||
|
|
||||||
node = self.nodes[0]
|
node = self.nodes[0]
|
||||||
|
wallet = MiniWallet(node)
|
||||||
|
|
||||||
# Generate 100 blocks and remove the first since we plan to spend its
|
# Generate 100 blocks and remove the first since we plan to spend its
|
||||||
# coinbase
|
# 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))
|
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
|
# Create a spending transaction and mine a block which includes it
|
||||||
tx = create_transaction(node, spending.vtx[0].rehash(), node.getnewaddress(), amount=49)
|
txid = wallet.send_self_transfer(from_node=node)['txid']
|
||||||
txid = node.sendrawtransaction(hexstring=tx.serialize_with_witness().hex(), maxfeerate=0)
|
tx_block = node.generateblock(output=wallet.get_address(), transactions=[txid])
|
||||||
|
|
||||||
tx_block = node.generateblock(output=node.getnewaddress(), transactions=[txid])
|
|
||||||
blocks.append(FromHex(CBlock(), node.getblock(tx_block['hash'], False)))
|
blocks.append(FromHex(CBlock(), node.getblock(tx_block['hash'], False)))
|
||||||
|
|
||||||
# Serialize the outputs that should be in the UTXO set and add them to
|
# Serialize the outputs that should be in the UTXO set and add them to
|
||||||
|
@ -49,6 +49,9 @@ class MiniWallet:
|
|||||||
self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
|
self._utxos.append({'txid': cb_tx['txid'], 'vout': 0, 'value': cb_tx['vout'][0]['value']})
|
||||||
return blocks
|
return blocks
|
||||||
|
|
||||||
|
def get_address(self):
|
||||||
|
return self._address
|
||||||
|
|
||||||
def get_utxo(self, *, txid=''):
|
def get_utxo(self, *, txid=''):
|
||||||
"""
|
"""
|
||||||
Returns a utxo and marks it as spent (pops it from the internal list)
|
Returns a utxo and marks it as spent (pops it from the internal list)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user