|
1 | 1 | #!/usr/bin/env python3
|
2 |
| -# Copyright (c) 2017-2018 The Bitcoin Core developers |
| 2 | +# Copyright (c) 2017-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 recovery from a crash during chainstate writing.
|
|
28 | 28 | import errno
|
29 | 29 | import http.client
|
30 | 30 | import random
|
31 |
| -import sys |
32 | 31 | import time
|
33 | 32 |
|
34 | 33 | from test_framework.messages import COIN, COutPoint, CTransaction, CTxIn, CTxOut, ToHex
|
35 | 34 | from test_framework.test_framework import BitcoinTestFramework
|
36 | 35 | from test_framework.util import assert_equal, create_confirmed_utxos, hex_str_to_bytes
|
37 | 36 |
|
38 |
| -HTTP_DISCONNECT_ERRORS = [http.client.CannotSendRequest] |
39 |
| -try: |
40 |
| - HTTP_DISCONNECT_ERRORS.append(http.client.RemoteDisconnected) |
41 |
| -except AttributeError: |
42 |
| - pass |
43 | 37 |
|
44 | 38 | class ChainstateWriteCrashTest(BitcoinTestFramework):
|
45 | 39 | def set_test_params(self):
|
@@ -110,14 +104,7 @@ def submit_block_catch_error(self, node_index, block):
|
110 | 104 | try:
|
111 | 105 | self.nodes[node_index].submitblock(block)
|
112 | 106 | return True
|
113 |
| - except http.client.BadStatusLine as e: |
114 |
| - # Prior to 3.5 BadStatusLine('') was raised for a remote disconnect error. |
115 |
| - if sys.version_info[0] == 3 and sys.version_info[1] < 5 and e.line == "''": |
116 |
| - self.log.debug("node %d submitblock raised exception: %s", node_index, e) |
117 |
| - return False |
118 |
| - else: |
119 |
| - raise |
120 |
| - except tuple(HTTP_DISCONNECT_ERRORS) as e: |
| 107 | + except (http.client.CannotSendRequest, http.client.RemoteDisconnected) as e: |
121 | 108 | self.log.debug("node %d submitblock raised exception: %s", node_index, e)
|
122 | 109 | return False
|
123 | 110 | except OSError as e:
|
|
0 commit comments