-
Notifications
You must be signed in to change notification settings - Fork 38.7k
test: refactor RPCPackagesTest to use MiniWallet
#25986
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
Conversation
kouloumos
left a comment
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 reasoning behind the removal of those functions was that the functionality of those methods can now be replicated with the existing MiniWallet methods.
I believe that your implementation doesn't fully utilize the MiniWallet methods. See #25379 where I did the first part of refactoring mempool_package_limits.py which was the other test that was using those functions.
941ae7f to
10edc9c
Compare
|
@kouloumos Thanks for the tip. I changed all tests to use MiniWallet methods in 10edc9c0d7b686808c040204103da01ed386a3c9. |
kouloumos
left a comment
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.
Looks good, some minor comments
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
df7e74b to
4d4298f
Compare
glozow
left a comment
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.
Looks good, thanks for working on this!
glozow
left a comment
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.
ACK 17cad44
hernanmarino
left a comment
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.
Approach ACK
pablomartin4btc
left a comment
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.
tested ACK 17cad44; went thru all changes and recommendations from @kouloumos & @glozow; also went up to #20833 to get a bit of background of the origin and purpose of these tests.
kouloumos
left a comment
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.
ACK 17cad44
looks good to me, just some minor nits.
| address = node.get_deterministic_priv_key().address | ||
| garbage_tx = node.createrawtransaction([{"txid": "00" * 32, "vout": 5}], {address: 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.
nit: get_deterministic_priv_key is not often used alongside the MinWallet is used. Why not use its own method?
| address = node.get_deterministic_priv_key().address | |
| garbage_tx = node.createrawtransaction([{"txid": "00" * 32, "vout": 5}], {address: 1}) | |
| address = self.wallet.getaddress() | |
| garbage_tx = node.createrawtransaction([{"txid": "00" * 32, "vout": 5}], {address: 1}) |
Also, if you decide to touch this, garbage_tx_hex follows better the naming scheme.
| {"txid": tx1["txid"], "wtxid": tx1["wtxid"], "package-error": "conflict-in-package"}, | ||
| {"txid": tx1["txid"], "wtxid": tx1["wtxid"], "package-error": "conflict-in-package"} |
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.
nit: I believe that is for the best when similar implementation details follow similar checks in code across functional tests. Although I believe this is important, I consider it a nit as this is not code you've written as part of this refactor.
What I am referring to, is the assertion after a testmepoolaccept(). In a similar example at mempool_package_limits, the implementation logic differs a bit and imo improves the readability by not checking for (w)txid.
bitcoin/test/functional/mempool_package_limits.py
Lines 116 to 118 in 85892f7
| testres_too_long = node.testmempoolaccept(rawtxs=package_hex) | |
| for txres in testres_too_long: | |
| assert_equal(txres["package-error"], "package-mempool-limits") |
Just a note that a similar assertion-of-testmepoolaccept() logic is already a method as part of another test. I've tried to implement it as part of this test, but it ended up not worth it.
bitcoin/test/functional/mempool_accept.py
Lines 49 to 55 in 85892f7
| def check_mempool_result(self, result_expected, *args, **kwargs): | |
| """Wrapper to check result of testmempoolaccept on node_0's mempool""" | |
| result_test = self.nodes[0].testmempoolaccept(*args, **kwargs) | |
| for r in result_test: | |
| r.pop('wtxid') # Skip check for now | |
| assert_equal(result_expected, result_test) | |
| assert_equal(self.nodes[0].getmempoolinfo()['size'], self.mempool_size) # Must not change mempool state |
*This assertion-of-testmepoolaccept() pattern can be observed in multiple occasions, this highlights just one of them.
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.
Agree doing similar checks each time is good and having a helper like check_mempool_result() is a way to achieve that. Fine for a future PR.
| # 2 parent 1 child CPFP. First parent pays high fees, second parent pays 0 fees and is | ||
| # fee-bumped by the child. |
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.
comment good
|
Approach ACK |
This PR refactors
RPCPackagesTestto useMiniWalletand removescreate_child_with_parents,make_chain, andcreate_raw_chainfromtest_framework/wallet, as requested in #25965.Close #25965.