Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kclowes committed Jul 14, 2021
1 parent f0c8c47 commit 5e40c7c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 21 deletions.
12 changes: 12 additions & 0 deletions tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
EMITTER_ENUM,
)
from web3.providers.eth_tester import (
AsyncEthereumTesterProvider,
EthereumTesterProvider,
)
from web3.types import ( # noqa: F401
Expand All @@ -44,12 +45,23 @@ def eth_tester_provider(eth_tester):
return provider


@pytest.fixture(scope="module")
def async_eth_tester_provider(eth_tester):
provider = AsyncEthereumTesterProvider(eth_tester)
return provider


@pytest.fixture(scope="module")
def web3(eth_tester_provider):
_web3 = Web3(eth_tester_provider)
return _web3


@pytest.fixture(scope="module")
def async_w3(eth_tester_provider):
_web3 = Web3(async_eth_tester_provider)
return _web3

#
# Math Contract Setup
#
Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/module_testing/net_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def test_net_version(self, async_w3: "Web3") -> None:

@pytest.mark.asyncio
async def test_net_listening(self, async_w3: "Web3") -> None:
listening = await async_w3.net.listening # type: ignore
listening = await async_w3.net.listening

assert is_boolean(listening)

Expand Down
2 changes: 2 additions & 0 deletions web3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
RequestManager as DefaultRequestManager,
)
from web3.net import (
AsyncNet,
Net,
)
from web3.parity import (
Expand Down Expand Up @@ -225,6 +226,7 @@ def toChecksumAddress(value: Union[AnyAddress, str, bytes]) -> ChecksumAddress:
parity: Parity
geth: Geth
net: Net
# async_net: AsyncNet

def __init__(
self,
Expand Down
49 changes: 29 additions & 20 deletions web3/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,53 @@ class BaseNet(Module):
mungers=[default_root_munger],
)

@property
def peer_count(self) -> int:
return self._peer_count()

@property
def version(self) -> str:
return self._version()

class Net(BaseNet):
@property
def listening(self) -> bool:
return self._listening()

@property
def peer_count(self) -> int:
return self._peer_count()

class Net(BaseNet):
@property
def chainId(self) -> NoReturn:
raise DeprecationWarning("This method has been deprecated in EIP 1474.")

@property
def version(self) -> str:
return self._version()
# @property
# def listening(self) -> bool:
# return self._listening()

# @property
# def peer_count(self) -> int:
# return self._peer_count()

# @property
# def version(self) -> str:
# return self._version()

#
# Deprecated Methods
#
peerCount = DeprecatedMethod(peer_count, 'peerCount', 'peer_count') # type: ignore
peerCount = DeprecatedMethod(BaseNet.peer_count, 'peerCount', 'peer_count') # type: ignore


class AsyncNet(BaseNet):
is_async = True

@property
async def listening(self) -> bool:
# types ignored b/c mypy conflict with BlockingNet properties
return await self._listening() # type: ignore
# @property
# def listening(self) -> bool:
# return self._listening()

@property
async def peer_count(self) -> int:
# types ignored b/c mypy conflict with BlockingNet properties
return await self._peer_count() # type: ignore
# @property
# def peer_count(self) -> int:
# return self._peer_count()

@property
async def version(self) -> str:
# types ignored b/c mypy conflict with BlockingNet properties
return await self._version() # type: ignore
# @property
# def version(self) -> str:
# return self._version()

0 comments on commit 5e40c7c

Please sign in to comment.