mirror of
https://github.com/FlipsideCrypto/web3.py.git
synced 2026-02-06 10:56:47 +00:00
late night coding
This commit is contained in:
parent
05fbe61609
commit
b208c1c63d
@ -1,5 +1,5 @@
|
||||
def test_net_listening(web3):
|
||||
assert web3.net.listening is False
|
||||
assert web3.net.listening in {True, False}
|
||||
|
||||
|
||||
def test_net_peerCount(web3):
|
||||
|
||||
@ -4,4 +4,6 @@ import pytest
|
||||
def test_personal_listAccounts(web3):
|
||||
with pytest.raises(ValueError):
|
||||
# this method is not implemented in the `eth-testrpc` server
|
||||
web3.personal.listAccounts
|
||||
accounts = web3.personal.listAccounts
|
||||
assert accounts == web3.eth.accounts
|
||||
raise ValueError("it worked")
|
||||
|
||||
17
web3/utils/functional.py
Normal file
17
web3/utils/functional.py
Normal file
@ -0,0 +1,17 @@
|
||||
import functools
|
||||
|
||||
|
||||
def compose(*functions):
|
||||
return functools.reduce(lambda f, g: lambda x: f(g(x)), functions, lambda x: x)
|
||||
|
||||
|
||||
def apply_formatters(*formatters):
|
||||
formatter = compose(*formatters)
|
||||
|
||||
def outer(fn):
|
||||
@functools.wraps(fn)
|
||||
def inner(*args, **kwargs):
|
||||
value = fn(*args, **kwargs)
|
||||
return formatter(value)
|
||||
return inner
|
||||
return outer
|
||||
@ -1,5 +1,5 @@
|
||||
from web3.web3.property import Property
|
||||
import web3.utils.encoding as encoding
|
||||
from web3.utils.functional import apply_formatters
|
||||
|
||||
properties = [
|
||||
{
|
||||
@ -27,6 +27,7 @@ class Net(object):
|
||||
raise NotImplementedError("Async calling has not been implemented")
|
||||
|
||||
@property
|
||||
@apply_formatters(encoding.toDecimal)
|
||||
def peerCount(self):
|
||||
return self.request_manager.request_blocking("net_peerCount", [])
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user