mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-16 21:20:43 +02:00
[tests] fix flake8 nits in feature_csv_activation.py
This commit is contained in:
parent
00d1680498
commit
6f7f5bc002
@ -42,16 +42,25 @@ bip112txs_vary_OP_CSV - 16 txs with nSequence = 10 evaluated against varying {re
|
|||||||
bip112txs_vary_OP_CSV_9 - 16 txs with nSequence = 9 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP
|
bip112txs_vary_OP_CSV_9 - 16 txs with nSequence = 9 evaluated against varying {relative_locktimes of 10} OP_CSV OP_DROP
|
||||||
bip112tx_special - test negative argument to OP_CSV
|
bip112tx_special - test negative argument to OP_CSV
|
||||||
"""
|
"""
|
||||||
|
from decimal import Decimal
|
||||||
from test_framework.test_framework import ComparisonTestFramework
|
|
||||||
from test_framework.util import *
|
|
||||||
from test_framework.mininode import ToHex, CTransaction, network_thread_start
|
|
||||||
from test_framework.blocktools import create_coinbase, create_block
|
|
||||||
from test_framework.comptool import TestInstance, TestManager
|
|
||||||
from test_framework.script import *
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from test_framework.blocktools import create_coinbase, create_block
|
||||||
|
from test_framework.comptool import TestInstance, TestManager
|
||||||
|
from test_framework.mininode import ToHex, CTransaction, network_thread_start
|
||||||
|
from test_framework.script import (
|
||||||
|
CScript,
|
||||||
|
OP_CHECKSEQUENCEVERIFY,
|
||||||
|
OP_DROP,
|
||||||
|
)
|
||||||
|
from test_framework.test_framework import ComparisonTestFramework
|
||||||
|
from test_framework.util import (
|
||||||
|
assert_equal,
|
||||||
|
get_bip9_status,
|
||||||
|
hex_str_to_bytes,
|
||||||
|
)
|
||||||
|
|
||||||
base_relative_locktime = 10
|
base_relative_locktime = 10
|
||||||
seq_disable_flag = 1 << 31
|
seq_disable_flag = 1 << 31
|
||||||
seq_random_high_bit = 1 << 25
|
seq_random_high_bit = 1 << 25
|
||||||
@ -206,12 +215,12 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
self.nodes[0].setmocktime(0) # set time back to present so yielded blocks aren't in the future as we advance last_block_time
|
self.nodes[0].setmocktime(0) # set time back to present so yielded blocks aren't in the future as we advance last_block_time
|
||||||
self.tipheight = 82 # height of the next block to build
|
self.tipheight = 82 # height of the next block to build
|
||||||
self.last_block_time = long_past_time
|
self.last_block_time = long_past_time
|
||||||
self.tip = int("0x" + self.nodes[0].getbestblockhash(), 0)
|
self.tip = int(self.nodes[0].getbestblockhash(), 16)
|
||||||
self.nodeaddress = self.nodes[0].getnewaddress()
|
self.nodeaddress = self.nodes[0].getnewaddress()
|
||||||
|
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'defined')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'defined')
|
||||||
test_blocks = self.generate_blocks(61, 4)
|
test_blocks = self.generate_blocks(61, 4)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 1
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
# Advanced from DEFINED to STARTED, height = 143
|
# Advanced from DEFINED to STARTED, height = 143
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'started')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'started')
|
||||||
|
|
||||||
@ -221,7 +230,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
test_blocks = self.generate_blocks(20, 4, test_blocks) # 0x00000004 (signalling not)
|
test_blocks = self.generate_blocks(20, 4, test_blocks) # 0x00000004 (signalling not)
|
||||||
test_blocks = self.generate_blocks(50, 536871169, test_blocks) # 0x20000101 (signalling ready)
|
test_blocks = self.generate_blocks(50, 536871169, test_blocks) # 0x20000101 (signalling ready)
|
||||||
test_blocks = self.generate_blocks(24, 536936448, test_blocks) # 0x20010000 (signalling not)
|
test_blocks = self.generate_blocks(24, 536936448, test_blocks) # 0x20010000 (signalling not)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 2
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
# Failed to advance past STARTED, height = 287
|
# Failed to advance past STARTED, height = 287
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'started')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'started')
|
||||||
|
|
||||||
@ -231,15 +240,16 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
test_blocks = self.generate_blocks(26, 4, test_blocks) # 0x00000004 (signalling not)
|
test_blocks = self.generate_blocks(26, 4, test_blocks) # 0x00000004 (signalling not)
|
||||||
test_blocks = self.generate_blocks(50, 536871169, test_blocks) # 0x20000101 (signalling ready)
|
test_blocks = self.generate_blocks(50, 536871169, test_blocks) # 0x20000101 (signalling ready)
|
||||||
test_blocks = self.generate_blocks(10, 536936448, test_blocks) # 0x20010000 (signalling not)
|
test_blocks = self.generate_blocks(10, 536936448, test_blocks) # 0x20010000 (signalling not)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 3
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
# Advanced from STARTED to LOCKED_IN, height = 431
|
# Advanced from STARTED to LOCKED_IN, height = 431
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'locked_in')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'locked_in')
|
||||||
|
|
||||||
# 140 more version 4 blocks
|
# 140 more version 4 blocks
|
||||||
test_blocks = self.generate_blocks(140, 4)
|
test_blocks = self.generate_blocks(140, 4)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 4
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
### Inputs at height = 572
|
# Inputs at height = 572
|
||||||
|
#
|
||||||
# Put inputs for all tests in the chain at height 572 (tip now = 571) (time increases by 600s per block)
|
# Put inputs for all tests in the chain at height 572 (tip now = 571) (time increases by 600s per block)
|
||||||
# Note we reuse inputs for v1 and v2 txs so must test these separately
|
# Note we reuse inputs for v1 and v2 txs so must test these separately
|
||||||
# 16 normal inputs
|
# 16 normal inputs
|
||||||
@ -268,14 +278,14 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
self.nodes[0].setmocktime(self.last_block_time + 600)
|
self.nodes[0].setmocktime(self.last_block_time + 600)
|
||||||
inputblockhash = self.nodes[0].generate(1)[0] # 1 block generated for inputs to be in chain at height 572
|
inputblockhash = self.nodes[0].generate(1)[0] # 1 block generated for inputs to be in chain at height 572
|
||||||
self.nodes[0].setmocktime(0)
|
self.nodes[0].setmocktime(0)
|
||||||
self.tip = int("0x" + inputblockhash, 0)
|
self.tip = int(inputblockhash, 16)
|
||||||
self.tipheight += 1
|
self.tipheight += 1
|
||||||
self.last_block_time += 600
|
self.last_block_time += 600
|
||||||
assert_equal(len(self.nodes[0].getblock(inputblockhash, True)["tx"]), 82 + 1)
|
assert_equal(len(self.nodes[0].getblock(inputblockhash, True)["tx"]), 82 + 1)
|
||||||
|
|
||||||
# 2 more version 4 blocks
|
# 2 more version 4 blocks
|
||||||
test_blocks = self.generate_blocks(2, 4)
|
test_blocks = self.generate_blocks(2, 4)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 5
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
# Not yet advanced to ACTIVE, height = 574 (will activate for block 576, not 575)
|
# Not yet advanced to ACTIVE, height = 574 (will activate for block 576, not 575)
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'locked_in')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'locked_in')
|
||||||
|
|
||||||
@ -330,7 +340,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
# try BIP 112 with seq=9 txs
|
# try BIP 112 with seq=9 txs
|
||||||
success_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v1))
|
success_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v1))
|
||||||
success_txs.extend(all_rlt_txs(bip112txs_vary_OP_CSV_9_v1))
|
success_txs.extend(all_rlt_txs(bip112txs_vary_OP_CSV_9_v1))
|
||||||
yield TestInstance([[self.create_test_block(success_txs), True]]) # 6
|
yield TestInstance([[self.create_test_block(success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
### Version 2 txs ###
|
### Version 2 txs ###
|
||||||
@ -348,16 +358,14 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
# try BIP 112 with seq=9 txs
|
# try BIP 112 with seq=9 txs
|
||||||
success_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2))
|
success_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2))
|
||||||
success_txs.extend(all_rlt_txs(bip112txs_vary_OP_CSV_9_v2))
|
success_txs.extend(all_rlt_txs(bip112txs_vary_OP_CSV_9_v2))
|
||||||
yield TestInstance([[self.create_test_block(success_txs), True]]) # 7
|
yield TestInstance([[self.create_test_block(success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
|
|
||||||
# 1 more version 4 block to get us to height 575 so the fork should now be active for the next block
|
# 1 more version 4 block to get us to height 575 so the fork should now be active for the next block
|
||||||
test_blocks = self.generate_blocks(1, 4)
|
test_blocks = self.generate_blocks(1, 4)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 8
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'active')
|
assert_equal(get_bip9_status(self.nodes[0], 'csv')['status'], 'active')
|
||||||
|
|
||||||
|
|
||||||
#################################
|
#################################
|
||||||
### After Soft Forks Activate ###
|
### After Soft Forks Activate ###
|
||||||
#################################
|
#################################
|
||||||
@ -368,26 +376,26 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
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
|
||||||
bip113signed2 = self.sign_transaction(self.nodes[0], bip113tx_v2)
|
bip113signed2 = self.sign_transaction(self.nodes[0], bip113tx_v2)
|
||||||
for bip113tx in [bip113signed1, bip113signed2]:
|
for bip113tx in [bip113signed1, bip113signed2]:
|
||||||
yield TestInstance([[self.create_test_block([bip113tx]), False]]) # 9,10
|
yield TestInstance([[self.create_test_block([bip113tx]), False]])
|
||||||
# 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
|
||||||
bip113signed1 = self.sign_transaction(self.nodes[0], bip113tx_v1)
|
bip113signed1 = self.sign_transaction(self.nodes[0], bip113tx_v1)
|
||||||
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
|
||||||
bip113signed2 = self.sign_transaction(self.nodes[0], bip113tx_v2)
|
bip113signed2 = self.sign_transaction(self.nodes[0], bip113tx_v2)
|
||||||
for bip113tx in [bip113signed1, bip113signed2]:
|
for bip113tx in [bip113signed1, bip113signed2]:
|
||||||
yield TestInstance([[self.create_test_block([bip113tx]), True]]) # 11,12
|
yield TestInstance([[self.create_test_block([bip113tx]), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
# Next block height = 580 after 4 blocks of random version
|
# Next block height = 580 after 4 blocks of random version
|
||||||
test_blocks = self.generate_blocks(4, 1234)
|
test_blocks = self.generate_blocks(4, 1234)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 13
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
### BIP 68 ###
|
### BIP 68 ###
|
||||||
### Version 1 txs ###
|
### Version 1 txs ###
|
||||||
# All still pass
|
# All still pass
|
||||||
success_txs = []
|
success_txs = []
|
||||||
success_txs.extend(all_rlt_txs(bip68txs_v1))
|
success_txs.extend(all_rlt_txs(bip68txs_v1))
|
||||||
yield TestInstance([[self.create_test_block(success_txs), True]]) # 14
|
yield TestInstance([[self.create_test_block(success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
### Version 2 txs ###
|
### Version 2 txs ###
|
||||||
@ -397,7 +405,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
for b22 in range(2):
|
for b22 in range(2):
|
||||||
for b18 in range(2):
|
for b18 in range(2):
|
||||||
bip68success_txs.append(bip68txs_v2[1][b25][b22][b18])
|
bip68success_txs.append(bip68txs_v2[1][b25][b22][b18])
|
||||||
yield TestInstance([[self.create_test_block(bip68success_txs), True]]) # 15
|
yield TestInstance([[self.create_test_block(bip68success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
# All txs without flag fail as we are at delta height = 8 < 10 and delta time = 8 * 600 < 10 * 512
|
# All txs without flag fail as we are at delta height = 8 < 10 and delta time = 8 * 600 < 10 * 512
|
||||||
bip68timetxs = []
|
bip68timetxs = []
|
||||||
@ -405,39 +413,38 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
for b18 in range(2):
|
for b18 in range(2):
|
||||||
bip68timetxs.append(bip68txs_v2[0][b25][1][b18])
|
bip68timetxs.append(bip68txs_v2[0][b25][1][b18])
|
||||||
for tx in bip68timetxs:
|
for tx in bip68timetxs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 16 - 19
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
bip68heighttxs = []
|
bip68heighttxs = []
|
||||||
for b25 in range(2):
|
for b25 in range(2):
|
||||||
for b18 in range(2):
|
for b18 in range(2):
|
||||||
bip68heighttxs.append(bip68txs_v2[0][b25][0][b18])
|
bip68heighttxs.append(bip68txs_v2[0][b25][0][b18])
|
||||||
for tx in bip68heighttxs:
|
for tx in bip68heighttxs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 20 - 23
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
|
|
||||||
# Advance one block to 581
|
# Advance one block to 581
|
||||||
test_blocks = self.generate_blocks(1, 1234)
|
test_blocks = self.generate_blocks(1, 1234)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 24
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
# Height txs should fail and time txs should now pass 9 * 600 > 10 * 512
|
# Height txs should fail and time txs should now pass 9 * 600 > 10 * 512
|
||||||
bip68success_txs.extend(bip68timetxs)
|
bip68success_txs.extend(bip68timetxs)
|
||||||
yield TestInstance([[self.create_test_block(bip68success_txs), True]]) # 25
|
yield TestInstance([[self.create_test_block(bip68success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
for tx in bip68heighttxs:
|
for tx in bip68heighttxs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 26 - 29
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
|
|
||||||
# Advance one block to 582
|
# Advance one block to 582
|
||||||
test_blocks = self.generate_blocks(1, 1234)
|
test_blocks = self.generate_blocks(1, 1234)
|
||||||
yield TestInstance(test_blocks, sync_every_block=False) # 30
|
yield TestInstance(test_blocks, sync_every_block=False)
|
||||||
|
|
||||||
# All BIP 68 txs should pass
|
# All BIP 68 txs should pass
|
||||||
bip68success_txs.extend(bip68heighttxs)
|
bip68success_txs.extend(bip68heighttxs)
|
||||||
yield TestInstance([[self.create_test_block(bip68success_txs), True]]) # 31
|
yield TestInstance([[self.create_test_block(bip68success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
|
|
||||||
### BIP 112 ###
|
### BIP 112 ###
|
||||||
### Version 1 txs ###
|
### Version 1 txs ###
|
||||||
# -1 OP_CSV tx should fail
|
# -1 OP_CSV tx should fail
|
||||||
yield TestInstance([[self.create_test_block([bip112tx_special_v1]), False]]) #32
|
yield TestInstance([[self.create_test_block([bip112tx_special_v1]), False]])
|
||||||
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 1 txs should still pass
|
||||||
success_txs = []
|
success_txs = []
|
||||||
for b25 in range(2):
|
for b25 in range(2):
|
||||||
@ -445,7 +452,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
for b18 in range(2):
|
for b18 in range(2):
|
||||||
success_txs.append(bip112txs_vary_OP_CSV_v1[1][b25][b22][b18])
|
success_txs.append(bip112txs_vary_OP_CSV_v1[1][b25][b22][b18])
|
||||||
success_txs.append(bip112txs_vary_OP_CSV_9_v1[1][b25][b22][b18])
|
success_txs.append(bip112txs_vary_OP_CSV_9_v1[1][b25][b22][b18])
|
||||||
yield TestInstance([[self.create_test_block(success_txs), True]]) # 33
|
yield TestInstance([[self.create_test_block(success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV, version 1 txs should now fail
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV, version 1 txs should now fail
|
||||||
@ -459,11 +466,11 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
fail_txs.append(bip112txs_vary_OP_CSV_9_v1[0][b25][b22][b18])
|
fail_txs.append(bip112txs_vary_OP_CSV_9_v1[0][b25][b22][b18])
|
||||||
|
|
||||||
for tx in fail_txs:
|
for tx in fail_txs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 34 - 81
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
|
|
||||||
### Version 2 txs ###
|
### Version 2 txs ###
|
||||||
# -1 OP_CSV tx should fail
|
# -1 OP_CSV tx should fail
|
||||||
yield TestInstance([[self.create_test_block([bip112tx_special_v2]), False]]) #82
|
yield TestInstance([[self.create_test_block([bip112tx_special_v2]), False]])
|
||||||
|
|
||||||
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in argument to OP_CSV, version 2 txs should pass (all sequence locks are met)
|
||||||
success_txs = []
|
success_txs = []
|
||||||
@ -473,10 +480,11 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
success_txs.append(bip112txs_vary_OP_CSV_v2[1][b25][b22][b18]) # 8/16 of vary_OP_CSV
|
success_txs.append(bip112txs_vary_OP_CSV_v2[1][b25][b22][b18]) # 8/16 of vary_OP_CSV
|
||||||
success_txs.append(bip112txs_vary_OP_CSV_9_v2[1][b25][b22][b18]) # 8/16 of vary_OP_CSV_9
|
success_txs.append(bip112txs_vary_OP_CSV_9_v2[1][b25][b22][b18]) # 8/16 of vary_OP_CSV_9
|
||||||
|
|
||||||
yield TestInstance([[self.create_test_block(success_txs), True]]) # 83
|
yield TestInstance([[self.create_test_block(success_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
## SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV for all remaining txs ##
|
# SEQUENCE_LOCKTIME_DISABLE_FLAG is unset in argument to OP_CSV for all remaining txs ##
|
||||||
|
|
||||||
# All txs with nSequence 9 should fail either due to earlier mismatch or failing the CSV check
|
# All txs with nSequence 9 should fail either due to earlier mismatch or failing the CSV check
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2)) # 16/16 of vary_nSequence_9
|
fail_txs.extend(all_rlt_txs(bip112txs_vary_nSequence_9_v2)) # 16/16 of vary_nSequence_9
|
||||||
@ -486,7 +494,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
fail_txs.append(bip112txs_vary_OP_CSV_9_v2[0][b25][b22][b18]) # 16/16 of vary_OP_CSV_9
|
fail_txs.append(bip112txs_vary_OP_CSV_9_v2[0][b25][b22][b18]) # 16/16 of vary_OP_CSV_9
|
||||||
|
|
||||||
for tx in fail_txs:
|
for tx in fail_txs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 84 - 107
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
|
|
||||||
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
|
# If SEQUENCE_LOCKTIME_DISABLE_FLAG is set in nSequence, tx should fail
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
@ -495,7 +503,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
for b18 in range(2):
|
for b18 in range(2):
|
||||||
fail_txs.append(bip112txs_vary_nSequence_v2[1][b25][b22][b18]) # 8/16 of vary_nSequence
|
fail_txs.append(bip112txs_vary_nSequence_v2[1][b25][b22][b18]) # 8/16 of vary_nSequence
|
||||||
for tx in fail_txs:
|
for tx in fail_txs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 108-115
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
|
|
||||||
# If sequencelock types mismatch, tx should fail
|
# If sequencelock types mismatch, tx should fail
|
||||||
fail_txs = []
|
fail_txs = []
|
||||||
@ -504,7 +512,7 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
fail_txs.append(bip112txs_vary_nSequence_v2[0][b25][1][b18]) # 12/16 of vary_nSequence
|
fail_txs.append(bip112txs_vary_nSequence_v2[0][b25][1][b18]) # 12/16 of vary_nSequence
|
||||||
fail_txs.append(bip112txs_vary_OP_CSV_v2[0][b25][1][b18]) # 12/16 of vary_OP_CSV
|
fail_txs.append(bip112txs_vary_OP_CSV_v2[0][b25][1][b18]) # 12/16 of vary_OP_CSV
|
||||||
for tx in fail_txs:
|
for tx in fail_txs:
|
||||||
yield TestInstance([[self.create_test_block([tx]), False]]) # 116-123
|
yield TestInstance([[self.create_test_block([tx]), False]])
|
||||||
|
|
||||||
# Remaining txs should pass, just test masking works properly
|
# Remaining txs should pass, just test masking works properly
|
||||||
success_txs = []
|
success_txs = []
|
||||||
@ -523,12 +531,10 @@ class BIP68_112_113Test(ComparisonTestFramework):
|
|||||||
tx.vin[0].nSequence = base_relative_locktime | seq_type_flag
|
tx.vin[0].nSequence = base_relative_locktime | seq_type_flag
|
||||||
signtx = self.sign_transaction(self.nodes[0], tx)
|
signtx = self.sign_transaction(self.nodes[0], tx)
|
||||||
time_txs.append(signtx)
|
time_txs.append(signtx)
|
||||||
yield TestInstance([[self.create_test_block(time_txs), True]]) # 125
|
yield TestInstance([[self.create_test_block(time_txs), True]])
|
||||||
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
|
||||||
|
|
||||||
### Missing aspects of test
|
# TODO: Test empty stack fails
|
||||||
## Testing empty stack fails
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
BIP68_112_113Test().main()
|
BIP68_112_113Test().main()
|
||||||
|
Loading…
Reference in New Issue
Block a user