Skip to content

Commit b7ee5fb

Browse files
fanquakeTom Trevethan
authored andcommitted
Merge bitcoin/bitcoin#33001: test: Do not pass tests on unhandled exceptions
faa3e684118bffa7a98cf76eeeb59243219df900 test: Log KeyboardInterrupt as exception (MarcoFalke) fa30b34026f76a5b8af997152fced2d281782e0d test: Do not pass tests on unhandled exceptions (MarcoFalke) Pull request description: Currently the functional tests are problematic, because they pass, even if they encounter an unhanded exception. Fix this by handling all exceptions: Catch `BaseException` as fallback and mark it as failure. Can be tested via: ```diff diff --git a/test/functional/wallet_disable.py b/test/functional/wallet_disable.py index da6e5d4..ecc41fb041 100755 --- a/test/functional/wallet_disable.py +++ b/test/functional/wallet_disable.py @@ -19,6 +19,7 @@ class DisableWalletTest (BitcoinTestFramework): self.wallet_names = [] def run_test (self): + import sys;sys.exit("fatal error") # Make sure wallet is really disabled assert_raises_rpc_error(-32601, 'Method not found', self.nodes[0].getwalletinfo) x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy') ``` Previously, the test would pass. With this patch, it would fail. ACKs for top commit: enirox001: Looks good to me—ACK faa3e68 stickies-v: re-ACK faa3e684118bffa7a98cf76eeeb59243219df900 pablomartin4btc: tACK faa3e684118bffa7a98cf76eeeb59243219df900 Tree-SHA512: 11ecd5201982e2c776e48d98834b17c15a415306a95524bc702daeba20a316aac797748e9592be8db575597804f149ee7ef104416037cc9e5891758625810e2d
1 parent 1ac1f75 commit b7ee5fb

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3817,7 +3817,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
38173817
// should not call LookupBlockIndex below.
38183818
RemoveBlockRequest(resp.blockhash, pfrom.GetId());
38193819
Misbehaving(pfrom.GetId(), 100, "previous compact block reconstruction attempt failed");
3820-
LogPrint(BCLog::NET, "Peer %d sent compact block transactions multiple times", pfrom.GetId());
3820+
LogPrint(BCLog::NET, "Peer %d sent compact block transactions multiple times\n", pfrom.GetId());
38213821
return;
38223822
}
38233823

test/functional/test_framework/test_framework.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,14 @@ def main(self):
130130
try:
131131
self.setup()
132132
self.run_test()
133-
except JSONRPCException:
134-
self.log.exception("JSONRPC error")
135-
self.success = TestStatus.FAILED
136133
except SkipTest as e:
137134
self.log.warning("Test Skipped: %s" % e.message)
138135
self.success = TestStatus.SKIPPED
139-
except AssertionError:
140-
self.log.exception("Assertion failed")
141-
self.success = TestStatus.FAILED
142-
except KeyError:
143-
self.log.exception("Key error")
144-
self.success = TestStatus.FAILED
145136
except subprocess.CalledProcessError as e:
146-
self.log.exception("Called Process failed with '{}'".format(e.output))
147-
self.success = TestStatus.FAILED
148-
except Exception:
149-
self.log.exception("Unexpected exception caught during testing")
137+
self.log.exception(f"Called Process failed with stdout='{e.stdout}'; stderr='{e.stderr}';")
150138
self.success = TestStatus.FAILED
151-
except KeyboardInterrupt:
152-
self.log.warning("Exiting after keyboard interrupt")
139+
except BaseException:
140+
self.log.exception("Unexpected exception")
153141
self.success = TestStatus.FAILED
154142
finally:
155143
exit_code = self.shutdown()

0 commit comments

Comments
 (0)