Merge #20283: test: Only try witness deser when checking for witness deser failure

fae45c34d1 test: Only try witness deserialize when checking for witness deserialize failure (MarcoFalke)

Pull request description:

  Witness deserialize will fail always. (This is what the test is checking for)

  Consequently, non-witness deserialize is also tried, and it might succeed accidentally. Avoid that by not trying non-witness deserialize.

  Fixes #20249

ACKs for top commit:
  jnewbery:
    utACK fae45c34d1

Tree-SHA512: 45e65b31603e3ca839776a7ed30e363b32eba20dfb67b7b55bff06715876850d4f6ba22f8ea4911a62e1f8ffff395bf187b23c46ddc766516b97057df000deb3
pull/764/head
fanquake 4 years ago
commit 6954e4d16c
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

@ -2097,14 +2097,14 @@ class SegWitTest(BitcoinTestFramework):
raw = self.nodes[0].createrawtransaction([{"txid": unspent['txid'], "vout": unspent['vout']}], {self.nodes[0].getnewaddress(): 1}) raw = self.nodes[0].createrawtransaction([{"txid": unspent['txid'], "vout": unspent['vout']}], {self.nodes[0].getnewaddress(): 1})
tx = FromHex(CTransaction(), raw) tx = FromHex(CTransaction(), raw)
assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, serialize_with_bogus_witness(tx).hex()) assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, hexstring=serialize_with_bogus_witness(tx).hex(), iswitness=True)
with self.nodes[0].assert_debug_log(['Superfluous witness record']): with self.nodes[0].assert_debug_log(['Superfluous witness record']):
self.test_node.send_and_ping(msg_bogus_tx(tx)) self.test_node.send_and_ping(msg_bogus_tx(tx))
raw = self.nodes[0].signrawtransactionwithwallet(raw) raw = self.nodes[0].signrawtransactionwithwallet(raw)
assert raw['complete'] assert raw['complete']
raw = raw['hex'] raw = raw['hex']
tx = FromHex(CTransaction(), raw) tx = FromHex(CTransaction(), raw)
assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, serialize_with_bogus_witness(tx).hex()) assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, hexstring=serialize_with_bogus_witness(tx).hex(), iswitness=True)
with self.nodes[0].assert_debug_log(['Unknown transaction optional data']): with self.nodes[0].assert_debug_log(['Unknown transaction optional data']):
self.test_node.send_and_ping(msg_bogus_tx(tx)) self.test_node.send_and_ping(msg_bogus_tx(tx))

Loading…
Cancel
Save