Skip to content

Commit 4bea301

Browse files
committed
test: use P2PK-MiniWallet for feature_csv_activation.py
Using the MiniWallet in P2PK mode, all transactions submitted to the mempool are following the standard policy now, i.e. the node command line parameter '-acceptnonstdtxn=1' is not needed anymore.
1 parent dc7eb64 commit 4bea301

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

test/functional/feature_csv_activation.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def set_test_params(self):
9090
self.setup_clean_chain = True
9191
self.extra_args = [[
9292
93-
'-acceptnonstdtxn=1',
9493
'-par=1', # Use only one script thread to get the exact reject reason for testing
9594
]]
9695
self.supports_cli = False
@@ -103,12 +102,14 @@ def create_self_transfer_from_utxo(self, input_tx):
103102
def create_bip112special(self, input, txversion):
104103
tx = self.create_self_transfer_from_utxo(input)
105104
tx.nVersion = txversion
105+
self.miniwallet.sign_tx(tx)
106106
tx.vin[0].scriptSig = CScript([-1, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
107107
return tx
108108

109109
def create_bip112emptystack(self, input, txversion):
110110
tx = self.create_self_transfer_from_utxo(input)
111111
tx.nVersion = txversion
112+
self.miniwallet.sign_tx(tx)
112113
tx.vin[0].scriptSig = CScript([OP_CHECKSEQUENCEVERIFY] + list(CScript(tx.vin[0].scriptSig)))
113114
return tx
114115

@@ -126,6 +127,7 @@ def create_bip68txs(self, bip68inputs, txversion, locktime_delta=0):
126127
tx = self.create_self_transfer_from_utxo(bip68inputs[i])
127128
tx.nVersion = txversion
128129
tx.vin[0].nSequence = locktime + locktime_delta
130+
self.miniwallet.sign_tx(tx)
129131
tx.rehash()
130132
txs.append({'tx': tx, 'sdf': sdf, 'stf': stf})
131133

@@ -143,6 +145,7 @@ def create_bip112txs(self, bip112inputs, varyOP_CSV, txversion, locktime_delta=0
143145
else: # vary nSequence instead, OP_CSV is fixed
144146
tx.vin[0].nSequence = locktime + locktime_delta
145147
tx.nVersion = txversion
148+
self.miniwallet.sign_tx(tx)
146149
if (varyOP_CSV):
147150
tx.vin[0].scriptSig = CScript([locktime, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
148151
else:
@@ -178,7 +181,7 @@ def send_blocks(self, blocks, success=True, reject_reason=None):
178181

179182
def run_test(self):
180183
self.helper_peer = self.nodes[0].add_p2p_connection(P2PDataStore())
181-
self.miniwallet = MiniWallet(self.nodes[0], raw_script=True)
184+
self.miniwallet = MiniWallet(self.nodes[0], use_p2pk=True)
182185

183186
self.log.info("Generate blocks in the past for coinbase outputs.")
184187
long_past_time = int(time.time()) - 600 * 1000 # enough to build up to 1000 blocks 10 minutes apart without worrying about getting into the future
@@ -285,7 +288,7 @@ def run_test(self):
285288
success_txs = []
286289
# BIP113 tx, -1 CSV tx and empty stack CSV tx should succeed
287290
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
288-
bip113tx_v1.rehash()
291+
self.miniwallet.sign_tx(bip113tx_v1)
289292
success_txs.append(bip113tx_v1)
290293
success_txs.append(bip112tx_special_v1)
291294
success_txs.append(bip112tx_emptystack_v1)
@@ -305,7 +308,7 @@ def run_test(self):
305308
success_txs = []
306309
# BIP113 tx, -1 CSV tx and empty stack CSV tx should succeed
307310
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
308-
bip113tx_v2.rehash()
311+
self.miniwallet.sign_tx(bip113tx_v2)
309312
success_txs.append(bip113tx_v2)
310313
success_txs.append(bip112tx_special_v2)
311314
success_txs.append(bip112tx_emptystack_v2)
@@ -331,16 +334,20 @@ def run_test(self):
331334
self.log.info("BIP 113 tests")
332335
# BIP 113 tests should now fail regardless of version number if nLockTime isn't satisfied by new rules
333336
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
337+
self.miniwallet.sign_tx(bip113tx_v1)
334338
bip113tx_v1.rehash()
335339
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
340+
self.miniwallet.sign_tx(bip113tx_v2)
336341
bip113tx_v2.rehash()
337342
for bip113tx in [bip113tx_v1, bip113tx_v2]:
338343
self.send_blocks([self.create_test_block([bip113tx])], success=False, reject_reason='bad-txns-nonfinal')
339344

340345
# BIP 113 tests should now pass if the locktime is < MTP
341346
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
347+
self.miniwallet.sign_tx(bip113tx_v1)
342348
bip113tx_v1.rehash()
343349
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
350+
self.miniwallet.sign_tx(bip113tx_v2)
344351
bip113tx_v2.rehash()
345352
for bip113tx in [bip113tx_v1, bip113tx_v2]:
346353
self.send_blocks([self.create_test_block([bip113tx])])
@@ -465,6 +472,7 @@ def run_test(self):
465472
time_txs = []
466473
for tx in [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if not tx['sdf'] and tx['stf']]:
467474
tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME | SEQ_TYPE_FLAG
475+
self.miniwallet.sign_tx(tx)
468476
tx.rehash()
469477
time_txs.append(tx)
470478

0 commit comments

Comments
 (0)