From bc52af96a594e630c353d42f3c9d447aa72db869 Mon Sep 17 00:00:00 2001 From: antazoey Date: Wed, 23 Aug 2023 08:10:31 -0500 Subject: [PATCH] fix: issue where could not have gas limit of 0 [APE-1307] (#1616) --- src/ape_ethereum/ecosystem.py | 6 +++--- tests/functional/test_ecosystem.py | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ape_ethereum/ecosystem.py b/src/ape_ethereum/ecosystem.py index 6324fb240e..32c08ecb83 100644 --- a/src/ape_ethereum/ecosystem.py +++ b/src/ape_ethereum/ecosystem.py @@ -357,9 +357,9 @@ def decode_receipt(self, data: dict) -> ReceiptAPI: receipt = Receipt( block_number=data.get("block_number") or data.get("blockNumber"), contract_address=data.get("contract_address") or data.get("contractAddress"), - gas_limit=data.get("gas") or data.get("gas_limit") or data.get("gasLimit"), - gas_price=data.get("gas_price") or data.get("gasPrice"), - gas_used=data.get("gas_used") or data.get("gasUsed"), + gas_limit=data.get("gas", data.get("gas_limit", data.get("gasLimit"))) or 0, + gas_price=data.get("gas_price", data.get("gasPrice")) or 0, + gas_used=data.get("gas_used", data.get("gasUsed")) or 0, logs=data.get("logs", []), status=status, txn_hash=txn_hash, diff --git a/tests/functional/test_ecosystem.py b/tests/functional/test_ecosystem.py index 6f45c3dba7..30804e9ec9 100644 --- a/tests/functional/test_ecosystem.py +++ b/tests/functional/test_ecosystem.py @@ -165,7 +165,7 @@ def test_decode_block_when_hash_is_none(ethereum): "totalDifficulty": 131073, "extraData": HexBytes("0x"), "size": 513, - "gasLimit": 30000000, + "gasLimit": 0, "gasUsed": 0, "timestamp": 1660932629, "transactions": [], @@ -174,6 +174,7 @@ def test_decode_block_when_hash_is_none(ethereum): } actual = ethereum.decode_block(block_data_with_none_hash) assert actual.hash is None + assert actual.gas_limit == 0 def test_decode_block_with_hex_values(ethereum):