Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lib throws for the call net_peerCount #34

Open
mezrin opened this issue Jun 30, 2017 · 1 comment
Open

Lib throws for the call net_peerCount #34

mezrin opened this issue Jun 30, 2017 · 1 comment

Comments

@mezrin
Copy link

mezrin commented Jun 30, 2017

In my project, I use testrpc as the environment for my unit tests.
And ehjsonrpc throws for the call net_peerCount with this:

File "/../src/venv/lib/python3.5/site-packages/ethjsonrpc/client.py", line 175, in net_peerCount
    return hex_to_dec(self._call('net_peerCount'))
  File "/../src/venv/lib/python3.5/site-packages/ethjsonrpc/utils.py", line 10, in hex_to_dec
    return int(x, 16)
TypeError: int() can't convert non-string with explicit base

I found a quick fix
https://github.com/ConsenSys/ethjsonrpc/blob/master/ethjsonrpc/utils.py#L8

def hex_to_dec(x):
    if type(x) is int:
        return x
    return int(x, 16)
@reiven
Copy link

reiven commented Jun 30, 2017

@mezrin you are using testrpc instead of geth or parity, right?

looks like a problem in testrpc with the response of that method, using geth or parity the anwser is correct

Using parity:

>>> from ethjsonrpc import ParityEthJsonRpc
>>> c = ParityEthJsonRpc('localhost')
>>> c.net_peerCount()
0

Using geth:

>>> from ethjsonrpc import EthJsonRpc
>>> c= EthJsonRpc('localhost')
>>> c.net_peerCount()
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants