-
Notifications
You must be signed in to change notification settings - Fork 38.1k
refactor: Replace remaining binascii method calls #22633
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
3a2ad3b
to
33b8a31
Compare
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.
Code-review ACK 33b8a31
It's nice to see that with this PR, there is now only one method left for hex-string/bytes conversions in the functional tests and contrib scripts. Special kudos for also replacing the Python code comment in serfloat_tests.cpp
. I tested this directly in the Python interpreter and it works as expected, i.e. the statement yields True
.
33b8a31
to
b95d5ad
Compare
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 b95d5ad 💯
ACK b95d5ad +1 for consistency! did a code review and everything looks good. also ran the standalone scripts where possible and tested a few individual functions (e.g |
Concept ACK. Let's be sure that this covers all and is the last PR in the series, it's been dragging on for a while. |
I think this is the last PR in this series. No other instances of |
Agreed!
Doing a search in test/function via "git grep -i hex", I unfortunately found yet another variant of converting bin-to-hex that should be fixed (I verified via diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index 6e57107f8..65d90f844 100755
--- a/test/functional/test_framework/messages.py
+++ b/test/functional/test_framework/messages.py
@@ -19,7 +19,6 @@ Classes use __slots__ to ensure extraneous attributes aren't accidentally added
by tests, compromising their intended effect.
"""
from base64 import b32decode, b32encode
-from codecs import encode
import copy
import hashlib
from io import BytesIO
@@ -681,7 +680,7 @@ class CBlockHeader:
r += struct.pack("<I", self.nBits)
r += struct.pack("<I", self.nNonce)
self.sha256 = uint256_from_str(hash256(r))
- self.hash = encode(hash256(r)[::-1], 'hex_codec').decode('ascii')
+ self.hash = hash256(r)[::-1].hex()
def rehash(self):
self.sha256 = None
This one is not using |
b95d5ad
to
021daed
Compare
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 021daed
cc @practicalswift @tryphe given you both reviewed the parent PR. |
re-ACK 021daed |
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.
Posthumous ACK, modulo could have updated the Python example in src/test/serfloat_tests.cpp
-- git grep binascii
takes you there.
Edit: oops, I ran grep from /src instead of root, there are some other ones, idem for git grep hexlify
. Maybe a follow-up if it matters.
This PR also tackled the Python code sample in
Just pulled master locally, running both |
@Zero-1729 You're right! I grepped from the PR branch (edit: nope, another PR branch 😅) sorry for the noise. |
@jonatack No worries, happy to help! 🙏🏾 |
This PR removes the remaining
binascii
method calls outsidetest/functional
andtest_framework
, as pointed out here #22619 (review).Follow-up to #22593 and #22619
Closes #22605