Skip to content

Commit

Permalink
Test for notifications over grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikDeSmedt committed Feb 16, 2024
1 parent 05cf75b commit 97d68ae
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_cln_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,33 @@ def test_grpc_decode(node_factory):
string=inv.bolt11
))
print(res)


def test_grpc_notifications(node_factory, bitcoind):
grpc_port = reserve()
l1 = node_factory.get_node(options={"grpc-port" : str(grpc_port)})
l2 = node_factory.get_node()

# Test the block_added notification
# Start listening to block added events over grpc
block_added_stream = l1.grpc.SubscribeBlockAdded(clnpb.StreamBlockAddedRequest())
bitcoind.generate_block(10)
for block_added_event in block_added_stream:
assert block_added_event.hash is not None
assert block_added_event.height is not None

# If we don't break out of the loop we'll
# be waiting for ever
break

# Test the connect notification
connect_stream = l1.grpc.SubscribeConnect(clnpb.StreamConnectRequest())
l2.connect(l1)

for connect_event in connect_stream:
assert connect_event.id.hex() == l2.info["hex"]





0 comments on commit 97d68ae

Please sign in to comment.