aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Lodder <[email protected]>2020-07-22 13:31:13 +0200
committerPatrick Lodder <[email protected]>2020-07-22 13:51:27 +0200
commit89c01f3866a76e0f9d5f5bac76d2b35d3352d1f6 (patch)
tree4e12fca0273a11476cba494d69496a9159c93a8e
parentrpc-tests: fix fundrawtransaction coin amounts to not spend dust (diff)
downloaddiscoin-89c01f3866a76e0f9d5f5bac76d2b35d3352d1f6.tar.xz
discoin-89c01f3866a76e0f9d5f5bac76d2b35d3352d1f6.zip
rpc-tests: don't use binary.hex() or binary.fromhex()
To retain compatibility with multiple python3 versions
-rw-r--r--qa/rpc-tests/test_framework/auxpow.py6
-rw-r--r--qa/rpc-tests/test_framework/scrypt_auxpow.py12
2 files changed, 10 insertions, 8 deletions
diff --git a/qa/rpc-tests/test_framework/auxpow.py b/qa/rpc-tests/test_framework/auxpow.py
index d96516b83..cb1cdff06 100644
--- a/qa/rpc-tests/test_framework/auxpow.py
+++ b/qa/rpc-tests/test_framework/auxpow.py
@@ -17,7 +17,7 @@ def computeAuxpow (block, target, ok):
# Start by building the merge-mining coinbase. The merkle tree
# consists only of the block hash as root.
- coinbase = "fabe" + binascii.hexlify ("m" * 2)
+ coinbase = "fabe" + binascii.hexlify("m" * 2)
coinbase += block
coinbase += "01000000" + ("00" * 4)
@@ -105,7 +105,7 @@ def reverseHex (data):
Flip byte order in the given data (hex string).
"""
- b = bytearray (bytes.fromhex(data))
+ b = bytearray (binascii.unhexlify(data))
b.reverse ()
- return b.hex()
+ return binascii.hexlify(b).decode("ascii")
diff --git a/qa/rpc-tests/test_framework/scrypt_auxpow.py b/qa/rpc-tests/test_framework/scrypt_auxpow.py
index a5f09dada..dda54e28b 100644
--- a/qa/rpc-tests/test_framework/scrypt_auxpow.py
+++ b/qa/rpc-tests/test_framework/scrypt_auxpow.py
@@ -14,6 +14,7 @@
from .auxpow import *
import ltc_scrypt
+import binascii
def computeAuxpowWithChainId (block, target, chainid, ok):
"""
@@ -23,7 +24,7 @@ def computeAuxpowWithChainId (block, target, chainid, ok):
# Start by building the merge-mining coinbase. The merkle tree
# consists only of the block hash as root.
- coinbase = "fabe" + (b"m" * 2).hex()
+ coinbase = "fabe" + binascii.hexlify((b"m" * 2)).decode("ascii")
coinbase += block
coinbase += "01000000" + ("00" * 4)
@@ -82,11 +83,11 @@ def mineScryptBlock (header, target, ok):
for the given target.
"""
- data = bytearray (bytes.fromhex(header))
+ data = bytearray (binascii.unhexlify(header))
while True:
assert data[79] < 255
data[79] += 1
- hexData = data.hex()
+ hexData = binascii.hexlify(data).decode("ascii")
scrypt = getScryptPoW(hexData)
if (ok and scrypt < target) or ((not ok) and scrypt > target):
@@ -100,5 +101,6 @@ def getScryptPoW(hexData):
Actual scrypt pow calculation
"""
- data = bytes.fromhex(hexData)
- return reverseHex(ltc_scrypt.getPoWHash(data).hex())
+ data = binascii.unhexlify(hexData)
+
+ return reverseHex(binascii.hexlify(ltc_scrypt.getPoWHash(data)).decode("ascii"))