14
14
import sys
15
15
import tempfile
16
16
import time
17
+ import traceback
17
18
18
19
from .util import (
19
20
PortSeed ,
@@ -77,7 +78,7 @@ def add_options(self, parser):
77
78
pass
78
79
79
80
def setup_chain (self ):
80
- self .log .info ("Initializing test directory " + self .options .tmpdir )
81
+ self .log .info ("Initializing test directory " + self .options .tmpdir )
81
82
if self .setup_clean_chain :
82
83
self ._initialize_chain_clean (self .options .tmpdir , self .num_nodes )
83
84
else :
@@ -111,9 +112,9 @@ def main(self):
111
112
help = "Leave bitcoinds and test.* datadir on exit or error" )
112
113
parser .add_option ("--noshutdown" , dest = "noshutdown" , default = False , action = "store_true" ,
113
114
help = "Don't stop bitcoinds after the test execution" )
114
- parser .add_option ("--srcdir" , dest = "srcdir" , default = os .path .normpath (os .path .dirname (os .path .realpath (__file__ ))+ "/../../../src" ),
115
+ parser .add_option ("--srcdir" , dest = "srcdir" , default = os .path .normpath (os .path .dirname (os .path .realpath (__file__ )) + "/../../../src" ),
115
116
help = "Source directory containing bitcoind/bitcoin-cli (default: %default)" )
116
- parser .add_option ("--cachedir" , dest = "cachedir" , default = os .path .normpath (os .path .dirname (os .path .realpath (__file__ ))+ "/../../cache" ),
117
+ parser .add_option ("--cachedir" , dest = "cachedir" , default = os .path .normpath (os .path .dirname (os .path .realpath (__file__ )) + "/../../cache" ),
117
118
help = "Directory for caching pregenerated datadirs" )
118
119
parser .add_option ("--tmpdir" , dest = "tmpdir" , help = "Root directory for datadirs" )
119
120
parser .add_option ("-l" , "--loglevel" , dest = "loglevel" , default = "INFO" ,
@@ -134,7 +135,7 @@ def main(self):
134
135
135
136
PortSeed .n = self .options .port_seed
136
137
137
- os .environ ['PATH' ] = self .options .srcdir + ":" + self .options .srcdir + "/qt:" + os .environ ['PATH' ]
138
+ os .environ ['PATH' ] = self .options .srcdir + ":" + self .options .srcdir + "/qt:" + os .environ ['PATH' ]
138
139
139
140
check_json_precision ()
140
141
@@ -188,7 +189,7 @@ def main(self):
188
189
for fn in filenames :
189
190
try :
190
191
with open (fn , 'r' ) as f :
191
- print ("From" , fn , ":" )
192
+ print ("From" , fn , ":" )
192
193
print ("" .join (deque (f , MAX_LINES_TO_PRINT )))
193
194
except OSError :
194
195
print ("Opening file %s failed." % fn )
@@ -257,7 +258,7 @@ def _start_logging(self):
257
258
ll = int (self .options .loglevel ) if self .options .loglevel .isdigit () else self .options .loglevel .upper ()
258
259
ch .setLevel (ll )
259
260
# Format logs the same as bitcoind's debug.log with microprecision (so log files can be concatenated and sorted)
260
- formatter = logging .Formatter (fmt = '%(asctime)s.%(msecs)03d000 %(name)s (%(levelname)s): %(message)s' , datefmt = '%Y-%m-%d %H:%M:%S' )
261
+ formatter = logging .Formatter (fmt = '%(asctime)s.%(msecs)03d000 %(name)s (%(levelname)s): %(message)s' , datefmt = '%Y-%m-%d %H:%M:%S' )
261
262
formatter .converter = time .gmtime
262
263
fh .setFormatter (formatter )
263
264
ch .setFormatter (formatter )
@@ -354,18 +355,13 @@ def _initialize_chain_clean(self, test_dir, num_nodes):
354
355
for i in range (num_nodes ):
355
356
initialize_datadir (test_dir , i )
356
357
357
- # Test framework for doing p2p comparison testing, which sets up some bitcoind
358
- # binaries:
359
- # 1 binary: test binary
360
- # 2 binaries: 1 test binary, 1 ref binary
361
- # n>2 binaries: 1 test binary, n-1 ref binaries
362
-
363
- class SkipTest (Exception ):
364
- """This exception is raised to skip a test"""
365
- def __init__ (self , message ):
366
- self .message = message
367
-
368
358
class ComparisonTestFramework (BitcoinTestFramework ):
359
+ """Test framework for doing p2p comparison testing
360
+
361
+ Sets up some bitcoind binaries:
362
+ - 1 binary: test binary
363
+ - 2 binaries: 1 test binary, 1 ref binary
364
+ - n>2 binaries: 1 test binary, n-1 ref binaries"""
369
365
370
366
def __init__ (self ):
371
367
super ().__init__ ()
@@ -387,4 +383,9 @@ def setup_network(self):
387
383
self .nodes = self .start_nodes (
388
384
self .num_nodes , self .options .tmpdir , extra_args ,
389
385
binary = [self .options .testbinary ] +
390
- [self .options .refbinary ]* (self .num_nodes - 1 ))
386
+ [self .options .refbinary ] * (self .num_nodes - 1 ))
387
+
388
+ class SkipTest (Exception ):
389
+ """This exception is raised to skip a test"""
390
+ def __init__ (self , message ):
391
+ self .message = message
0 commit comments