Skip to content

Instantly share code, notes, and snippets.

@PastaPastaPasta
Created November 18, 2018 16:53
Show Gist options
  • Save PastaPastaPasta/f3bcbbc6ea3a8a4994c9d1dce441f670 to your computer and use it in GitHub Desktop.
Save PastaPastaPasta/f3bcbbc6ea3a8a4994c9d1dce441f670 to your computer and use it in GitHub Desktop.
C:\Users\Paul Burkhalter\source\repos\sentinel>py.test
============================= test session starts =============================
platform win32 -- Python 3.7.1, pytest-3.0.1, py-1.4.31, pluggy-0.3.1
rootdir: C:\Users\Paul Burkhalter\source\repos\sentinel, inifile:
collected 23 items
test\integration\test_jsonrpc.py F
test\unit\test_dash_config.py .F
test\unit\test_dashy_things.py ......
test\unit\test_gobject_json.py ..
test\unit\test_misc.py .
test\unit\test_models.py ..
test\unit\test_submit_command.py .
test\unit\models\test_proposals.py ....
test\unit\models\test_superblocks.py ....
================================== FAILURES ===================================
_________________________________ test_dashd __________________________________
def test_dashd():
config_text = DashConfig.slurp_config_file(config.dash_conf)
network = 'mainnet'
is_testnet = False
genesis_hash = u'00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6'
for line in config_text.split("\n"):
if line.startswith('testnet=1'):
network = 'testnet'
is_testnet = True
genesis_hash = u'00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'
creds = DashConfig.get_rpc_creds(config_text, network)
dashd = DashDaemon(**creds)
assert dashd.rpc_command is not None
assert hasattr(dashd, 'rpc_connection')
# Dash testnet block 0 hash == 00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c
# test commands without arguments
> info = dashd.rpc_command('getinfo')
test\integration\test_jsonrpc.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
lib\dashd.py:44: in rpc_command
return self.rpc_connection.__getattr__(params[0])(*params[1:])
..\..\..\appdata\local\programs\python\python37-32\lib\site-packages\bitcoinrpc\authproxy.py:136: in __call__
'Content-type': 'application/json'})
..\..\..\appdata\local\programs\python\python37-32\lib\http\client.py:1229: in request
self._send_request(method, url, body, headers, encode_chunked)
..\..\..\appdata\local\programs\python\python37-32\lib\http\client.py:1275: in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
..\..\..\appdata\local\programs\python\python37-32\lib\http\client.py:1224: in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
..\..\..\appdata\local\programs\python\python37-32\lib\http\client.py:1016: in _send_output
self.send(msg)
..\..\..\appdata\local\programs\python\python37-32\lib\http\client.py:956: in send
self.connect()
..\..\..\appdata\local\programs\python\python37-32\lib\http\client.py:928: in connect
(self.host,self.port), self.timeout, self.source_address)
..\..\..\appdata\local\programs\python\python37-32\lib\socket.py:727: in create_connection
raise err
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
address = ('127.0.0.1', 9998), timeout = 30, source_address = None
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used. If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
A host of '' or port 0 tells the OS to use the default.
"""
host, port = address
err = None
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
af, socktype, proto, canonname, sa = res
sock = None
try:
sock = socket(af, socktype, proto)
if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
sock.settimeout(timeout)
if source_address:
sock.bind(source_address)
> sock.connect(sa)
E ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
..\..\..\appdata\local\programs\python\python37-32\lib\socket.py:716: ConnectionRefusedError
___________________________ test_slurp_config_file ____________________________
def test_slurp_config_file():
import tempfile
dash_config = """# basic settings
#testnet=1 # TESTNET
server=1
printtoconsole=1
txindex=1 # enable transaction index
"""
expected_stripped_config = """server=1
printtoconsole=1
txindex=1 # enable transaction index
"""
with tempfile.NamedTemporaryFile(mode='w') as temp:
temp.write(dash_config)
temp.flush()
> conf = DashConfig.slurp_config_file(temp.name)
test\unit\test_dash_config.py:83:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <class 'dash_config.DashConfig'>
filename = 'C:\\Users\\PAULBU~1\\AppData\\Local\\Temp\\tmpll6cv1a9'
@classmethod
def slurp_config_file(self, filename):
# read dash.conf config but skip commented lines
> f = io.open(filename)
E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\PAULBU~1\\AppData\\Local\\Temp\\tmpll6cv1a9'
lib\dash_config.py:15: PermissionError
===================== 2 failed, 21 passed in 2.86 seconds =====================
C:\Users\Paul Burkhalter\source\repos\sentinel>py.test -svv ./test/unit
============================= test session starts =============================
platform win32 -- Python 3.7.1, pytest-3.0.1, py-1.4.31, pluggy-0.3.1 -- c:\users\paul burkhalter\appdata\local\programs\python\python37-32\python.exe
cachedir: .cache
rootdir: C:\Users\Paul Burkhalter\source\repos\sentinel, inifile:
collected 22 items
test/unit/test_dash_config.py::test_get_rpc_creds PASSED
test/unit/test_dash_config.py::test_slurp_config_file FAILED
test/unit/test_dashy_things.py::test_valid_dash_address PASSED
test/unit/test_dashy_things.py::test_invalid_dash_address PASSED
test/unit/test_dashy_things.py::test_deterministic_masternode_elections PASSED
test/unit/test_dashy_things.py::test_parse_masternode_status_vin PASSED
test/unit/test_dashy_things.py::test_hash_function PASSED
test/unit/test_dashy_things.py::test_blocks_to_seconds PASSED
test/unit/test_gobject_json.py::test_valid_json PASSED
test/unit/test_gobject_json.py::test_extract_object PASSED
test/unit/test_misc.py::test_is_numeric PASSED
test/unit/test_models.py::test_proposal PASSED
test/unit/test_models.py::test_governance_object PASSED
test/unit/test_submit_command.py::test_submit_command PASSED
test/unit/models/test_proposals.py::test_proposal_is_valid PASSED
test/unit/models/test_proposals.py::test_proposal_is_expired PASSED
test/unit/models/test_proposals.py::test_approved_and_ranked PASSED
test/unit/models/test_proposals.py::test_proposal_size PASSED
test/unit/models/test_superblocks.py::test_superblock_is_valid PASSED
test/unit/models/test_superblocks.py::test_serialisable_fields PASSED
test/unit/models/test_superblocks.py::test_deterministic_superblock_creation PASSED
test/unit/models/test_superblocks.py::test_deterministic_superblock_selection PASSED
================================== FAILURES ===================================
___________________________ test_slurp_config_file ____________________________
def test_slurp_config_file():
import tempfile
dash_config = """# basic settings
#testnet=1 # TESTNET
server=1
printtoconsole=1
txindex=1 # enable transaction index
"""
expected_stripped_config = """server=1
printtoconsole=1
txindex=1 # enable transaction index
"""
with tempfile.NamedTemporaryFile(mode='w') as temp:
temp.write(dash_config)
temp.flush()
> conf = DashConfig.slurp_config_file(temp.name)
test\unit\test_dash_config.py:83:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <class 'dash_config.DashConfig'>
filename = 'C:\\Users\\PAULBU~1\\AppData\\Local\\Temp\\tmpukum2a2e'
@classmethod
def slurp_config_file(self, filename):
# read dash.conf config but skip commented lines
> f = io.open(filename)
E PermissionError: [Errno 13] Permission denied: 'C:\\Users\\PAULBU~1\\AppData\\Local\\Temp\\tmpukum2a2e'
lib\dash_config.py:15: PermissionError
===================== 1 failed, 21 passed in 0.82 seconds =====================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment