aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-08-21 16:29:48 +0200
committerMarcoFalke <falke.marco@gmail.com>2021-08-21 16:29:55 +0200
commitf5a406f003a060325128db47552089b3254044e3 (patch)
tree7395718a5c7572217ec9c7d71836d82448d68cc3 /test
parent4fc15d15667d9d9c4fb5515ce73c05b4596298ec (diff)
parent021daedfa100defad553d69cd3d628aaa5bc7caf (diff)
downloadbitcoin-f5a406f003a060325128db47552089b3254044e3.tar.xz
Merge bitcoin/bitcoin#22633: refactor: Replace remaining binascii method calls
021daedfa100defad553d69cd3d628aaa5bc7caf 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 https://github.com/bitcoin/bitcoin/pull/22619#pullrequestreview-722153458. Follow-up to #22593 and #22619 Closes #22605 ACKs for top commit: josibake: re-ACK https://github.com/bitcoin/bitcoin/pull/22633/commits/021daedfa100defad553d69cd3d628aaa5bc7caf theStack: re-ACK 021daedfa100defad553d69cd3d628aaa5bc7caf Tree-SHA512: 2ae9fee8917112c91a5406f219ca70f24cd8902b903db5a61fc2de85ad640d669a772f5c05970be0fcee6ef1cdd32fae2ca5d1ec6dc9798b43352c8160ddde6f
Diffstat (limited to 'test')
-rwxr-xr-xtest/functional/test_framework/messages.py3
-rwxr-xr-xtest/util/bitcoin-util-test.py3
2 files changed, 2 insertions, 4 deletions
diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py
index 6e57107f86..65d90f8448 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
diff --git a/test/util/bitcoin-util-test.py b/test/util/bitcoin-util-test.py
index 7b1cc2b031..aa8fd6eee5 100755
--- a/test/util/bitcoin-util-test.py
+++ b/test/util/bitcoin-util-test.py
@@ -10,7 +10,6 @@ Runs automatically during `make check`.
Can also be run manually."""
import argparse
-import binascii
import configparser
import difflib
import json
@@ -167,7 +166,7 @@ def parse_output(a, fmt):
if fmt == 'json': # json: compare parsed data
return json.loads(a)
elif fmt == 'hex': # hex: parse and compare binary data
- return binascii.a2b_hex(a.strip())
+ return bytes.fromhex(a.strip())
else:
raise NotImplementedError("Don't know how to compare %s" % fmt)