27 initialize_chain_clean,
29 from .authproxy
import AuthServiceProxy, JSONRPCException
36 for node
in self.
nodes:
44 print(
"Initializing test directory "+self.options.tmpdir)
71 Split the network of four nodes into nodes 0/1 and 2/3. 90 Join the (previously split) network halves together. 100 parser = optparse.OptionParser(usage=
"%prog [options]")
101 parser.add_option(
"--nocleanup", dest=
"nocleanup", default=
False, action=
"store_true",
102 help=
"Leave dashds and test.* datadir on exit or error")
103 parser.add_option(
"--noshutdown", dest=
"noshutdown", default=
False, action=
"store_true",
104 help=
"Don't stop dashds after the test execution")
105 parser.add_option(
"--srcdir", dest=
"srcdir", default=
"../../src",
106 help=
"Source directory containing dashd/dash-cli (default: %default)")
107 parser.add_option(
"--tmpdir", dest=
"tmpdir", default=tempfile.mkdtemp(prefix=
"test"),
108 help=
"Root directory for datadirs")
109 parser.add_option(
"--tracerpc", dest=
"trace_rpc", default=
False, action=
"store_true",
110 help=
"Print out all RPC calls as they are made")
111 parser.add_option(
"--coveragedir", dest=
"coveragedir",
112 help=
"Write tested RPC commands into this directory")
114 (self.options, self.args) = parser.parse_args()
116 if self.options.trace_rpc:
118 logging.basicConfig(level=logging.DEBUG)
120 if self.options.coveragedir:
123 os.environ[
'PATH'] = self.options.srcdir+
":"+self.options.srcdir+
"/qt:"+os.environ[
'PATH']
129 if not os.path.isdir(self.options.tmpdir):
130 os.makedirs(self.options.tmpdir)
139 except JSONRPCException
as e:
140 print(
"JSONRPC error: "+e.error[
'message'])
141 traceback.print_tb(sys.exc_info()[2])
142 except AssertionError
as e:
143 print(
"Assertion failed: "+ str(e))
144 traceback.print_tb(sys.exc_info()[2])
145 except Exception
as e:
146 print(
"Unexpected exception caught during testing: " + repr(e))
147 traceback.print_tb(sys.exc_info()[2])
149 if not self.options.noshutdown:
150 print(
"Stopping nodes")
154 print(
"Note: dashds were not stopped and may still be running")
156 if not self.options.nocleanup
and not self.options.noshutdown:
158 shutil.rmtree(self.options.tmpdir)
161 print(
"Tests successful")
181 parser.add_option(
"--testbinary", dest=
"testbinary",
182 default=os.getenv(
"DASHD",
"dashd"),
183 help=
"bitcoind binary to test")
184 parser.add_option(
"--refbinary", dest=
"refbinary",
185 default=os.getenv(
"DASHD",
"dashd"),
186 help=
"bitcoind binary to use for reference nodes (if any)")
189 print "Initializing test directory "+self.options.tmpdir
195 extra_args=[[
'-debug',
'-whitelist=127.0.0.1']] * self.
num_nodes,
196 binary=[self.options.testbinary] +
197 [self.options.refbinary]*(self.
num_nodes-1))
def initialize_chain(test_dir)
def setup_network(self, split=False)
def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None)
def check_json_precision()
def add_options(self, parser)
def add_options(self, parser)
def sync_mempools(rpc_connections, wait=1)
def initialize_chain_clean(test_dir, num_nodes)
def sync_blocks(rpc_connections, wait=1)
def enable_coverage(dirname)
def assert_equal(thing1, thing2)
def connect_nodes_bi(nodes, a, b)