Skip to content

Commit 8aa5088

Browse files
committed
Passing create_access_list tests
1 parent e822795 commit 8aa5088

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

tests/integration/test_ethereum_tester.py

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
from eth_tester.exceptions import (
88
TransactionFailed,
99
)
10+
from eth_typing import (
11+
ChecksumAddress,
12+
)
1013
from eth_utils import (
1114
is_checksum_address,
1215
is_dict,
@@ -583,6 +586,16 @@ def test_eth_get_balance_with_block_identifier(self, w3: "Web3") -> None:
583586
assert is_integer(later_balance)
584587
assert later_balance > genesis_balance
585588

589+
def test_eth_create_access_list(
590+
self,
591+
w3: "Web3",
592+
unlocked_account_dual_type: ChecksumAddress,
593+
unlocked_account: ChecksumAddress,
594+
) -> None:
595+
super().test_eth_create_access_list(
596+
w3, unlocked_account_dual_type, unlocked_account
597+
)
598+
586599

587600
class TestEthereumTesterNetModule(NetModuleTest):
588601
pass

web3/_utils/method_formatters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
471471

472472
ACCESS_LIST_RESPONSE_FORMATTER = type_aware_apply_formatters_to_dict(
473473
{
474-
"accessList": ACCESS_LIST_FORMATTER,
474+
"accessList": apply_list_to_array_formatter(ACCESS_LIST_FORMATTER),
475475
"gasUsed": to_integer_if_hex,
476476
}
477477
)

web3/_utils/module_testing/eth_module.py

+25
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,31 @@ def test_eth_get_code_with_block_identifier(
26942694
assert isinstance(code, HexBytes)
26952695
assert len(code) > 0
26962696

2697+
def test_eth_create_access_list(
2698+
self,
2699+
w3: "Web3",
2700+
unlocked_account_dual_type: ChecksumAddress,
2701+
unlocked_account: ChecksumAddress,
2702+
) -> None:
2703+
response = w3.eth.create_access_list(
2704+
{
2705+
"from": unlocked_account_dual_type,
2706+
"to": unlocked_account,
2707+
"data": HexStr("0x0"),
2708+
}
2709+
)
2710+
2711+
assert is_dict(response)
2712+
access_list = response["accessList"]
2713+
assert len(access_list) > 0
2714+
assert access_list[0]["address"] is not None
2715+
assert is_checksum_address(access_list[0]["address"])
2716+
assert access_list[1]["address"] is not None
2717+
assert is_checksum_address(access_list[1]["address"])
2718+
assert len(access_list[0]["storageKeys"]) > 0
2719+
assert len(access_list[1]["storageKeys"]) > 0
2720+
assert int(response["gas"]) >= 0
2721+
26972722
def test_eth_sign(
26982723
self, w3: "Web3", unlocked_account_dual_type: ChecksumAddress
26992724
) -> None:

web3/eth/eth.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
)
6969
from web3.types import (
7070
ENS,
71-
AccessList,
7271
BlockData,
7372
BlockIdentifier,
7473
BlockParams,
@@ -287,15 +286,15 @@ def _durin_call(
287286
_create_access_list: Method[
288287
Callable[
289288
[TxParams, Optional[BlockIdentifier]],
290-
AccessList,
289+
TxData,
291290
]
292291
] = Method(RPC.eth_createAccessList, mungers=[BaseEth.create_access_list_munger])
293292

294293
def create_access_list(
295294
self,
296295
transaction: TxParams,
297296
block_identifier: Optional[BlockIdentifier] = None,
298-
) -> AccessList:
297+
) -> TxData:
299298
return self._create_access_list(transaction, block_identifier)
300299

301300
# eth_estimateGas

web3/providers/eth_tester/defaults.py

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def personal_send_transaction(eth_tester: "EthereumTester", params: Any) -> HexS
311311
"sendTransaction": call_eth_tester("send_transaction"),
312312
"sendRawTransaction": call_eth_tester("send_raw_transaction"),
313313
"call": call_eth_tester("call"), # TODO: untested
314+
"createAccessList": call_eth_tester("create_access_list"),
314315
"estimateGas": call_eth_tester("estimate_gas"), # TODO: untested
315316
"getBlockByHash": null_if_block_not_found(call_eth_tester("get_block_by_hash")),
316317
"getBlockByNumber": null_if_block_not_found(

web3/providers/eth_tester/main.py

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def _make_request(
155155
api_endpoints: Dict[str, Dict[str, Any]],
156156
ethereum_tester_instance: "EthereumTester",
157157
) -> RPCResponse:
158+
print("OOOOOOOOOOO", params)
158159
# do not import eth_tester derivatives until runtime,
159160
# it is not a default dependency
160161
from eth_tester.exceptions import (

0 commit comments

Comments
 (0)