Skip to content

Commit fac4e73

Browse files
author
MarcoFalke
committed
test: Run invalid_txs.InputMissing test in feature_block
1 parent f7e182a commit fac4e73

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/wallet/test/wallet_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2012-2018 The Bitcoin Core developers
1+
// Copyright (c) 2012-2019 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

@@ -47,7 +47,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup)
4747

4848
auto locked_chain = chain->lock();
4949

50-
// Verify ScanForWalletTransactions accomodates a null start block.
50+
// Verify ScanForWalletTransactions accommodates a null start block.
5151
{
5252
CWallet wallet(*chain, WalletLocation(), WalletDatabase::CreateDummy());
5353
AddKey(wallet, coinbaseKey);

test/functional/feature_block.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2015-2018 The Bitcoin Core developers
2+
# Copyright (c) 2015-2019 The Bitcoin Core developers
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test block processing."""
@@ -137,20 +137,29 @@ def run_test(self):
137137
for TxTemplate in invalid_txs.iter_all_templates():
138138
template = TxTemplate(spend_tx=attempt_spend_tx)
139139

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
146140
if template.valid_in_block:
147141
continue
148142

149143
self.log.info("Reject block with invalid tx: %s", TxTemplate.__name__)
150144
blockname = "for_invalid.%s" % TxTemplate.__name__
151145
badblock = self.next_block(blockname)
152146
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 = []
154163
badtx.rehash()
155164
badblock = self.update_block(blockname, [badtx])
156165
self.sync_blocks(

0 commit comments

Comments
 (0)