I’ve translated the test to MiniWallet. If you take it, make sure to rebase on current master first, as it is using new MiniWallet functions.
Also, I am removing not needed stuff. Let me know if you have any questions. And no need to mention me in the commit as author.
0diff --git a/test/functional/rpc_txospender.py b/test/functional/rpc_txospender.py
1index 1d7157e9bf..c063b4e502 100755
2--- a/test/functional/rpc_txospender.py
3+++ b/test/functional/rpc_txospender.py
4@@ -10,57 +10,36 @@ from test_framework.test_framework import BitcoinTestFramework
5 from test_framework.util import (
6 assert_equal,
7 assert_raises_rpc_error,
8- find_vout_for_address,
9 )
10+from test_framework.wallet import MiniWallet
11+
12
13 class GetTxoSpenderTest(BitcoinTestFramework):
14 def set_test_params(self):
15- self.setup_clean_chain = True
16 self.num_nodes = 2
17 self.extra_args = [
18 ["-txindex", "-txospenderindex"],
19 ["-txindex"],
20 ]
21- # whitelist all peers to speed up tx relay / mempool sync
22- for args in self.extra_args:
23- args.append("-whitelist=noban@127.0.0.1")
24-
25 self.supports_cli = False
26
27- def skip_test_if_missing_module(self):
28- self.skip_if_no_wallet()
29-
30- def setup_network(self):
31- super().setup_network()
32- self.connect_nodes(0, 1)
33-
34 def run_test(self):
35- self.log.info("Prepare some coins for multiple *rawtransaction commands")
36- self.generate(self.nodes[1], 1)
37- self.generate(self.nodes[0], COINBASE_MATURITY + 1)
38- self.sync_all()
39- self.generate(self.nodes[0], 5)
40+ self.wallet = MiniWallet(self.nodes[1])
41+ self.wallet.rescan_utxos()
42
43 self.gettxospender_tests()
44
45 def gettxospender_tests(self):
46- addr = self.nodes[1].getnewaddress()
47- txid = self.nodes[0].sendtoaddress(addr, 10)
48- self.generate(self.nodes[0], 1)
49- vout = find_vout_for_address(self.nodes[1], txid, addr)
50- rawTx = self.nodes[1].createrawtransaction([{'txid': txid, 'vout': vout}], {self.nodes[1].getnewaddress(): 9.999})
51- rawTxSigned = self.nodes[1].signrawtransactionwithwallet(rawTx)
52- txId = self.nodes[1].sendrawtransaction(rawTxSigned['hex'])
53- self.generateblock(self.nodes[0], output=self.nodes[0].getnewaddress(), transactions=[rawTxSigned['hex']])
54+ partially_spent_tx = self.wallet.send_self_transfer_multi(from_node=self.nodes[1], num_outputs=2)
55+ num_out = 1
56+ spending_txid = self.wallet.send_self_transfer(from_node=self.nodes[1], utxo_to_spend=partially_spent_tx["new_utxos"][num_out])["txid"]
57+ self.generate(self.wallet, 1)
58
59- for n in [0, 1]:
60- self.log.info(f"Test gettxospender {'with' if n == 0 else 'without'} -txospenderindex")
61+ self.log.info(f"Test gettxospender with -txospenderindex")
62+ assert_equal(self.nodes[0].gettxospender(partially_spent_tx["txid"], num_out), spending_txid)
63+ self.log.info(f"Test gettxospender without -txospenderindex")
64+ assert_raises_rpc_error(-8, "This RPC call requires -txospenderindex to be enabled.", self.nodes[1].gettxospender, partially_spent_tx["txid"], num_out)
65
66- if n == 0:
67- assert_equal(self.nodes[n].gettxospender(txid, vout), txId)
68- else:
69- # Without -txospenderindex, expect to raise.
70- assert_raises_rpc_error(-8, "This RPC call requires -txospenderindex to be enabled.", self.nodes[n].gettxospender, txid, vout)
71
72-if __name__ == '__main__':
73+if __name__ == "__main__":
74 GetTxoSpenderTest().main()