|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -# Copyright (c) 2015-2018 The Bitcoin Core developers |
| 2 | +# Copyright (c) 2015-2019 The Bitcoin Core developers |
3 | 3 | # Distributed under the MIT software license, see the accompanying
|
4 | 4 | # file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
5 | 5 | """Test block processing."""
|
@@ -137,20 +137,29 @@ def run_test(self):
|
137 | 137 | for TxTemplate in invalid_txs.iter_all_templates():
|
138 | 138 | template = TxTemplate(spend_tx=attempt_spend_tx)
|
139 | 139 |
|
140 |
| - # Something about the serialization code for missing inputs creates |
141 |
| - # a different hash in the test client than on bitcoind, resulting |
142 |
| - # in a mismatching merkle root during block validation. |
143 |
| - # Skip until we figure out what's going on. |
144 |
| - if TxTemplate == invalid_txs.InputMissing: |
145 |
| - continue |
146 | 140 | if template.valid_in_block:
|
147 | 141 | continue
|
148 | 142 |
|
149 | 143 | self.log.info("Reject block with invalid tx: %s", TxTemplate.__name__)
|
150 | 144 | blockname = "for_invalid.%s" % TxTemplate.__name__
|
151 | 145 | badblock = self.next_block(blockname)
|
152 | 146 | badtx = template.get_tx()
|
153 |
| - self.sign_tx(badtx, attempt_spend_tx) |
| 147 | + if TxTemplate != invalid_txs.InputMissing: |
| 148 | + self.sign_tx(badtx, attempt_spend_tx) |
| 149 | + else: |
| 150 | + # Segwit is active in regtest at this point, so to deserialize a |
| 151 | + # transaction without any inputs correctly, we set the outputs |
| 152 | + # to an empty list. This is a hack, as the serialization of an |
| 153 | + # empty list of outputs is deserialized as flags==0 and thus |
| 154 | + # deserialization of the outputs is skipped. |
| 155 | + # A policy check requires "loose" txs to be of a minimum size, |
| 156 | + # so vtx is not set to be empty in the TxTemplate class and we |
| 157 | + # only apply the workaround where txs are not "loose", i.e. in |
| 158 | + # blocks. |
| 159 | + # |
| 160 | + # The workaround has the purpose that both sides calculate |
| 161 | + # the same tx hash in the merkle tree |
| 162 | + badtx.vout = [] |
154 | 163 | badtx.rehash()
|
155 | 164 | badblock = self.update_block(blockname, [badtx])
|
156 | 165 | self.sync_blocks(
|
|
0 commit comments