@@ -42,7 +42,7 @@ class TestNode():
42
42
To make things easier for the test writer, any unrecognised messages will
43
43
be dispatched to the RPC connection."""
44
44
45
- def __init__ (self , i , dirname , extra_args , rpchost , timewait , binary , stderr , mocktime , coverage_dir ):
45
+ def __init__ (self , i , dirname , extra_args , rpchost , timewait , binary , stderr , mocktime , coverage_dir , use_cli = False ):
46
46
self .index = i
47
47
self .datadir = os .path .join (dirname , "node" + str (i ))
48
48
self .rpchost = rpchost
@@ -62,6 +62,7 @@ def __init__(self, i, dirname, extra_args, rpchost, timewait, binary, stderr, mo
62
62
self .args = [self .binary , "-datadir=" + self .datadir , "-server" , "-keypool=1" , "-discover=0" , "-rest" , "-logtimemicros" , "-debug" , "-debugexclude=libevent" , "-debugexclude=leveldb" , "-mocktime=" + str (mocktime ), "-uacomment=testnode%d" % i ]
63
63
64
64
self .cli = TestNodeCLI (os .getenv ("BITCOINCLI" , "bitcoin-cli" ), self .datadir )
65
+ self .use_cli = use_cli
65
66
66
67
self .running = False
67
68
self .process = None
@@ -73,9 +74,12 @@ def __init__(self, i, dirname, extra_args, rpchost, timewait, binary, stderr, mo
73
74
self .p2ps = []
74
75
75
76
def __getattr__ (self , name ):
76
- """Dispatches any unrecognised messages to the RPC connection."""
77
- assert self .rpc_connected and self .rpc is not None , "Error: no RPC connection"
78
- return getattr (self .rpc , name )
77
+ """Dispatches any unrecognised messages to the RPC connection or a CLI instance."""
78
+ if self .use_cli :
79
+ return getattr (self .cli , name )
80
+ else :
81
+ assert self .rpc_connected and self .rpc is not None , "Error: no RPC connection"
82
+ return getattr (self .rpc , name )
79
83
80
84
def start (self , extra_args = None , stderr = None ):
81
85
"""Start the node."""
@@ -114,10 +118,13 @@ def wait_for_rpc_connection(self):
114
118
raise AssertionError ("Unable to connect to bitcoind" )
115
119
116
120
def get_wallet_rpc (self , wallet_name ):
117
- assert self .rpc_connected
118
- assert self .rpc
119
- wallet_path = "wallet/%s" % wallet_name
120
- return self .rpc / wallet_path
121
+ if self .use_cli :
122
+ return self .cli ("-rpcwallet={}" .format (wallet_name ))
123
+ else :
124
+ assert self .rpc_connected
125
+ assert self .rpc
126
+ wallet_path = "wallet/%s" % wallet_name
127
+ return self .rpc / wallet_path
121
128
122
129
def stop_node (self ):
123
130
"""Stop the node."""
@@ -210,6 +217,7 @@ def __init__(self, binary, datadir):
210
217
self .binary = binary
211
218
self .datadir = datadir
212
219
self .input = None
220
+ self .log = logging .getLogger ('TestFramework.bitcoincli' )
213
221
214
222
def __call__ (self , * args , input = None ):
215
223
# TestNodeCLI is callable with bitcoin-cli command-line args
@@ -240,6 +248,7 @@ def send_cli(self, command, *args, **kwargs):
240
248
if named_args :
241
249
p_args += ["-named" ]
242
250
p_args += [command ] + pos_args + named_args
251
+ self .log .debug ("Running bitcoin-cli command: %s" % command )
243
252
process = subprocess .Popen (p_args , stdin = subprocess .PIPE , stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
244
253
cli_stdout , cli_stderr = process .communicate (input = self .input )
245
254
returncode = process .poll ()
0 commit comments