Skip to content

Commit a55606c

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25356: test: Remove MiniWallet mempool_valid option
fa779de test: Remove MiniWallet mempool_valid option (MacroFake) Pull request description: It seems an unnecessary burden to force MiniWallet call-sites to figure out for each tx whether it is mempool valid or not. The result will only be used for internal sanity checks. So remove the option: * Replace the vsize sanity check with a call to `get_vsize()`. * Drop the fee check. Hopefully any future bug here will be caught by code-review or otherwise. ACKs for top commit: theStack: Code-review ACK fa779de Tree-SHA512: df44a0e116a0b6b15389c80038f9b45e17f186d0e3d7b0925e367fd2cbbcab9a7a6f7add41859ffb5603885f304233a5d28fbd57a4008ebdfe5edbe83bb1d7c3
2 parents b91055e + fa779de commit a55606c

File tree

8 files changed

+11
-18
lines changed

8 files changed

+11
-18
lines changed

test/functional/feature_rbf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ def test_no_inherited_signaling(self):
684684
utxo_to_spend=parent_utxo,
685685
sequence=SEQUENCE_FINAL,
686686
fee_rate=Decimal('0.02'),
687-
mempool_valid=False,
688687
)
689688

690689
# Broadcast replacement child tx

test/functional/mempool_limit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def run_test(self):
7575

7676
# Deliberately try to create a tx with a fee less than the minimum mempool fee to assert that it does not get added to the mempool
7777
self.log.info('Create a mempool tx that will not pass mempoolminfee')
78-
assert_raises_rpc_error(-26, "mempool min fee not met", miniwallet.send_self_transfer, from_node=node, fee_rate=relayfee, mempool_valid=False)
78+
assert_raises_rpc_error(-26, "mempool min fee not met", miniwallet.send_self_transfer, from_node=node, fee_rate=relayfee)
7979

8080

8181
if __name__ == '__main__':

test/functional/mempool_reorg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def run_test(self):
5353
utxo = wallet.get_utxo(txid=coinbase_txids[0])
5454
timelock_tx = wallet.create_self_transfer(
5555
utxo_to_spend=utxo,
56-
mempool_valid=False,
57-
locktime=self.nodes[0].getblockcount() + 2
56+
locktime=self.nodes[0].getblockcount() + 2,
5857
)['hex']
5958

6059
self.log.info("Check that the time-locked transaction is too immature to spend")

test/functional/mempool_spend_coinbase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def run_test(self):
4040
spend_mature_id = wallet.send_self_transfer(from_node=self.nodes[0], utxo_to_spend=utxo_mature)["txid"]
4141

4242
# other coinbase should be too immature to spend
43-
immature_tx = wallet.create_self_transfer(utxo_to_spend=utxo_immature, mempool_valid=False)
43+
immature_tx = wallet.create_self_transfer(utxo_to_spend=utxo_immature)
4444
assert_raises_rpc_error(-26,
4545
"bad-txns-premature-spend-of-coinbase",
4646
lambda: self.nodes[0].sendrawtransaction(immature_tx['hex']))

test/functional/mining_prioritisetransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def run_test(self):
212212
assert x not in mempool
213213

214214
# Create a free transaction. Should be rejected.
215-
tx_res = self.wallet.create_self_transfer(from_node=self.nodes[0], fee_rate=0, mempool_valid=False)
215+
tx_res = self.wallet.create_self_transfer(from_node=self.nodes[0], fee_rate=0)
216216
tx_hex = tx_res['hex']
217217
tx_id = tx_res['txid']
218218

test/functional/rpc_rawtransaction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def sendrawtransaction_testmempoolaccept_tests(self):
285285

286286
# Test a transaction with a large fee.
287287
# Fee rate is 0.20000000 BTC/kvB
288-
tx = self.wallet.create_self_transfer(mempool_valid=False, from_node=self.nodes[0], fee_rate=Decimal('0.20000000'))
288+
tx = self.wallet.create_self_transfer(from_node=self.nodes[0], fee_rate=Decimal("0.20000000"))
289289
# Thus, testmempoolaccept should reject
290290
testres = self.nodes[2].testmempoolaccept([tx['hex']])[0]
291291
assert_equal(testres['allowed'], False)

test/functional/test_framework/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def create_lots_of_big_transactions(mini_wallet, node, fee, tx_batch_size, txout
563563
from_node=node,
564564
utxo_to_spend=None if use_internal_utxos else utxos.pop(),
565565
fee_rate=0,
566-
mempool_valid=False)['tx']
566+
)["tx"]
567567
tx.vout[0].nValue -= fee_sats
568568
tx.vout.extend(txouts)
569569
res = node.testmempoolaccept([tx.serialize().hex()])[0]

test/functional/test_framework/wallet.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
193193
194194
Returns a tuple (txid, n) referring to the created external utxo outpoint.
195195
"""
196-
tx = self.create_self_transfer(from_node=from_node, fee_rate=0, mempool_valid=False)['tx']
196+
tx = self.create_self_transfer(from_node=from_node, fee_rate=0)["tx"]
197197
assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee)
198198
tx.vout[0].nValue -= (amount + fee) # change output -> MiniWallet
199199
tx.vout.append(CTxOut(amount, scriptPubKey)) # arbitrary output -> to be returned
@@ -230,7 +230,7 @@ def create_self_transfer_multi(
230230
# create simple tx template (1 input, 1 output)
231231
tx = self.create_self_transfer(
232232
fee_rate=0, from_node=from_node,
233-
utxo_to_spend=utxos_to_spend[0], sequence=sequence, mempool_valid=False)['tx']
233+
utxo_to_spend=utxos_to_spend[0], sequence=sequence)["tx"]
234234

235235
# duplicate inputs, witnesses and outputs
236236
tx.vin = [deepcopy(tx.vin[0]) for _ in range(len(utxos_to_spend))]
@@ -248,9 +248,8 @@ def create_self_transfer_multi(
248248
o.nValue = outputs_value_total // num_outputs
249249
return tx
250250

251-
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, mempool_valid=True, locktime=0, sequence=0):
252-
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.
253-
Checking mempool validity via the testmempoolaccept RPC can be skipped by setting mempool_valid to False."""
251+
def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utxo_to_spend=None, locktime=0, sequence=0):
252+
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
254253
from_node = from_node or self._test_node
255254
utxo_to_spend = utxo_to_spend or self.get_utxo()
256255
if self._priv_key is None:
@@ -277,11 +276,7 @@ def create_self_transfer(self, *, fee_rate=Decimal("0.003"), from_node=None, utx
277276
tx.wit.vtxinwit[0].scriptWitness.stack = [CScript([OP_TRUE]), bytes([LEAF_VERSION_TAPSCRIPT]) + self._internal_key]
278277
tx_hex = tx.serialize().hex()
279278

280-
if mempool_valid:
281-
tx_info = from_node.testmempoolaccept([tx_hex])[0]
282-
assert_equal(tx_info['allowed'], True)
283-
assert_equal(tx_info['vsize'], vsize)
284-
assert_equal(tx_info['fees']['base'], utxo_to_spend['value'] - Decimal(send_value) / COIN)
279+
assert_equal(tx.get_vsize(), vsize)
285280

286281
return {'txid': tx.rehash(), 'wtxid': tx.getwtxid(), 'hex': tx_hex, 'tx': tx}
287282

0 commit comments

Comments
 (0)