Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_csv_activation.py
Show First 20 Lines • Show All 237 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# 82 blocks generated for inputs | # 82 blocks generated for inputs | ||||
self.coinbase_blocks = self.nodes[0].generate(1 + 16 + 2 * 32 + 1) | self.coinbase_blocks = self.nodes[0].generate(1 + 16 + 2 * 32 + 1) | ||||
# Set time back to present so yielded blocks aren't in the future as | # Set time back to present so yielded blocks aren't in the future as | ||||
# we advance last_block_time | # we advance last_block_time | ||||
self.nodes[0].setmocktime(0) | self.nodes[0].setmocktime(0) | ||||
# height of the next block to build | # height of the next block to build | ||||
self.tipheight = 82 | self.tipheight = 82 | ||||
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() | ||||
# CSV is not activated yet. | # CSV is not activated yet. | ||||
assert_equal(get_csv_status(self.nodes[0]), False) | assert_equal(get_csv_status(self.nodes[0]), False) | ||||
# Generate 489 more version 4 blocks | # Generate 489 more version 4 blocks | ||||
test_blocks = self.generate_blocks(489) | test_blocks = self.generate_blocks(489) | ||||
# Test #1 | # Test #1 | ||||
self.sync_blocks(test_blocks) | self.sync_blocks(test_blocks) | ||||
# Still not activated. | # Still not activated. | ||||
assert_equal(get_csv_status(self.nodes[0]), False) | assert_equal(get_csv_status(self.nodes[0]), 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 | ||||
bip68inputs = [] | bip68inputs = [] | ||||
for i in range(16): | for i in range(16): | ||||
bip68inputs.append(send_generic_input_tx( | bip68inputs.append(send_generic_input_tx( | ||||
self.nodes[0], self.coinbase_blocks, self.nodeaddress)) | self.nodes[0], self.coinbase_blocks, self.nodeaddress)) | ||||
Show All 22 Lines | def run_test(self): | ||||
# 1 normal input | # 1 normal input | ||||
bip113input = send_generic_input_tx( | bip113input = send_generic_input_tx( | ||||
self.nodes[0], self.coinbase_blocks, self.nodeaddress) | self.nodes[0], self.coinbase_blocks, self.nodeaddress) | ||||
self.nodes[0].setmocktime(self.last_block_time + 600) | self.nodes[0].setmocktime(self.last_block_time + 600) | ||||
# 1 block generated for inputs to be in chain at height 572 | # 1 block generated for inputs to be in chain at height 572 | ||||
inputblockhash = self.nodes[0].generate(1)[0] | inputblockhash = self.nodes[0].generate(1)[0] | ||||
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( | assert_equal(len(self.nodes[0].getblock( | ||||
inputblockhash, True)["tx"]), 82 + 1) | inputblockhash, True)["tx"]), 82 + 1) | ||||
# 2 more version 4 blocks | # 2 more version 4 blocks | ||||
test_blocks = self.generate_blocks(2) | test_blocks = self.generate_blocks(2) | ||||
# Test #2 | # Test #2 | ||||
▲ Show 20 Lines • Show All 258 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
success_txs += [tx['tx'] | success_txs += [tx['tx'] | ||||
for tx in bip112txs_vary_OP_CSV_9_v2 if tx['sdf']] | for tx in bip112txs_vary_OP_CSV_9_v2 if tx['sdf']] | ||||
# Test #80 | # Test #80 | ||||
self.sync_blocks( | self.sync_blocks( | ||||
[self.create_test_block_spend_utxos(self.nodes[0], success_txs)]) | [self.create_test_block_spend_utxos(self.nodes[0], success_txs)]) | ||||
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 | # All txs with nSequence 9 should fail either due to earlier mismatch | ||||
# or failing the CSV check | # or failing the CSV check | ||||
fail_txs = all_rlt_txs(bip112txs_vary_nSequence_9_v2) | fail_txs = all_rlt_txs(bip112txs_vary_nSequence_9_v2) | ||||
fail_txs += [tx['tx'] | fail_txs += [tx['tx'] | ||||
for tx in bip112txs_vary_OP_CSV_9_v2 if not tx['sdf']] | for tx in bip112txs_vary_OP_CSV_9_v2 if not tx['sdf']] | ||||
for tx in fail_txs: | for tx in fail_txs: | ||||
# Test #81 - Test #104 | # Test #81 - Test #104 | ||||
self.sync_blocks([self.create_test_block_spend_utxos( | self.sync_blocks([self.create_test_block_spend_utxos( | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
raw_tx = spend_tx(self.nodes[0], tx, self.nodeaddress) | raw_tx = spend_tx(self.nodes[0], tx, self.nodeaddress) | ||||
raw_tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME | SEQ_TYPE_FLAG | raw_tx.vin[0].nSequence = BASE_RELATIVE_LOCKTIME | SEQ_TYPE_FLAG | ||||
raw_tx.rehash() | raw_tx.rehash() | ||||
spend_txs.append(raw_tx) | spend_txs.append(raw_tx) | ||||
# Test #126 | # Test #126 | ||||
self.sync_blocks([self.create_test_block(spend_txs)]) | self.sync_blocks([self.create_test_block(spend_txs)]) | ||||
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() |