aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_importdescriptors.py
diff options
context:
space:
mode:
authorSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-08-13 16:02:10 +0200
committerSebastian Falbesoner <sebastian.falbesoner@gmail.com>2023-10-24 11:13:51 +0200
commit73a339abc3c864461c8b8830e139c8ec51570243 (patch)
treea9ff47a204e234ecd78b85adcf88f8947015c7d2 /test/functional/wallet_importdescriptors.py
parentd724bb52910c4a4a7609d5e685740cd675dd25a7 (diff)
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.
Diffstat (limited to 'test/functional/wallet_importdescriptors.py')
-rwxr-xr-xtest/functional/wallet_importdescriptors.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/test/functional/wallet_importdescriptors.py b/test/functional/wallet_importdescriptors.py
index ad5ae111aa..1f1f92589c 100755
--- a/test/functional/wallet_importdescriptors.py
+++ b/test/functional/wallet_importdescriptors.py
@@ -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'])