Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved account to BaseEth #2582

Merged
merged 2 commits into from
Jul 29, 2022
Merged

Moved account to BaseEth #2582

merged 2 commits into from
Jul 29, 2022

Conversation

dbfreem
Copy link
Contributor

@dbfreem dbfreem commented Jul 21, 2022

What was wrong?

Make account accessible in AsyncEth

closes #2580

How was it fixed?

Move Eth.account to BaseEth so that it can be used in AsyncEth.

Todo:

Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dbfreem! Before this gets merged, we'll need to add a few tests. If you want to/have time to add them, that would be great! Otherwise someone from the team can pick it up!

You should be able to pretty much wholesale copy/paste tests/core/eth-module/test_async_accounts.py, but where you have your async_w3 fixture defined, you'll need to pass in the AsyncEth module. So instead of this line it should look something like:

return Web3(AsyncEthereumTesterProvider(), modules={"eth", (AsyncEth,)})

@dbfreem
Copy link
Contributor Author

dbfreem commented Jul 21, 2022

@kclowes So, I did some thinking about the test here. Two things I thought of.

  1. Most of these test are testing the functionality of eth_account.Account. It could be argued that these test don't really belong in web3.py but actually in eth_account. They are actually probably already covered there.
  2. If we do need test for this, shouldn't the test be only on BaseEth instead of duplicating them between AsyncEth and Eth? I could change the above referenced test to be only one set of test against BaseEth.account.

Just my thoughts so feel free to say "yes, we want both the AsynEth and Eth test in web3.py for account". :) haha.

@kclowes
Copy link
Collaborator

kclowes commented Jul 21, 2022

Thanks for the comments!

  1. Most of these test are testing the functionality of eth_account.Account. It could be argued that these test don't really belong in web3.py but actually in eth_account. They are actually probably already covered there.

They are covered over there as well, but I think it's good to make sure we can access the most important methods through w3.eth.account, rather than just on the Account class. For example, when the HDWallet feature was implemented, it was working great in eth-account, but we had to do some tweaking to get it to work in web3.

  1. If we do need test for this, shouldn't the test be only on BaseEth instead of duplicating them between AsyncEth and Eth? I could change the above referenced test to be only one set of test against BaseEth.account.

That's a good idea. I think it would be good to have at least one "happy path" test for each Eth and AsyncEth to make sure we can access account through each of those classes to prevent any regressions though.

@dbfreem
Copy link
Contributor Author

dbfreem commented Jul 21, 2022

@kclowes I made the suggested changes, take a look and let me know what you think

Copy link
Collaborator

@fselmo fselmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment just to make sure we have decent assumptions for the testing around this. It would be good to add this feature to the async docs too but I can do that before merging if you'd like. Just let me know.

Thanks for the PR 👌

newsfragments/2580.feature.rst Outdated Show resolved Hide resolved
tests/core/eth-module/test_accounts.py Outdated Show resolved Hide resolved
@dbfreem
Copy link
Contributor Author

dbfreem commented Jul 29, 2022

@fselmo I made the suggested changes. Copied your test into test_account.py, and made the doc changes.

@fselmo
Copy link
Collaborator

fselmo commented Jul 29, 2022

@fselmo I made the suggested changes. Copied your test into test_account.py, and made the doc changes.

lgtm! I just organized async at the bottom so it's a bit easier to read. Ty 👍🏼... I'll merge as soon as tests pass

@fselmo fselmo force-pushed the async_eth_account branch from bc64d1a to e619ebf Compare July 29, 2022 17:51
dbfreem and others added 2 commits July 29, 2022 11:52
- Moved account test to BaseEth, created one test for AsyncEth.account and Eth.account
- Update docs: added link to eth ``account`` in async provider
- Added additional eth ``account`` test
- Added newsfragment
@fselmo fselmo force-pushed the async_eth_account branch from e619ebf to 730ff30 Compare July 29, 2022 17:52
@fselmo fselmo merged commit d74e8ea into ethereum:master Jul 29, 2022
fselmo added a commit to fselmo/web3.py that referenced this pull request Jul 29, 2022
- Move ``account`` to ``BaseEth`` so it can be accessed by both ``Eth`` and ``AsyncEth``
fselmo added a commit to fselmo/web3.py that referenced this pull request Jul 29, 2022
- Move ``account`` to ``BaseEth`` so it can be accessed by both ``Eth`` and ``AsyncEth``
fselmo added a commit to fselmo/web3.py that referenced this pull request Jul 29, 2022
- Move ``account`` to ``BaseEth`` so it can be accessed by both ``Eth`` and ``AsyncEth``
fselmo added a commit that referenced this pull request Aug 2, 2022
- Move ``account`` to ``BaseEth`` so it can be accessed by both ``Eth`` and ``AsyncEth``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 'account' to AsyncEth?
3 participants