test: Remove MiniWallet mempool_valid option

This commit is contained in:
MacroFake
2022-06-13 14:08:12 +02:00
parent 506d9b25a3
commit fa779de665
8 changed files with 11 additions and 18 deletions

View File

@@ -563,7 +563,7 @@ def create_lots_of_big_transactions(mini_wallet, node, fee, tx_batch_size, txout
from_node=node,
utxo_to_spend=None if use_internal_utxos else utxos.pop(),
fee_rate=0,
mempool_valid=False)['tx']
)["tx"]
tx.vout[0].nValue -= fee_sats
tx.vout.extend(txouts)
res = node.testmempoolaccept([tx.serialize().hex()])[0]

View File

@@ -193,7 +193,7 @@ class MiniWallet:
Returns a tuple (txid, n) referring to the created external utxo outpoint.
"""
tx = self.create_self_transfer(from_node=from_node, fee_rate=0, mempool_valid=False)['tx']
tx = self.create_self_transfer(from_node=from_node, fee_rate=0)["tx"]
assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee)
tx.vout[0].nValue -= (amount + fee) # change output -> MiniWallet
tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned
@@ -230,7 +230,7 @@ class MiniWallet:
# create simple tx template (1 input, 1 output)
tx = self.create_self_transfer(
fee_rate=0, from_node=from_node,
utxo_to_spend=utxos_to_spend[0], sequence=sequence, mempool_valid=False)['tx']
utxo_to_spend=utxos_to_spend[0], sequence=sequence)["tx"]
# duplicate inputs, witnesses and outputs
tx.vin = [deepcopy(tx.vin[0]) for _ in range(len(utxos_to_spend))]
@@ -248,9 +248,8 @@ class MiniWallet:
o.nValue = outputs_value_total // num_outputs
return tx
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, mempool_valid=True, 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.
Checking mempool validity via the testmempoolaccept RPC can be skipped by setting mempool_valid to False."""
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, 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."""
from_node = from_node or self._test_node
utxo_to_spend = utxo_to_spend or self.get_utxo()
if self._priv_key is None:
@@ -277,11 +276,7 @@ class MiniWallet:
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE]), bytes([LEAF_VERSION_TAPSCRIPT]) + self._internal_key]
tx_hex = tx.serialize().hex()
if mempool_valid:
tx_info = from_node.testmempoolaccept([tx_hex])[0]
assert_equal(tx_info['allowed'], True)
assert_equal(tx_info['vsize'], vsize)
assert_equal(tx_info['fees']['base'], utxo_to_spend['value'] - Decimal(send_value) / COIN)
assert_equal(tx.get_vsize(), vsize)
return {'txid': tx.rehash(), 'wtxid': tx.getwtxid(), 'hex': tx_hex, 'tx': tx}