-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Optimize test_wallet_sync #11103
Optimize test_wallet_sync #11103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the extra work to retain coverage of the two sync modes while reducing runtime.
for i in range(20): | ||
# Tests a reorg with the wallet | ||
ph = both_phs[i % 2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big deal either way, but figured I'd offer this.
https://docs.python.org/3.10/library/itertools.html#itertools.cycle
for i in range(20): | |
# Tests a reorg with the wallet | |
ph = both_phs[i % 2] | |
for i, ph in zip(range(20), itertools.cycle(both_phs)): | |
# Tests a reorg with the wallet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, but that is much more complicated imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is true that modulus is a common programming idiom. How about this? We really don't care about the range nor the modulus of the iteration.
for i in range(20): | |
# Tests a reorg with the wallet | |
ph = both_phs[i % 2] | |
for ph in both_phs * 10: | |
# Tests a reorg with the wallet |
I don't mean to badger about this but I realized this much simpler form than my last suggestion. Feel free to mark this resolved.
) | ||
for i in range(1000, len(new_blocks)): | ||
for i in range(base_num_blocks + 20, len(new_blocks)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading this right?
for i in range(base_num_blocks + 20, len(new_blocks)): | |
for i in range(len(all_blocks), len(new_blocks)): |
|
||
# Insert 400 blocks | ||
for block in default_400_blocks: | ||
await full_node_api.full_node.respond_block(full_node_protocol.RespondBlock(block)) | ||
|
||
# Farm few more with reward | ||
for i in range(0, num_blocks - 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why - 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was testing only one wallet, but farming rewards take 1 block to get confirmed. So here the first wallet needs less rewards because all of them will get confirmed, in the second one, the last one will not get confirmed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. I think I might generally prefer to make sure all the rewards get processed rather than finishing the test with unconfirmed transactions and off-by-one compensations.
But, you can go ahead and resolve this conversation once you've read my comment. No action requested.
Co-authored-by: Kyle Altendorf <sda@fstab.net>
* Optimize test_wallet_sync * Update tests/wallet/sync/test_wallet_sync.py Co-authored-by: Kyle Altendorf <sda@fstab.net> * Fix test Co-authored-by: Kyle Altendorf <sda@fstab.net>
Running every test twice with two modes is wasteful, we can share a lot of the slow stuff