From 8796536988c50d0063b864f19a013fbf0aca1d95 Mon Sep 17 00:00:00 2001 From: ShahanaFarooqui Date: Tue, 21 Nov 2023 11:02:03 +1030 Subject: [PATCH] tests/clnrest: Test to confirm that `msat` suffix has been removed from notifications --- tests/test_clnrest.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_clnrest.py b/tests/test_clnrest.py index 18eaee423047..2e42315e7893 100644 --- a/tests/test_clnrest.py +++ b/tests/test_clnrest.py @@ -375,6 +375,29 @@ def test_clnrest_websocket_rune_no_listnotifications(node_factory): assert len([n for n in notifications if n.find('invoice_creation') > 0]) == 0 +@pytest.mark.xfail(strict=True) +def test_clnrest_numeric_msat_notification(node_factory): + """Test that msat fields are integers in notifications also.""" + # start a node with clnrest + rest_port = str(reserve()) + base_url = 'http://127.0.0.1:' + rest_port + l1, l2 = node_factory.get_nodes(2, opts=[{}, {'clnrest-port': rest_port, 'clnrest-protocol': 'http'}]) + node_factory.join_nodes([l1, l2], wait_for_announce=True) + http_session = http_session_with_retry() + + # create an invoice on l2 + inv = l2.rpc.invoice(5000000, 'test_invoice_payment_notification', 'test_invoice_payment_notification_description') + + # create rune authorizing listclnrest-notifications method + rune_clnrest_notifications = l2.rpc.createrune(restrictions=[["method=listclnrest-notifications"]])['rune'] + http_session.headers.update({"rune": rune_clnrest_notifications}) + notifications = notifications_received_via_websocket(l1, base_url, http_session, 'pay', [inv['bolt11']]) + filtered_notifications = [n for n in notifications if 'invoice_creation' in n] + + assert isinstance(filtered_notifications[0]['invoice_creation']['msat'], int) + assert filtered_notifications[0]['invoice_creation']['msat'] == 5000000 + + def test_clnrest_options(node_factory): """Test startup options `clnrest-host`, `clnrest-protocol` and `clnrest-certs`.""" # with invalid port