Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_block.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2017 The Bitcoin Core developers | # Copyright (c) 2015-2017 The Bitcoin Core developers | ||||
# Copyright (c) 2017 The Bitcoin developers | # Copyright (c) 2019 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
"""Test block processing.""" | """Test block processing.""" | ||||
import copy | import copy | ||||
import struct | import struct | ||||
import time | import time | ||||
from test_framework.blocktools import ( | from test_framework.blocktools import ( | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# txns. | # txns. | ||||
attempt_spend_tx = out[2] | attempt_spend_tx = out[2] | ||||
# Submit blocks for rejection, each of which contains a single transaction | # Submit blocks for rejection, each of which contains a single transaction | ||||
# (aside from coinbase) which should be considered invalid. | # (aside from coinbase) which should be considered invalid. | ||||
for TxTemplate in invalid_txs.iter_all_templates(): | for TxTemplate in invalid_txs.iter_all_templates(): | ||||
template = TxTemplate(spend_tx=attempt_spend_tx) | template = TxTemplate(spend_tx=attempt_spend_tx) | ||||
# Something about the serialization code for missing inputs creates | |||||
# a different hash in the test client than on bitcoind, resulting | |||||
# in a mismatching merkle root during block validation. | |||||
# Skip until we figure out what's going on. | |||||
if TxTemplate == invalid_txs.InputMissing: | |||||
continue | |||||
if template.valid_in_block: | if template.valid_in_block: | ||||
continue | continue | ||||
self.log.info( | self.log.info( | ||||
"Reject block with invalid tx: %s", | "Reject block with invalid tx: %s", | ||||
TxTemplate.__name__) | TxTemplate.__name__) | ||||
blockname = "for_invalid.{}".format(TxTemplate.__name__) | blockname = "for_invalid.{}".format(TxTemplate.__name__) | ||||
badblock = self.next_block(blockname) | badblock = self.next_block(blockname) | ||||
badtx = template.get_tx() | badtx = template.get_tx() | ||||
if TxTemplate != invalid_txs.InputMissing: | |||||
self.sign_tx(badtx, attempt_spend_tx) | self.sign_tx(badtx, attempt_spend_tx) | ||||
badtx.rehash() | badtx.rehash() | ||||
badblock = self.update_block(blockname, [badtx]) | badblock = self.update_block(blockname, [badtx]) | ||||
self.send_blocks( | self.send_blocks( | ||||
[badblock], success=False, | [badblock], success=False, | ||||
reject_reason=( | reject_reason=( | ||||
template.block_reject_reason or template.reject_reason), | template.block_reject_reason or template.reject_reason), | ||||
reconnect=True, timeout=2) | reconnect=True, timeout=2) | ||||
▲ Show 20 Lines • Show All 1,104 Lines • Show Last 20 Lines |