diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -8,15 +8,18 @@ from test_framework.address import ADDRESS_BCHREG_UNSPENDABLE from test_framework.test_framework import BitcoinTestFramework -from test_framework.messages import CTransaction +from test_framework.messages import CTransaction, hash256 from test_framework.util import ( assert_equal, connect_nodes, - hash256, ) from time import sleep +def hash256_reversed(byte_str): + return hash256(byte_str)[::-1] + + class ZMQSubscriber: def __init__(self, socket, topic): self.sequence = 0 @@ -105,7 +108,7 @@ # Should receive the generated raw block. block = rawblock.receive() - assert_equal(genhashes[x], hash256(block[:80]).hex()) + assert_equal(genhashes[x], hash256_reversed(block[:80]).hex()) if self.is_wallet_compiled(): self.log.info("Wait for tx from second node") @@ -119,7 +122,7 @@ # Should receive the broadcasted raw transaction. hex = rawtx.receive() - assert_equal(payment_txid, hash256(hex).hex()) + assert_equal(payment_txid, hash256_reversed(hex).hex()) self.log.info("Test the getzmqnotifications RPC") assert_equal(self.nodes[0].getzmqnotifications(), [ diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py --- a/test/functional/test_framework/util.py +++ b/test/functional/test_framework/util.py @@ -8,7 +8,6 @@ from binascii import unhexlify from decimal import Decimal, ROUND_DOWN from subprocess import CalledProcessError -import hashlib import inspect import json import logging @@ -229,14 +228,6 @@ return len(bytearray.fromhex(hex_string)) -def hash256(byte_str): - sha256 = hashlib.sha256() - sha256.update(byte_str) - sha256d = hashlib.sha256() - sha256d.update(sha256.digest()) - return sha256d.digest()[::-1] - - def hex_str_to_bytes(hex_str): return unhexlify(hex_str.encode('ascii'))