Skip to content

Commit

Permalink
update docs and test
Browse files Browse the repository at this point in the history
  • Loading branch information
tmckenzie51 committed Mar 22, 2021
1 parent 7bdad53 commit e96fece
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ API
- :meth:`web3.eth.sign() <web3.eth.Eth.sign>`
- :meth:`web3.eth.signTypedData() <web3.eth.Eth.signTypedData>`
- :meth:`web3.eth.estimateGas() <web3.eth.Eth.estimateGas>`
- :meth:`web3.eth.generateGasPrice() <web3.eth.Eth.generateGasPrice>`
- :meth:`web3.eth.generate_gas_price() <web3.eth.Eth.generate_gas_price>`
- :meth:`web3.eth.setGasPriceStrategy() <web3.eth.Eth.setGasPriceStrategy>`


Expand Down
9 changes: 7 additions & 2 deletions docs/web3.eth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ The following methods are available on the ``web3.eth`` namespace.
nodes would result in an error like: ``ValueError: {'code': -32602, 'message': 'too many arguments, want at most 1'}``


.. py:method:: Eth.generateGasPrice(transaction_params=None)
.. py:method:: Eth.generate_gas_price(transaction_params=None)
Uses the selected gas price strategy to calculate a gas price. This method
returns the gas price denominated in wei.
Expand All @@ -970,13 +970,18 @@ The following methods are available on the ``web3.eth`` namespace.

.. code-block:: python
>>> Web3.eth.generateGasPrice()
>>> Web3.eth.generate_gas_price()
20000000000
.. note::
For information about how gas price can be customized in web3 see
:ref:`Gas_Price`.

.. py:method:: Eth.generateGasPrice(transaction_params=None)
.. warning:: Deprecated: This method is deprecated in favor of
:meth:`~web3.eth.Eth.generate_gas_price_strategy()`

.. py:method:: Eth.setGasPriceStrategy(gas_price_strategy)
Set the selected gas price strategy. It must be a method of the signature
Expand Down
8 changes: 4 additions & 4 deletions tests/core/middleware/test_gas_price_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ def the_gas_price_strategy_middleware(web3):


def test_gas_price_generated(the_gas_price_strategy_middleware):
the_gas_price_strategy_middleware.web3.eth.generateGasPrice.return_value = 5
the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = 5
method = 'eth_sendTransaction'
params = [{
'to': '0x0',
'value': 1,
}]
the_gas_price_strategy_middleware(method, params)
the_gas_price_strategy_middleware.web3.eth.generateGasPrice.assert_called_once_with({
the_gas_price_strategy_middleware.web3.eth.generate_gas_price.assert_called_once_with({
'to': '0x0',
'value': 1,
})
Expand All @@ -37,7 +37,7 @@ def test_gas_price_generated(the_gas_price_strategy_middleware):


def test_gas_price_not_overridden(the_gas_price_strategy_middleware):
the_gas_price_strategy_middleware.web3.eth.generateGasPrice.return_value = 5
the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = 5
method = 'eth_sendTransaction'
params = [{
'to': '0x0',
Expand All @@ -53,7 +53,7 @@ def test_gas_price_not_overridden(the_gas_price_strategy_middleware):


def test_gas_price_not_set_without_gas_price_strategy(the_gas_price_strategy_middleware):
the_gas_price_strategy_middleware.web3.eth.generateGasPrice.return_value = None
the_gas_price_strategy_middleware.web3.eth.generate_gas_price.return_value = None
method = 'eth_sendTransaction'
params = [{
'to': '0x0',
Expand Down

0 comments on commit e96fece

Please sign in to comment.