Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions tests/core/eth-module/test_eth_protocolVersion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_eth_protocolVersion(web3):
assert web3.eth.protocolVersion == '99'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this 99?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it's talking to eth-tester and should probably be updated internally to be 63

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, strange - according to this line it should be returning 63. Will dive deeper into this tomorrow

9 changes: 7 additions & 2 deletions tests/core/version-module/test_version_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ def async_w3():

def test_blocking_version(blocking_w3):
assert blocking_w3.blocking_version.api == blocking_w3.legacy_version.api
assert blocking_w3.blocking_version.node == blocking_w3.legacy_version.node
assert blocking_w3.blocking_version.ethereum == blocking_w3.legacy_version.ethereum


def test_legacy_version_deprecation(blocking_w3):
with pytest.raises(DeprecationWarning):
blocking_w3.legacy_version.node
with pytest.raises(DeprecationWarning):
blocking_w3.legacy_version.ethereum


@pytest.mark.asyncio
Expand Down
2 changes: 2 additions & 0 deletions tests/core/web3-module/test_clientVersion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_web3_clientVersion(web3):
assert web3.clientVersion.startswith("EthereumTester/")
2 changes: 1 addition & 1 deletion web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

class EthModuleTest:
def test_eth_protocolVersion(self, web3):
protocol_version = web3.version.ethereum
protocol_version = web3.eth.protocolVersion

assert is_string(protocol_version)
assert protocol_version.isdigit()
Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/module_testing/version_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class VersionModuleTest:
def test_eth_protocolVersion(self, web3):
protocol_version = web3.version.ethereum
protocol_version = web3.eth.protocolVersion

assert is_string(protocol_version)
assert protocol_version.isdigit()
2 changes: 1 addition & 1 deletion web3/_utils/module_testing/web3_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class Web3ModuleTest:
def test_web3_clientVersion(self, web3):
client_version = web3.version.node
client_version = web3.clientVersion
self._check_web3_clientVersion(client_version)

def _check_web3_clientVersion(self, client_version):
Expand Down
8 changes: 4 additions & 4 deletions web3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,12 @@
from web3.txpool import (
TxPool,
)
from web3.version import (
Version,
)


def get_default_modules():
return {
"eth": (Eth,),
"net": (Net,),
"version": (Version,),
"txpool": (TxPool,),
"miner": (Miner,),
"admin": (Admin,),
Expand Down Expand Up @@ -155,6 +151,10 @@ def provider(self):
def provider(self, provider):
self.manager.provider = provider

@property
def clientVersion(self):
return self.manager.request_blocking("web3_clientVersion", [])

@staticmethod
@apply_to_return_value(HexBytes)
def keccak(primitive=None, text=None, hexstr=None):
Expand Down
2 changes: 1 addition & 1 deletion web3/middleware/normalize_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def middleware(method, params):
# It used to return a result of None, so we simulate the old behavior.

if method == 'eth_getTransactionReceipt' and 'error' in result:
is_geth = web3.version.node.startswith('Geth')
is_geth = web3.clientVersion.startswith('Geth')
if is_geth and result['error']['code'] == -32000:
return assoc(
dissoc(result, 'error'),
Expand Down
4 changes: 2 additions & 2 deletions web3/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def api(self):

@property
def node(self):
return self.web3.manager.request_blocking("web3_clientVersion", [])
raise DeprecationWarning("This method has been deprecated as of EIP 1474.")

@property
def ethereum(self):
return self.web3.manager.request_blocking("eth_protocolVersion", [])
raise DeprecationWarning("This method has been deprecated as of EIP 1474.")