test: check more details on zmq raw block response

This commit is contained in:
Andrew Toth 2024-03-12 12:47:01 -04:00
parent 38265cc14e
commit 0865ab8712
No known key found for this signature in database
GPG Key ID: 60007AFC8938B018

View File

@ -5,6 +5,7 @@
"""Test the ZMQ notification interface.""" """Test the ZMQ notification interface."""
import struct import struct
from time import sleep from time import sleep
from io import BytesIO
from test_framework.address import ( from test_framework.address import (
ADDRESS_BCRT1_P2WSH_OP_TRUE, ADDRESS_BCRT1_P2WSH_OP_TRUE,
@ -17,6 +18,7 @@ from test_framework.blocktools import (
) )
from test_framework.test_framework import BitcoinTestFramework from test_framework.test_framework import BitcoinTestFramework
from test_framework.messages import ( from test_framework.messages import (
CBlock,
hash256, hash256,
tx_from_hex, tx_from_hex,
) )
@ -203,8 +205,13 @@ class ZMQTest (BitcoinTestFramework):
assert_equal(tx.hash, txid.hex()) assert_equal(tx.hash, txid.hex())
# Should receive the generated raw block. # Should receive the generated raw block.
block = rawblock.receive() hex = rawblock.receive()
assert_equal(genhashes[x], hash256_reversed(block[:80]).hex()) block = CBlock()
block.deserialize(BytesIO(hex))
assert block.is_valid()
assert_equal(block.vtx[0].hash, tx.hash)
assert_equal(len(block.vtx), 1)
assert_equal(genhashes[x], hash256_reversed(hex[:80]).hex())
# Should receive the generated block hash. # Should receive the generated block hash.
hash = hashblock.receive().hex() hash = hashblock.receive().hex()