aboutsummaryrefslogtreecommitdiff
path: root/test/functional/wallet_txn_clone.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_txn_clone.py
parentd724bb52910c4a4a7609d5e685740cd675dd25a7 (diff)
downloadbitcoin-73a339abc3c864461c8b8830e139c8ec51570243.tar.xz
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_txn_clone.py')
-rwxr-xr-xtest/functional/wallet_txn_clone.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/test/functional/wallet_txn_clone.py b/test/functional/wallet_txn_clone.py
index d8ef66d83a..1f3b6f2ce9 100755
--- a/test/functional/wallet_txn_clone.py
+++ b/test/functional/wallet_txn_clone.py
@@ -7,7 +7,6 @@
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_equal,
- find_vout_for_address
)
from test_framework.messages import (
COIN,
@@ -35,8 +34,8 @@ class TxnMallTest(BitcoinTestFramework):
super().setup_network()
self.disconnect_nodes(1, 2)
- def spend_txid(self, txid, vout, outputs):
- inputs = [{"txid": txid, "vout": vout}]
+ def spend_utxo(self, utxo, outputs):
+ inputs = [utxo]
tx = self.nodes[0].createrawtransaction(inputs, outputs)
tx = self.nodes[0].fundrawtransaction(tx)
tx = self.nodes[0].signrawtransactionwithwallet(tx['hex'])
@@ -56,13 +55,13 @@ class TxnMallTest(BitcoinTestFramework):
self.nodes[0].settxfee(.001)
node0_address1 = self.nodes[0].getnewaddress(address_type=output_type)
- node0_txid1 = self.nodes[0].sendtoaddress(node0_address1, 1219)
- node0_tx1 = self.nodes[0].gettransaction(node0_txid1)
- self.nodes[0].lockunspent(False, [{"txid":node0_txid1, "vout": find_vout_for_address(self.nodes[0], node0_txid1, node0_address1)}])
+ node0_utxo1 = self.create_outpoints(self.nodes[0], outputs=[{node0_address1: 1219}])[0]
+ node0_tx1 = self.nodes[0].gettransaction(node0_utxo1['txid'])
+ self.nodes[0].lockunspent(False, [node0_utxo1])
node0_address2 = self.nodes[0].getnewaddress(address_type=output_type)
- node0_txid2 = self.nodes[0].sendtoaddress(node0_address2, 29)
- node0_tx2 = self.nodes[0].gettransaction(node0_txid2)
+ node0_utxo2 = self.create_outpoints(self.nodes[0], outputs=[{node0_address2: 29}])[0]
+ node0_tx2 = self.nodes[0].gettransaction(node0_utxo2['txid'])
assert_equal(self.nodes[0].getbalance(),
starting_balance + node0_tx1["fee"] + node0_tx2["fee"])
@@ -71,8 +70,8 @@ class TxnMallTest(BitcoinTestFramework):
node1_address = self.nodes[1].getnewaddress()
# Send tx1, and another transaction tx2 that won't be cloned
- txid1 = self.spend_txid(node0_txid1, find_vout_for_address(self.nodes[0], node0_txid1, node0_address1), {node1_address: 40})
- txid2 = self.spend_txid(node0_txid2, find_vout_for_address(self.nodes[0], node0_txid2, node0_address2), {node1_address: 20})
+ txid1 = self.spend_utxo(node0_utxo1, {node1_address: 40})
+ txid2 = self.spend_utxo(node0_utxo2, {node1_address: 20})
# Construct a clone of tx1, to be malleated
rawtx1 = self.nodes[0].getrawtransaction(txid1, 1)