Skip to content
This repository was archived by the owner on Aug 8, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyethapp/rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class JSONRPCClientReplyError(Exception):
class JSONRPCClient(object):
protocol = JSONRPCProtocol()

def __init__(self, port=4000, print_communication=True, privkey=None, sender=None):
def __init__(self, host='127.0.0.1', port=4000, print_communication=True, privkey=None, sender=None):
"specify privkey for local signing"
self.transport = HttpPostClientTransport('http://127.0.0.1:{}'.format(port))
self.transport = HttpPostClientTransport('http://{}:{}'.format(host, port))
self.print_communication = print_communication
self.privkey = privkey
self._sender = sender
Expand Down
14 changes: 14 additions & 0 deletions pyethapp/tests/test_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,17 @@ def test_find_block():
JSONRPCClient.call = lambda self, cmd, num, flag: num
client = JSONRPCClient()
client.find_block(lambda x: x == '0x5')


def test_default_host():
default_host = '127.0.0.1'
client = JSONRPCClient()
assert client.transport.endpoint == 'http://{}:{}'.format(default_host, client.port)


def test_set_host():
host = '1.1.1.1'
default_host = '127.0.0.1'
client = JSONRPCClient(host)
assert client.transport.endpoint == 'http://{}:{}'.format(host, client.port)
assert client.transport.endpoint != 'http://{}:{}'.format(default_host, client.port)