示例#1
0
 def test_other_request_error(self):
     """Mock other errors connecting to server.
     """
     responses.add(responses.POST, self.dummy_url, body=RequestException(""))
     client = AuthServiceProxy(self.dummy_url)
     with pytest.raises(JSONRPCException):
         client.get_balance()
示例#2
0
 def test_timeout_error(self):
     """Mock timeout connecting to server.
     """
     responses.add(responses.POST, self.dummy_url, body=Timeout(""))
     client = AuthServiceProxy(self.dummy_url)
     with pytest.raises(JSONRPCException):
         client.get_balance()
示例#3
0
 def test_connection_error(self):
     """Mock no connection to server error.
     """
     responses.add(responses.POST, self.dummy_url, body=ConnectionError(""))
     client = AuthServiceProxy(self.dummy_url)
     with pytest.raises(JSONRPCException):
         client.get_balance()
示例#4
0
 def test_jsondecode_request_error(self):
     """Mock JSONDecodeError when trying to get JSON form response."""
     responses.add(responses.POST,
                   self.dummy_url,
                   body=RequestException(""))
     client = AuthServiceProxy(self.dummy_url)
     with pytest.raises(JSONRPCException):
         client.get_balance()
from monerorpc.authproxy import AuthServiceProxy, JSONRPCException
import logging
logging.basicConfig()
logging.getLogger("MoneroRPC").setLevel(logging.DEBUG)
log = logging.getLogger("wallet-rpc-lib")

rpc = AuthServiceProxy('http://*****:*****@127.0.0.1:38083/json_rpc')
#rpc = AuthServiceProxy('http://127.0.0.1:38083/json_rpc')
try:
    rpc.get_balance()
    params = {"account_index": 0, "address_indices": [0, 1]}
    rpc.get_balance(params)
    destinations = {
        "destinations": [{
            "address":
            "59McWTPGc745SRWrSMoh8oTjoXoQq6sPUgKZ66dQWXuKFQ2q19h9gvhJNZcFTizcnT12r63NFgHiGd6gBCjabzmzHAMoyD6",
            "amount": 1
        }],
        "mixin":
        10
    }
    rpc.transfer(destinations)
except (JSONRPCException) as e:
    log.error(e)
示例#6
0
 def test_other_request_error(self):
     """Mock other errors connecting to server."""
     responses.add(responses.POST, self.dummy_url, body="<html></html>")
     client = AuthServiceProxy(self.dummy_url)
     with pytest.raises(ValueError):
         client.get_balance()