mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
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.
This commit is contained in:
parent
dc7eb64e83
commit
4bea301692
1 changed files with 12 additions and 4 deletions
|
@ -90,7 +90,6 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.extra_args = [[
|
self.extra_args = [[
|
||||||
'-whitelist=noban@127.0.0.1',
|
'-whitelist=noban@127.0.0.1',
|
||||||
'-acceptnonstdtxn=1',
|
|
||||||
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
'-par=1', # Use only one script thread to get the exact reject reason for testing
|
||||||
]]
|
]]
|
||||||
self.supports_cli = False
|
self.supports_cli = False
|
||||||
|
@ -103,12 +102,14 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
def create_bip112special(self, input, txversion):
|
def create_bip112special(self, input, txversion):
|
||||||
tx = self.create_self_transfer_from_utxo(input)
|
tx = self.create_self_transfer_from_utxo(input)
|
||||||
tx.nVersion = txversion
|
tx.nVersion = txversion
|
||||||
|
self.miniwallet.sign_tx(tx)
|
||||||
tx.vin[0].scriptSig = CScript([-1, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
|
tx.vin[0].scriptSig = CScript([-1, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
def create_bip112emptystack(self, input, txversion):
|
def create_bip112emptystack(self, input, txversion):
|
||||||
tx = self.create_self_transfer_from_utxo(input)
|
tx = self.create_self_transfer_from_utxo(input)
|
||||||
tx.nVersion = txversion
|
tx.nVersion = txversion
|
||||||
|
self.miniwallet.sign_tx(tx)
|
||||||
tx.vin[0].scriptSig = CScript([OP_CHECKSEQUENCEVERIFY] + list(CScript(tx.vin[0].scriptSig)))
|
tx.vin[0].scriptSig = CScript([OP_CHECKSEQUENCEVERIFY] + list(CScript(tx.vin[0].scriptSig)))
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
@ -126,6 +127,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
tx = self.create_self_transfer_from_utxo(bip68inputs[i])
|
tx = self.create_self_transfer_from_utxo(bip68inputs[i])
|
||||||
tx.nVersion = txversion
|
tx.nVersion = txversion
|
||||||
tx.vin[0].nSequence = locktime + locktime_delta
|
tx.vin[0].nSequence = locktime + locktime_delta
|
||||||
|
self.miniwallet.sign_tx(tx)
|
||||||
tx.rehash()
|
tx.rehash()
|
||||||
txs.append({'tx': tx, 'sdf': sdf, 'stf': stf})
|
txs.append({'tx': tx, 'sdf': sdf, 'stf': stf})
|
||||||
|
|
||||||
|
@ -143,6 +145,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
else: # vary nSequence instead, OP_CSV is fixed
|
else: # vary nSequence instead, OP_CSV is fixed
|
||||||
tx.vin[0].nSequence = locktime + locktime_delta
|
tx.vin[0].nSequence = locktime + locktime_delta
|
||||||
tx.nVersion = txversion
|
tx.nVersion = txversion
|
||||||
|
self.miniwallet.sign_tx(tx)
|
||||||
if (varyOP_CSV):
|
if (varyOP_CSV):
|
||||||
tx.vin[0].scriptSig = CScript([locktime, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
|
tx.vin[0].scriptSig = CScript([locktime, OP_CHECKSEQUENCEVERIFY, OP_DROP] + list(CScript(tx.vin[0].scriptSig)))
|
||||||
else:
|
else:
|
||||||
|
@ -178,7 +181,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.helper_peer = self.nodes[0].add_p2p_connection(P2PDataStore())
|
self.helper_peer = self.nodes[0].add_p2p_connection(P2PDataStore())
|
||||||
self.miniwallet = MiniWallet(self.nodes[0], raw_script=True)
|
self.miniwallet = MiniWallet(self.nodes[0], use_p2pk=True)
|
||||||
|
|
||||||
self.log.info("Generate blocks in the past for coinbase outputs.")
|
self.log.info("Generate blocks in the past for coinbase outputs.")
|
||||||
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
|
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 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
success_txs = []
|
success_txs = []
|
||||||
# BIP113 tx, -1 CSV tx and empty stack CSV tx should succeed
|
# BIP113 tx, -1 CSV tx and empty stack CSV tx should succeed
|
||||||
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
||||||
bip113tx_v1.rehash()
|
self.miniwallet.sign_tx(bip113tx_v1)
|
||||||
success_txs.append(bip113tx_v1)
|
success_txs.append(bip113tx_v1)
|
||||||
success_txs.append(bip112tx_special_v1)
|
success_txs.append(bip112tx_special_v1)
|
||||||
success_txs.append(bip112tx_emptystack_v1)
|
success_txs.append(bip112tx_emptystack_v1)
|
||||||
|
@ -305,7 +308,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
success_txs = []
|
success_txs = []
|
||||||
# BIP113 tx, -1 CSV tx and empty stack CSV tx should succeed
|
# BIP113 tx, -1 CSV tx and empty stack CSV tx should succeed
|
||||||
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
||||||
bip113tx_v2.rehash()
|
self.miniwallet.sign_tx(bip113tx_v2)
|
||||||
success_txs.append(bip113tx_v2)
|
success_txs.append(bip113tx_v2)
|
||||||
success_txs.append(bip112tx_special_v2)
|
success_txs.append(bip112tx_special_v2)
|
||||||
success_txs.append(bip112tx_emptystack_v2)
|
success_txs.append(bip112tx_emptystack_v2)
|
||||||
|
@ -331,16 +334,20 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
self.log.info("BIP 113 tests")
|
self.log.info("BIP 113 tests")
|
||||||
# BIP 113 tests should now fail regardless of version number if nLockTime isn't satisfied by new rules
|
# BIP 113 tests should now fail regardless of version number if nLockTime isn't satisfied by new rules
|
||||||
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
||||||
|
self.miniwallet.sign_tx(bip113tx_v1)
|
||||||
bip113tx_v1.rehash()
|
bip113tx_v1.rehash()
|
||||||
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 # = MTP of prior block (not <) but < time put on current block
|
||||||
|
self.miniwallet.sign_tx(bip113tx_v2)
|
||||||
bip113tx_v2.rehash()
|
bip113tx_v2.rehash()
|
||||||
for bip113tx in [bip113tx_v1, bip113tx_v2]:
|
for bip113tx in [bip113tx_v1, bip113tx_v2]:
|
||||||
self.send_blocks([self.create_test_block([bip113tx])], success=False, reject_reason='bad-txns-nonfinal')
|
self.send_blocks([self.create_test_block([bip113tx])], success=False, reject_reason='bad-txns-nonfinal')
|
||||||
|
|
||||||
# BIP 113 tests should now pass if the locktime is < MTP
|
# BIP 113 tests should now pass if the locktime is < MTP
|
||||||
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
|
bip113tx_v1.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
|
||||||
|
self.miniwallet.sign_tx(bip113tx_v1)
|
||||||
bip113tx_v1.rehash()
|
bip113tx_v1.rehash()
|
||||||
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
|
bip113tx_v2.nLockTime = self.last_block_time - 600 * 5 - 1 # < MTP of prior block
|
||||||
|
self.miniwallet.sign_tx(bip113tx_v2)
|
||||||
bip113tx_v2.rehash()
|
bip113tx_v2.rehash()
|
||||||
for bip113tx in [bip113tx_v1, bip113tx_v2]:
|
for bip113tx in [bip113tx_v1, bip113tx_v2]:
|
||||||
self.send_blocks([self.create_test_block([bip113tx])])
|
self.send_blocks([self.create_test_block([bip113tx])])
|
||||||
|
@ -465,6 +472,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
|
||||||
time_txs = []
|
time_txs = []
|
||||||
for tx in [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if not tx['sdf'] and tx['stf']]:
|
for tx in [tx['tx'] for tx in bip112txs_vary_OP_CSV_v2 if not tx['sdf'] and tx['stf']]:
|
||||||
tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME | SEQ_TYPE_FLAG
|
tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME | SEQ_TYPE_FLAG
|
||||||
|
self.miniwallet.sign_tx(tx)
|
||||||
tx.rehash()
|
tx.rehash()
|
||||||
time_txs.append(tx)
|
time_txs.append(tx)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue