Skip to content

Commit afc0966

Browse files
committed
Moved and renamed hash256 from util.py to zmq_interface.py
1 parent b799ebc commit afc0966

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

test/functional/interface_zmq.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
99
from test_framework.test_framework import BitcoinTestFramework
10-
from test_framework.messages import CTransaction
11-
from test_framework.util import (
12-
assert_equal,
13-
hash256,
14-
)
10+
from test_framework.messages import CTransaction, hash256
11+
from test_framework.util import assert_equal
1512
from io import BytesIO
1613

1714
ADDRESS = "tcp://127.0.0.1:28332"
1815

16+
def hash256_reversed(byte_str):
17+
return hash256(byte_str)[::-1]
18+
1919
class ZMQSubscriber:
2020
def __init__(self, socket, topic):
2121
self.sequence = 0
@@ -103,7 +103,7 @@ def _zmq_test(self):
103103

104104
# Should receive the generated raw block.
105105
block = self.rawblock.receive()
106-
assert_equal(genhashes[x], hash256(block[:80]).hex())
106+
assert_equal(genhashes[x], hash256_reversed(block[:80]).hex())
107107

108108
if self.is_wallet_compiled():
109109
self.log.info("Wait for tx from second node")
@@ -116,7 +116,7 @@ def _zmq_test(self):
116116

117117
# Should receive the broadcasted raw transaction.
118118
hex = self.rawtx.receive()
119-
assert_equal(payment_txid, hash256(hex).hex())
119+
assert_equal(payment_txid, hash256_reversed(hex).hex())
120120

121121

122122
self.log.info("Test the getzmqnotifications RPC")

test/functional/test_framework/util.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from base64 import b64encode
88
from binascii import unhexlify
99
from decimal import Decimal, ROUND_DOWN
10-
import hashlib
1110
import inspect
1211
import json
1312
import logging
@@ -183,12 +182,6 @@ def check_json_precision():
183182
def count_bytes(hex_string):
184183
return len(bytearray.fromhex(hex_string))
185184

186-
def hash256(byte_str):
187-
sha256 = hashlib.sha256()
188-
sha256.update(byte_str)
189-
sha256d = hashlib.sha256()
190-
sha256d.update(sha256.digest())
191-
return sha256d.digest()[::-1]
192185

193186
def hex_str_to_bytes(hex_str):
194187
return unhexlify(hex_str.encode('ascii'))

0 commit comments

Comments
 (0)