diff options
author | MacroFake <falke.marco@gmail.com> | 2022-06-23 10:50:29 +0200 |
---|---|---|
committer | MacroFake <falke.marco@gmail.com> | 2022-06-27 11:07:34 +0200 |
commit | fa04ff61b6c209e48bce7d581466356e84617637 (patch) | |
tree | ff730027327ecf03b1ff363bbf3ed2630d9a9257 /test/functional | |
parent | fa34e44e98d3840fa79533fec512c80e9e1d3ea1 (diff) |
test: Return new_utxos from create_self_transfer_multi in MiniWallet
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/feature_dbcrash.py | 8 | ||||
-rwxr-xr-x | test/functional/feature_fee_estimation.py | 3 | ||||
-rwxr-xr-x | test/functional/feature_rbf.py | 5 | ||||
-rw-r--r-- | test/functional/test_framework/wallet.py | 29 |
4 files changed, 22 insertions, 23 deletions
diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py index a3a5e9e27d..62e9bec663 100755 --- a/test/functional/feature_dbcrash.py +++ b/test/functional/feature_dbcrash.py @@ -192,14 +192,12 @@ class ChainstateWriteCrashTest(BitcoinTestFramework): # Sanity check -- if we chose inputs that are too small, skip continue - tx = self.wallet.create_self_transfer_multi( + self.wallet.send_self_transfer_multi( from_node=node, utxos_to_spend=utxos_to_spend, num_outputs=3, - fee_per_output=FEE // 3) - - # Send the transaction to get into the mempool (skip fee-checks to run faster) - node.sendrawtransaction(hexstring=tx.serialize().hex(), maxfeerate=0) + fee_per_output=FEE // 3, + ) num_transactions += 1 def run_test(self): diff --git a/test/functional/feature_fee_estimation.py b/test/functional/feature_fee_estimation.py index ca21dd8a73..b0cbcf4edf 100755 --- a/test/functional/feature_fee_estimation.py +++ b/test/functional/feature_fee_estimation.py @@ -52,7 +52,8 @@ def small_txpuzzle_randfee( raise RuntimeError(f"Insufficient funds: need {amount + fee}, have {total_in}") tx = wallet.create_self_transfer_multi( utxos_to_spend=utxos_to_spend, - fee_per_output=0) + fee_per_output=0, + )["tx"] tx.vout[0].nValue = int((total_in - amount - fee) * COIN) tx.vout.append(deepcopy(tx.vout[0])) tx.vout[1].nValue = int(amount * COIN) diff --git a/test/functional/feature_rbf.py b/test/functional/feature_rbf.py index 712897e5e7..91dc222bab 100755 --- a/test/functional/feature_rbf.py +++ b/test/functional/feature_rbf.py @@ -472,11 +472,10 @@ class ReplaceByFeeTest(BitcoinTestFramework): # Now attempt to submit a tx that double-spends all the root tx inputs, which # would invalidate `num_txs_invalidated` transactions. - double_tx = wallet.create_self_transfer_multi( + tx_hex = wallet.create_self_transfer_multi( utxos_to_spend=root_utxos, fee_per_output=10_000_000, # absurdly high feerate - ) - tx_hex = double_tx.serialize().hex() + )["hex"] if failure_expected: assert_raises_rpc_error( diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index 1892b33f1c..435c985406 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -209,20 +209,10 @@ class MiniWallet: return txid, 1 def send_self_transfer_multi(self, *, from_node, **kwargs): - """ - Create and send a transaction that spends the given UTXOs and creates a - certain number of outputs with equal amounts. - - Returns a dictionary with - - txid - - serialized transaction in hex format - - transaction as CTransaction instance - - list of newly created UTXOs, ordered by vout index - """ + """Call create_self_transfer_multi and send the transaction.""" tx = self.create_self_transfer_multi(**kwargs) - txid = self.sendrawtransaction(from_node=from_node, tx_hex=tx.serialize().hex()) - return {'new_utxos': [self.get_utxo(txid=txid, vout=vout) for vout in range(len(tx.vout))], - 'txid': txid, 'hex': tx.serialize().hex(), 'tx': tx} + self.sendrawtransaction(from_node=from_node, tx_hex=tx["hex"]) + return tx def create_self_transfer_multi( self, @@ -256,7 +246,18 @@ class MiniWallet: outputs_value_total = inputs_value_total - fee_per_output * num_outputs for o in tx.vout: o.nValue = outputs_value_total // num_outputs - return tx + txid = tx.rehash() + return { + "new_utxos": [self._create_utxo( + txid=txid, + vout=i, + value=Decimal(tx.vout[i].nValue) / COIN, + height=0, + ) for i in range(len(tx.vout))], + "txid": txid, + "hex": tx.serialize().hex(), + "tx": tx, + } def create_self_transfer(self, *, fee_rate=Decimal("0.003"), utxo_to_spend=None, locktime=0, sequence=0): """Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.""" |