Merge bitcoin/bitcoin#23858: test: Fix rpc_scantxoutset intermittent issue

fafe4dea16 test: Fix pep8 of touched file (MarcoFalke)
fa0ac9d7e3 test: Fix rpc_scantxoutset intermittent issue (MarcoFalke)

Pull request description:

  I fail to see how this could have ever worked, since there is nothing that prevents the wallet from spending the coins in the utxo set.

  Fixes https://github.com/bitcoin/bitcoin/issues/23847

  Longer term it would be nice to remove the wallet and use MiniWallet here.

ACKs for top commit:
  brunoerg:
    tACK fafe4dea16
  theStack:
    Code-review ACK fafe4dea16

Tree-SHA512: d92b7be9a81eb62f496488dd15b8e564e9b7a64b55634af2714b53f985e6a35fdae788323833ff59c40ae7c6a0cf54fe069db8eb3be03686f7c100379f54a292
This commit is contained in:
MarcoFalke 2021-12-26 11:07:22 +01:00
commit 9bec5b80a0
No known key found for this signature in database
GPG key ID: CE2B75697E69A548

View file

@ -10,9 +10,11 @@ from decimal import Decimal
import shutil
import os
def descriptors(out):
return sorted(u['desc'] for u in out['unspents'])
class ScantxoutsetTest(BitcoinTestFramework):
def set_test_params(self):
self.num_nodes = 1
@ -31,9 +33,12 @@ class ScantxoutsetTest(BitcoinTestFramework):
pubk2 = self.nodes[0].getaddressinfo(addr_LEGACY)['pubkey']
addr_BECH32 = self.nodes[0].getnewaddress("", "bech32")
pubk3 = self.nodes[0].getaddressinfo(addr_BECH32)['pubkey']
self.nodes[0].sendtoaddress(addr_P2SH_SEGWIT, 0.001)
self.nodes[0].sendtoaddress(addr_LEGACY, 0.002)
self.nodes[0].sendtoaddress(addr_BECH32, 0.004)
txid = self.nodes[0].sendtoaddress(addr_P2SH_SEGWIT, 0.001)
self.nodes[0].lockunspent(unlock=False, transactions=[{"txid": txid, "vout": 0}, {"txid": txid, "vout": 1}])
txid = self.nodes[0].sendtoaddress(addr_LEGACY, 0.002)
self.nodes[0].lockunspent(unlock=False, transactions=[{"txid": txid, "vout": 0}, {"txid": txid, "vout": 1}])
txid = self.nodes[0].sendtoaddress(addr_BECH32, 0.004)
self.nodes[0].lockunspent(unlock=False, transactions=[{"txid": txid, "vout": 0}, {"txid": txid, "vout": 1}])
#send to child keys of tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK
self.nodes[0].sendtoaddress("mkHV1C6JLheLoUSSZYk7x3FH5tnx9bu7yc", 0.008) # (m/0'/0'/0')
@ -49,7 +54,6 @@ class ScantxoutsetTest(BitcoinTestFramework):
self.nodes[0].sendtoaddress("mxp7w7j8S1Aq6L8StS2PqVvtt4HGxXEvdy", 8.192) # (m/1/1/1)
self.nodes[0].sendtoaddress("mpQ8rokAhp1TAtJQR6F6TaUmjAWkAWYYBq", 16.384) # (m/1/1/1500)
self.generate(self.nodes[0], 1)
self.log.info("Stop node, remove wallet, mine again some blocks...")
@ -124,5 +128,6 @@ class ScantxoutsetTest(BitcoinTestFramework):
# Check that second arg is needed for start
assert_raises_rpc_error(-1, "scanobjects argument is required for the start action", self.nodes[0].scantxoutset, "start")
if __name__ == '__main__':
if __name__ == "__main__":
ScantxoutsetTest().main()