-
Notifications
You must be signed in to change notification settings - Fork 38.8k
test: refactor: remove hex_str_to_bytes helper
#22593
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
test: refactor: remove hex_str_to_bytes helper
#22593
Conversation
|
Concept ACK |
Zero-1729
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.
Concept and code review ACK ee54626838f014efa9cc858df28e717327075565
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
Use the built-in class method bytes.fromhex() instead, which is available since Python 3.0.
ee54626 to
ca6c154
Compare
|
Rebased on master due to conflict after merge of #22429. For the previous ACK (thanks Zero-1729!), it can be trivially re-reviewed via |
Zero-1729
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.
re-ACK ca6c154, clean rebase.
|
cr ACK ca6c154 |
|
Concept ACK, cr ACK ca6c154 Silly question, shouldn't we also test |
|
FWIW |
|
I slightly prefer the clear |
…version in functional test framework 5a1bef6 test: refactor: remove binascii from test_framework (Zero-1729) Pull request description: This PR continues the work started in PR #22593, regarding using the `bytes` built-in module. In this PR specifically, instances of `binascii`'s methods `hexlify`, `unhexlify`, and `a2b_hex` have been replaced with the build-in `bytes` module's `hex` and `fromhex` methods where appropriate to make bytes <-> hex-string conversions consistent across the functional test files and test_framework. Additionally, certain changes made are based on the following assumption: ``` bytes.hex(data) == binascii.hexlify(data).decode() bytes.hex(data).encode() == binascii.hexlify(data) ``` Ran the functional tests to ensure behaviour is still consistent and changes didn't break existing tests. closes #22605 ACKs for top commit: theStack: Code-review ACK 5a1bef6 🔢 Tree-SHA512: 8f28076cf0580a0d02a156f3e1e94c9badd3d41c3fbdfb2b87cd8a761dde2c94faa5f4c448d6747b1ccc9111c3ef1a1d7b42a11c806b241fa0410b7529e2445f
021daed refactor: replace remaining binascii method calls (Zero-1729) Pull request description: This PR removes the remaining `binascii` method calls outside `test/functional` and `test_framework`, as pointed out here #22619 (review). Follow-up to #22593 and #22619 Closes #22605 ACKs for top commit: josibake: re-ACK 021daed theStack: re-ACK 021daed Tree-SHA512: 2ae9fee8917112c91a5406f219ca70f24cd8902b903db5a61fc2de85ad640d669a772f5c05970be0fcee6ef1cdd32fae2ca5d1ec6dc9798b43352c8160ddde6f
Summary: Use the built-in class method `bytes.fromhex()` instead, which is available since Python 3.0. This is a backport of [[bitcoin/bitcoin#22593 | core#22593]] Test Plan: `ninja check-functional-extended` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11136
Use the built-in class method
bytes.fromhex()instead, which is available since Python 3.0 (https://docs.python.org/3.0/library/stdtypes.html?highlight=fromhex#bytes.fromhex).This would be nice to solve with a scripted-diff, but it's tricky to also tackle the imports (which need to be removed in the same commit, otherwise the linter would complain).