Skip to content

Commit 493af7a

Browse files
MacroFakeFabcien
authored andcommitted
test: Remove MiniWallet mempool_valid option
Summary: ``` 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: ``` Backport of [[bitcoin/bitcoin#25356 | core#25356]]. Depends on D12732. Note: most tests are not converted to MiniWallet yet, but this change is trivial enough that it's not a problem. Test Plan: ninja check-functional Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Differential Revision: https://reviews.bitcoinabc.org/D12733
1 parent 58c2c25 commit 493af7a

File tree

3 files changed

+8
-17
lines changed

3 files changed

+8
-17
lines changed

test/functional/mempool_reorg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ def run_test(self):
6262
timelock_tx = wallet.create_self_transfer(
6363
from_node=self.nodes[0],
6464
utxo_to_spend=utxo,
65-
mempool_valid=False,
66-
locktime=self.nodes[0].getblockcount() + 2
65+
locktime=self.nodes[0].getblockcount() + 2,
6766
)['hex']
6867

6968
self.log.info(

test/functional/mempool_spend_coinbase.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def coinbase_txid(h):
5353
# other coinbase should be too immature to spend
5454
immature_tx = wallet.create_self_transfer(
5555
from_node=self.nodes[0],
56-
utxo_to_spend=utxo_immature,
57-
mempool_valid=False)
56+
utxo_to_spend=utxo_immature)
5857
assert_raises_rpc_error(-26,
5958
"bad-txns-premature-spend-of-coinbase",
6059
lambda: self.nodes[0].sendrawtransaction(immature_tx['hex']))

test/functional/test_framework/wallet.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@ def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
114114
(the utxo with the largest value is taken).
115115
Returns a tuple (txid, n) referring to the created external utxo outpoint.
116116
"""
117-
tx = self.create_self_transfer(
118-
from_node=from_node,
119-
fee_rate=0,
120-
mempool_valid=False)['tx']
117+
tx = self.create_self_transfer(from_node=from_node, fee_rate=0)["tx"]
121118
assert_greater_than_or_equal(tx.vout[0].nValue, amount + fee)
122119
# change output -> MiniWallet
123120
tx.vout[0].nValue -= (amount + fee)
@@ -129,16 +126,14 @@ def send_to(self, *, from_node, scriptPubKey, amount, fee=1000):
129126
return txid, len(tx.vout) - 1
130127

131128
def create_self_transfer(self, *, fee_rate=Decimal("3000.00"),
132-
from_node, utxo_to_spend=None, mempool_valid=True, locktime=0):
133-
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed.
134-
Checking mempool validity via the testmempoolaccept RPC can be skipped by setting mempool_valid to False."""
129+
from_node, utxo_to_spend=None, locktime=0):
130+
"""Create and return a tx with the specified fee_rate. Fee may be exact or at most one satoshi higher than needed."""
135131
utxo_to_spend = utxo_to_spend or self.get_utxo()
136132

137133
# The size will be enforced by pad_tx()
138134
size = 100
139135
send_value = satoshi_round(
140136
utxo_to_spend['value'] - fee_rate * (Decimal(size) / 1000))
141-
fee = utxo_to_spend['value'] - send_value
142137
assert send_value > 0
143138

144139
tx = CTransaction()
@@ -149,11 +144,9 @@ def create_self_transfer(self, *, fee_rate=Decimal("3000.00"),
149144
tx.vin[0].scriptSig = SCRIPTSIG_OP_TRUE
150145
pad_tx(tx, size)
151146
tx_hex = tx.serialize().hex()
152-
if mempool_valid:
153-
tx_info = from_node.testmempoolaccept([tx_hex])[0]
154-
assert_equal(mempool_valid, tx_info['allowed'])
155-
assert_equal(tx_info['size'], size)
156-
assert_equal(tx_info['fees']['base'], fee)
147+
148+
assert_equal(len(tx.serialize()), size)
149+
157150
return {'txid': tx.rehash(), 'hex': tx_hex, 'tx': tx}
158151

159152
def sendrawtransaction(self, *, from_node, tx_hex):

0 commit comments

Comments
 (0)