mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
Fix zmq_test.py
This commit is contained in:
parent
7a44dc1956
commit
e37bd6d96c
@ -7,12 +7,18 @@ import configparser
|
|||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
|
from codecs import encode
|
||||||
|
|
||||||
|
from test_framework.mininode import dashhash
|
||||||
from test_framework.test_framework import BitcoinTestFramework, SkipTest
|
from test_framework.test_framework import BitcoinTestFramework, SkipTest
|
||||||
from test_framework.util import (assert_equal,
|
from test_framework.util import (assert_equal,
|
||||||
bytes_to_hex_str,
|
bytes_to_hex_str,
|
||||||
hash256,
|
hash256,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def dashhash_helper(b):
|
||||||
|
return encode(dashhash(b)[::-1], 'hex_codec').decode('ascii')
|
||||||
|
|
||||||
class ZMQTest (BitcoinTestFramework):
|
class ZMQTest (BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
@ -97,7 +103,7 @@ class ZMQTest (BitcoinTestFramework):
|
|||||||
assert_equal(msgSequence, 0) #must be sequence 0 on rawblock
|
assert_equal(msgSequence, 0) #must be sequence 0 on rawblock
|
||||||
|
|
||||||
# Check the hash of the rawblock's header matches generate
|
# Check the hash of the rawblock's header matches generate
|
||||||
assert_equal(genhashes[0], bytes_to_hex_str(hash256(body[:80])))
|
assert_equal(genhashes[0], dashhash_helper(body[:80]))
|
||||||
|
|
||||||
self.log.info("Generate 10 blocks (and 10 coinbase txes)")
|
self.log.info("Generate 10 blocks (and 10 coinbase txes)")
|
||||||
n = 10
|
n = 10
|
||||||
@ -117,7 +123,7 @@ class ZMQTest (BitcoinTestFramework):
|
|||||||
assert_equal(msgSequence, blockcount + 1)
|
assert_equal(msgSequence, blockcount + 1)
|
||||||
blockcount += 1
|
blockcount += 1
|
||||||
if topic == b"rawblock":
|
if topic == b"rawblock":
|
||||||
zmqRawHashed.append(bytes_to_hex_str(hash256(body[:80])))
|
zmqRawHashed.append(dashhash_helper(body[:80]))
|
||||||
msgSequence = struct.unpack('<I', msg[-1])[-1]
|
msgSequence = struct.unpack('<I', msg[-1])[-1]
|
||||||
assert_equal(msgSequence, blockcount)
|
assert_equal(msgSequence, blockcount)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user