Test that pyln-client plugins can send notifications.
(node_factory)
| 3031 | |
| 3032 | |
| 3033 | def test_pyln_request_notify(node_factory): |
| 3034 | """Test that pyln-client plugins can send notifications. |
| 3035 | """ |
| 3036 | plugin_path = os.path.join( |
| 3037 | os.path.dirname(__file__), 'plugins/countdown.py' |
| 3038 | ) |
| 3039 | l1 = node_factory.get_node(options={'plugin': plugin_path}) |
| 3040 | notifications = [] |
| 3041 | |
| 3042 | def n(*args, message, **kwargs): |
| 3043 | print("Got a notification:", message) |
| 3044 | notifications.append(message) |
| 3045 | |
| 3046 | with l1.rpc.notify(n): |
| 3047 | l1.rpc.countdown(10) |
| 3048 | |
| 3049 | expected = ['{}/10'.format(i) for i in range(10)] |
| 3050 | assert expected == notifications |
| 3051 | |
| 3052 | # Calling without the context manager we should not get any notifications |
| 3053 | notifications = [] |
| 3054 | l1.rpc.countdown(10) |
| 3055 | assert notifications == [] |
| 3056 | |
| 3057 | |
| 3058 | def test_self_disable(node_factory): |