MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_notify

Function test_notify

tests/test_plugin.py:2761–2823  ·  view source on GitHub ↗

Test that notifications from plugins get ignored

(node_factory)

Source from the content-addressed store, hash-verified

2759
2760
2761def test_notify(node_factory):
2762 """Test that notifications from plugins get ignored"""
2763 plugins = [os.path.join(os.getcwd(), 'tests/plugins/notify.py'),
2764 os.path.join(os.getcwd(), 'tests/plugins/notify2.py')]
2765 l1 = node_factory.get_node(options={'plugin': plugins})
2766
2767 assert l1.rpc.call('make_notify') == 'This worked'
2768 assert l1.rpc.call('call_make_notify') == 'This worked'
2769
2770 out = subprocess.check_output(['cli/lightning-cli',
2771 '--network={}'.format(TEST_NETWORK),
2772 '--lightning-dir={}'
2773 .format(l1.daemon.lightning_dir),
2774 'make_notify']).decode('utf-8').splitlines(keepends=True)
2775 assert out[0] == '# Beginning stage 1\n'
2776 assert out[1] == '\r'
2777 for i in range(100):
2778 assert out[2 + i].startswith("# Stage 1/2 {:>3}/100 |".format(1 + i))
2779 if i == 99:
2780 assert out[2 + i].endswith("|\n")
2781 else:
2782 assert out[2 + i].endswith("|\r")
2783
2784 # These messages are DEBUG level, and default is INFO, so there is no
2785 # "'# Beginning stage 2\n'
2786 assert out[102] == '\r'
2787 for i in range(10):
2788 assert out[103 + i].startswith("# Stage 2/2 {:>2}/10 |".format(1 + i))
2789 if i == 9:
2790 assert out[103 + i].endswith("|\n")
2791 else:
2792 assert out[103 + i].endswith("|\r")
2793 assert out[113] == '"This worked"\n'
2794 assert len(out) == 114
2795
2796 # At debug level, we get the second prompt.
2797 out = subprocess.check_output(['cli/lightning-cli',
2798 '--network={}'.format(TEST_NETWORK),
2799 '--lightning-dir={}'
2800 .format(l1.daemon.lightning_dir),
2801 '-N', 'debug',
2802 'make_notify']).decode('utf-8').splitlines()
2803 assert out[0] == '# Beginning stage 1'
2804 assert out[1] == ''
2805 for i in range(100):
2806 assert out[2 + i].startswith("# Stage 1/2 {:>3}/100 |".format(1 + i))
2807 assert out[2 + i].endswith("|")
2808 assert out[102] == '# Beginning stage 2'
2809 assert out[103] == ''
2810 for i in range(10):
2811 assert out[104 + i].startswith("# Stage 2/2 {:>2}/10 |".format(1 + i))
2812 assert out[104 + i].endswith("|")
2813 assert out[114] == '"This worked"'
2814 assert len(out) == 115
2815
2816 # none suppresses
2817 out = subprocess.check_output(['cli/lightning-cli',
2818 '--network={}'.format(TEST_NETWORK),

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
get_nodeMethod · 0.45
callMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected