aboutsummaryrefslogtreecommitdiff
path: root/test/functional/interface_zmq.py
diff options
context:
space:
mode:
authornthumann <me@n-thumann.de>2021-05-26 19:38:38 +0200
committernthumann <me@n-thumann.de>2021-06-20 16:56:08 +0200
commit8abe5703a9bb76bc92204a6f69775790e96208fa (patch)
tree3223e78f9338ebe00d562bd98e60b66638042107 /test/functional/interface_zmq.py
parentded449b726e47f35798ef1c4b1e59123a0dc2b61 (diff)
downloadbitcoin-8abe5703a9bb76bc92204a6f69775790e96208fa.tar.xz
test: Add IPv6 test to zmq
Diffstat (limited to 'test/functional/interface_zmq.py')
-rwxr-xr-xtest/functional/interface_zmq.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py
index 94e162b748..c23dad6ec9 100755
--- a/test/functional/interface_zmq.py
+++ b/test/functional/interface_zmq.py
@@ -13,6 +13,7 @@ from test_framework.util import (
assert_equal,
assert_raises_rpc_error,
)
+from test_framework.netutil import test_ipv6_local
from io import BytesIO
from time import sleep
@@ -108,6 +109,7 @@ class ZMQTest (BitcoinTestFramework):
self.test_mempool_sync()
self.test_reorg()
self.test_multiple_interfaces()
+ self.test_ipv6()
finally:
# Destroy the ZMQ context.
self.log.debug("Destroying ZMQ context")
@@ -115,10 +117,12 @@ class ZMQTest (BitcoinTestFramework):
# Restart node with the specified zmq notifications enabled, subscribe to
# all of them and return the corresponding ZMQSubscriber objects.
- def setup_zmq_test(self, services, *, recv_timeout=60, sync_blocks=True):
+ def setup_zmq_test(self, services, *, recv_timeout=60, sync_blocks=True, ipv6=False):
subscribers = []
for topic, address in services:
socket = self.ctx.socket(zmq.SUB)
+ if ipv6:
+ socket.setsockopt(zmq.IPV6, 1)
subscribers.append(ZMQSubscriber(socket, topic.encode()))
self.restart_node(0, ["-zmqpub%s=%s" % (topic, address) for topic, address in services] +
@@ -557,5 +561,22 @@ class ZMQTest (BitcoinTestFramework):
assert_equal(self.nodes[0].getbestblockhash(), subscribers[0].receive().hex())
assert_equal(self.nodes[0].getbestblockhash(), subscribers[1].receive().hex())
+ def test_ipv6(self):
+ if not test_ipv6_local():
+ self.log.info("Skipping IPv6 test, because IPv6 is not supported.")
+ return
+ self.log.info("Testing IPv6")
+ # Set up subscriber using IPv6 loopback address
+ subscribers = self.setup_zmq_test([
+ ("hashblock", "tcp://[::1]:28332")
+ ], ipv6=True)
+
+ # Generate 1 block in nodes[0]
+ self.nodes[0].generatetoaddress(1, ADDRESS_BCRT1_UNSPENDABLE)
+
+ # Should receive the same block hash
+ assert_equal(self.nodes[0].getbestblockhash(), subscribers[0].receive().hex())
+
+
if __name__ == '__main__':
ZMQTest().main()