diff options
| -rw-r--r-- | qa/rpc-tests/test_framework/auxpow.py | 6 | ||||
| -rw-r--r-- | qa/rpc-tests/test_framework/scrypt_auxpow.py | 12 |
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")) |