MCPcopy Create free account
hub / github.com/ElementsProject/elements / ZMQTestSetupBlock

Class ZMQTestSetupBlock

test/functional/interface_zmq.py:77–98  ·  view source on GitHub ↗

Helper class for setting up a ZMQ test via the "sync up" procedure. Generates a block on the specified node on instantiation and provides a method to check whether a ZMQ notification matches, i.e. the event was caused by this generated block. Assumes that a notification either contains

Source from the content-addressed store, hash-verified

75
76
77class ZMQTestSetupBlock:
78 """Helper class for setting up a ZMQ test via the "sync up" procedure.
79 Generates a block on the specified node on instantiation and provides a
80 method to check whether a ZMQ notification matches, i.e. the event was
81 caused by this generated block. Assumes that a notification either contains
82 the generated block's hash, it's (coinbase) transaction id, the raw block or
83 raw transaction data.
84 """
85 def __init__(self, test_framework, node):
86 self.block_hash = test_framework.generate(node, 1, sync_fun=test_framework.no_op)[0]
87 coinbase = node.getblock(self.block_hash, 2)['tx'][0]
88 self.tx_hash = coinbase['txid']
89 self.raw_tx = coinbase['hex']
90 self.raw_block = node.getblock(self.block_hash, 0)
91
92 def caused_notification(self, notification):
93 return (
94 self.block_hash in notification
95 or self.tx_hash in notification
96 or self.raw_block in notification
97 or self.raw_tx in notification
98 )
99
100
101class ZMQTest (BitcoinTestFramework):

Callers 1

setup_zmq_testMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected