test: refactor: support sending funds with outpoint result
This commit introduces a helper `create_outpoints` to execute the `send` RPC and immediately return the target address outpoints as UTXO dictionary in the common format, making the tests more readable and avoiding unnecessary duplication.
This commit is contained in:
1 parent
d724bb5291
commit
73a339abc3
9 files changed
+90
-107
No files matched your search
@@ -24,7 +24,6 @@ from test_framework.descriptors import descsum_create
|
||||
from test_framework.util import (
|
||||
assert_equal,
|
||||
assert_raises_rpc_error,
|
||||
find_vout_for_address,
|
||||
)
|
||||
from test_framework.wallet_util import (
|
||||
get_generate_key,
|
||||
@@ -493,12 +492,10 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 999)
|
||||
|
||||
# generate some utxos for next tests
|
||||
txid = w0.sendtoaddress(addr, 10)
|
||||
vout = find_vout_for_address(self.nodes[0], txid, addr)
|
||||
utxo = self.create_outpoints(w0, outputs=[{addr: 10}])[0]
|
||||
|
||||
addr2 = wmulti_pub.getnewaddress('', 'bech32')
|
||||
txid2 = w0.sendtoaddress(addr2, 10)
|
||||
vout2 = find_vout_for_address(self.nodes[0], txid2, addr2)
|
||||
utxo2 = self.create_outpoints(w0, outputs=[{addr2: 10}])[0]
|
||||
|
||||
self.generate(self.nodes[0], 6)
|
||||
assert_equal(wmulti_pub.getbalance(), wmulti_priv.getbalance())
|
||||
@@ -554,7 +551,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
assert_equal(res[1]['success'], True)
|
||||
assert_equal(res[1]['warnings'][0], 'Not all private keys provided. Some wallet functionality may return unexpected errors')
|
||||
|
||||
rawtx = self.nodes[1].createrawtransaction([{'txid': txid, 'vout': vout}], {w0.getnewaddress(): 9.999})
|
||||
rawtx = self.nodes[1].createrawtransaction([utxo], {w0.getnewaddress(): 9.999})
|
||||
tx_signed_1 = wmulti_priv1.signrawtransactionwithwallet(rawtx)
|
||||
assert_equal(tx_signed_1['complete'], False)
|
||||
tx_signed_2 = wmulti_priv2.signrawtransactionwithwallet(tx_signed_1['hex'])
|
||||
@@ -648,7 +645,7 @@ class ImportDescriptorsTest(BitcoinTestFramework):
|
||||
}])
|
||||
assert_equal(res[0]['success'], True)
|
||||
|
||||
rawtx = self.nodes[1].createrawtransaction([{'txid': txid2, 'vout': vout2}], {w0.getnewaddress(): 9.999})
|
||||
rawtx = self.nodes[1].createrawtransaction([utxo2], {w0.getnewaddress(): 9.999})
|
||||
tx = wmulti_priv3.signrawtransactionwithwallet(rawtx)
|
||||
assert_equal(tx['complete'], True)
|
||||
self.nodes[1].sendrawtransaction(tx['hex'])
|
||||
|
||||
Reference in new issue
Block a user