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

deprecate submitWork in favor of submit_work #1927

Merged
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
8 changes: 6 additions & 2 deletions docs/web3.eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1140,19 +1140,23 @@ with the filtering API.
True


.. py:method:: Eth.submitWork(nonce, pow_hash, mix_digest)
.. py:method:: Eth.submit_work(nonce, pow_hash, mix_digest)

* Delegates to ``eth_submitWork`` RPC Method.

.. code-block:: python

>>> web3.eth.submitWork(
>>> web3.eth.submit_work(
1,
'0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
'0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000',
)
True

.. py:method:: Eth.submitWork(nonce, pow_hash, mix_digest)

.. warning:: Deprecated: This property is deprecated in favor of
:attr:`~web3.eth.Eth.submit_work()`

Contracts
---------
Expand Down
1 change: 1 addition & 0 deletions newsfragments/1927.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ``w3.eth.submit_work`` deprecate ``w3.eth.submitWork``
4 changes: 3 additions & 1 deletion tests/integration/test_ethereum_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ class TestEthereumTesterEthModule(EthModuleTest):
EthModuleTest.test_eth_sign_transaction_ens_names, ValueError
)
test_eth_submitHashrate = not_implemented(EthModuleTest.test_eth_submitHashrate, ValueError)
test_eth_submitWork = not_implemented(EthModuleTest.test_eth_submitWork, ValueError)
test_eth_submitWork_deprecated = not_implemented(
EthModuleTest.test_eth_submitWork_deprecated, ValueError)
test_eth_submit_work = not_implemented(EthModuleTest.test_eth_submit_work, ValueError)

tmckenzie51 marked this conversation as resolved.
Show resolved Hide resolved
def test_eth_getBlockByHash_pending(
self, web3: "Web3"
Expand Down
13 changes: 11 additions & 2 deletions web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,9 +1476,18 @@ def test_eth_submitHashrate(self, web3: "Web3") -> None:
result = web3.eth.submitHashrate(5000, node_id)
assert result is True

def test_eth_submitWork(self, web3: "Web3") -> None:
def test_eth_submit_work(self, web3: "Web3") -> None:
nonce = 1
pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef')
mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000')
result = web3.eth.submitWork(nonce, pow_hash, mix_digest)
result = web3.eth.submit_work(nonce, pow_hash, mix_digest)
assert result is False

def test_eth_submitWork_deprecated(self, web3: "Web3") -> None:
nonce = 1
pow_hash = HexStr('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef')
mix_digest = HexStr('0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000')
with pytest.warns(DeprecationWarning,
match="submitWork is deprecated in favor of submit_work"):
result = web3.eth.submitWork(nonce, pow_hash, mix_digest)
assert result is False
3 changes: 2 additions & 1 deletion web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def filter_munger(
mungers=[default_root_munger],
)

submitWork: Method[Callable[[int, _Hash32, _Hash32], bool]] = Method(
submit_work: Method[Callable[[int, _Hash32, _Hash32], bool]] = Method(
RPC.eth_submitWork,
mungers=[default_root_munger],
)
Expand Down Expand Up @@ -689,6 +689,7 @@ def setGasPriceStrategy(self, gas_price_strategy: GasPriceStrategy) -> None:
getUncleCount = DeprecatedMethod(get_uncle_count, 'getUncleCount', 'get_uncle_count')
sendTransaction = DeprecatedMethod(send_transaction, 'sendTransaction', 'send_transaction')
signTransaction = DeprecatedMethod(sign_transaction, 'signTransaction', 'sign_transaction')
submitWork = DeprecatedMethod(submit_work, 'submitWork', 'submit_work')
getLogs = DeprecatedMethod(get_logs, 'getLogs', 'get_logs')
sendRawTransaction = DeprecatedMethod(send_raw_transaction,
'sendRawTransaction',
Expand Down