@ -402,6 +402,14 @@ class TestNodeCLIAttr:
def get_request ( self , * args , * * kwargs ) :
def get_request ( self , * args , * * kwargs ) :
return lambda : self ( * args , * * kwargs )
return lambda : self ( * args , * * kwargs )
def arg_to_cli ( arg ) :
if isinstance ( arg , bool ) :
return str ( arg ) . lower ( )
elif isinstance ( arg , dict ) or isinstance ( arg , list ) :
return json . dumps ( arg )
else :
return str ( arg )
class TestNodeCLI ( ) :
class TestNodeCLI ( ) :
""" Interface to bitcoin-cli for an individual node """
""" Interface to bitcoin-cli for an individual node """
@ -433,8 +441,8 @@ class TestNodeCLI():
def send_cli ( self , command = None , * args , * * kwargs ) :
def send_cli ( self , command = None , * args , * * kwargs ) :
""" Run bitcoin-cli command. Deserializes returned string as python object. """
""" Run bitcoin-cli command. Deserializes returned string as python object. """
pos_args = [ str ( arg ) . lower ( ) if type ( arg ) is bool else str ( arg ) for arg in args ]
pos_args = [ arg_to_cli ( arg ) for arg in args ]
named_args = [ str ( key ) + " = " + str ( value ) for ( key , value ) in kwargs . items ( ) ]
named_args = [ str ( key ) + " = " + arg_to_cli ( value ) for ( key , value ) in kwargs . items ( ) ]
assert not ( pos_args and named_args ) , " Cannot use positional arguments and named arguments in the same bitcoin-cli call "
assert not ( pos_args and named_args ) , " Cannot use positional arguments and named arguments in the same bitcoin-cli call "
p_args = [ self . binary , " -datadir= " + self . datadir ] + self . options
p_args = [ self . binary , " -datadir= " + self . datadir ] + self . options
if named_args :
if named_args :