Skip to content

Commit

Permalink
fix: gas price type
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jul 17, 2023
1 parent adb1e04 commit 04f9a03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ape/api/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,8 @@ def chain_id(self) -> int:

@property
def gas_price(self) -> int:
return self._web3.eth.generate_gas_price() # type: ignore
price = self._web3.eth.generate_gas_price() or 0
return int(price, 16) if isinstance(price, str) and is_0x_prefixed(price) else int(price)

@property
def priority_fee(self) -> int:
Expand Down
6 changes: 6 additions & 0 deletions tests/functional/test_geth.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,3 +504,9 @@ def test_out_of_gas_error(geth_contract, geth_account, geth_provider):
geth_account.call(txn)

assert err.value.txn is not None


@geth_process_test
def test_gas_price(geth_provider):
actual = geth_provider.gas_price
assert isinstance(actual, int)
5 changes: 5 additions & 0 deletions tests/functional/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,8 @@ def test_get_virtual_machine_error_panic(eth_tester_provider, mocker):
assert enrich_spy.call_count == 1
enrich_spy.assert_called_once_with(actual)
assert isinstance(actual, ContractLogicError)


def test_gas_price(eth_tester_provider):
actual = eth_tester_provider.gas_price
assert isinstance(actual, int)

0 comments on commit 04f9a03

Please sign in to comment.