Skip to content

Commit 9154ded

Browse files
committed
Cleanup, add more Async ENS tests, test performance improvements
* Add some missing awaits * Add a lot more testing around AsyncENS. We can think about splitting AsyncEthereumTesterProvider tests off into their own CI job if they get too big but we should provide ample testing around the async implementation to make sure it's all wired up correctly. * Cleanup for better readability and consistency across ENS and AsyncENS * Keep async_ens_setup as module scope with a module-scoped event_loop fixture and add a module-scoped async_w3 for ens module * Fix some minor warnings with optionals where ``None`` is being passed in * nit: Since we are adding so many new lines, match code style to ideal rest of library for consistency. Trailing commas with new arguments allow for a cleaner git blame / git history since the next bit of code added would only touch the new line that is created, etc. (``black`` formatting PRs are coming in now though so this wasn't very important after the first commit that was squashed here).
1 parent 0730dee commit 9154ded

16 files changed

+734
-481
lines changed

ens/async_ens.py

Lines changed: 187 additions & 178 deletions
Large diffs are not rendered by default.

ens/base_ens.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
class BaseENS:
3636
w3: 'Web3' = None
37+
ens: Union['Contract', 'AsyncContract'] = None
3738
_resolver_contract: Union[Type['Contract'], Type['AsyncContract']] = None
3839
_reverse_resolver_contract: Union[Type['Contract'], Type['AsyncContract']] = None
39-
ens: Union['Contract', 'AsyncContract'] = None
4040

4141
@staticmethod
4242
@wraps(label_to_hash)
@@ -86,8 +86,10 @@ def parent(name: str) -> str:
8686
return '' if len(labels) == 1 else '.'.join(labels[1:])
8787

8888
def _decode_ensip10_resolve_data(
89-
self, contract_call_result: bytes,
90-
extended_resolver: Union['Contract', 'AsyncContract'], fn_name: str,
89+
self,
90+
contract_call_result: bytes,
91+
extended_resolver: Union['Contract', 'AsyncContract'],
92+
fn_name: str,
9193
) -> Any:
9294
func = extended_resolver.get_function_by_name(fn_name)
9395
output_types = get_abi_output_types(func.abi)
@@ -96,9 +98,11 @@ def _decode_ensip10_resolve_data(
9698
# if decoding a single value, return that value - else, return the tuple
9799
return decoded[0] if len(decoded) == 1 else decoded
98100

99-
def _type_aware_resolver(self,
100-
address: ChecksumAddress,
101-
func: str) -> Union['Contract', 'AsyncContract']:
101+
def _type_aware_resolver(
102+
self,
103+
address: ChecksumAddress,
104+
func: str,
105+
) -> Union['Contract', 'AsyncContract']:
102106
return (
103107
self._reverse_resolver_contract(address=address) if func == 'name' else
104108
self._resolver_contract(address=address)

0 commit comments

Comments
 (0)