diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2021-02-23 00:16:50 +0100 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2021-03-23 20:32:50 +0100 |
commit | 4973c5175c5fd1f4791ea26e8ddefd6fb11ac1c3 (patch) | |
tree | bd6f5e2251c46d7f4d3c0194b7e0f7c8cafeda07 | |
parent | 1a27af1d7b5ec18b4248ead1eaf0f381047b4b24 (diff) |
test: Remove wallet dependency of utxo set hash test
-rwxr-xr-x | test/functional/feature_utxo_set_hash.py | 16 | ||||
-rw-r--r-- | test/functional/test_framework/wallet.py | 3 |
2 files changed, 9 insertions, 10 deletions
diff --git a/test/functional/feature_utxo_set_hash.py b/test/functional/feature_utxo_set_hash.py index 6e6046d84d..214dea40c4 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,15 +14,13 @@ 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") @@ -35,18 +32,17 @@ class UTXOSetHashTest(BitcoinTestFramework): self.log.info("Test MuHash implementation consistency") node = self.nodes[0] + wallet = MiniWallet(node) # 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 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) |