We open and close a channel and check notifications both sides. The misc_notifications.py plugin logs `channel_state_changed` events.
(node_factory, bitcoind)
| 857 | @pytest.mark.openchannel('v1') |
| 858 | @pytest.mark.openchannel('v2') |
| 859 | def test_channel_state_changed_bilateral(node_factory, bitcoind): |
| 860 | """ We open and close a channel and check notifications both sides. |
| 861 | |
| 862 | The misc_notifications.py plugin logs `channel_state_changed` events. |
| 863 | """ |
| 864 | opts = {"plugin": os.path.join(os.getcwd(), "tests/plugins/misc_notifications.py")} |
| 865 | l1, l2 = node_factory.line_graph(2, opts=opts) |
| 866 | |
| 867 | l1_id = l1.rpc.getinfo()["id"] |
| 868 | l2_id = l2.rpc.getinfo()["id"] |
| 869 | cid = l1.get_channel_id(l2) |
| 870 | scid = l1.get_channel_scid(l2) |
| 871 | |
| 872 | # a helper that gives us the next channel_state_changed log entry |
| 873 | def wait_for_event(node): |
| 874 | msg = node.daemon.wait_for_log("plugin-misc_notifications.py: channel_state_changed.*new_state.*") |
| 875 | event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0]) |
| 876 | return event |
| 877 | |
| 878 | # check channel 'opener' and 'closer' within this testcase ... |
| 879 | assert(l1.rpc.listpeerchannels()['channels'][0]['opener'] == 'local') |
| 880 | assert(l2.rpc.listpeerchannels()['channels'][0]['opener'] == 'remote') |
| 881 | # the 'closer' should be missing initially |
| 882 | assert 'closer' not in l1.rpc.listpeerchannels()['channels'][0] |
| 883 | assert 'closer' not in l2.rpc.listpeerchannels()['channels'][0] |
| 884 | |
| 885 | if l1.config('experimental-dual-fund'): |
| 886 | # Dual funded channels go through three state transitions. |
| 887 | event1a, event1b, event1c = wait_for_event(l1), wait_for_event(l1), wait_for_event(l1) |
| 888 | event2a, event2b, event2c = wait_for_event(l2), wait_for_event(l2), wait_for_event(l2) |
| 889 | |
| 890 | for ev in [event1a, event1b]: |
| 891 | assert(ev['peer_id'] == l2_id) # we only test these IDs the first time |
| 892 | assert(ev['channel_id'] == cid) |
| 893 | assert('short_channel_id' not in ev) # Missing until locked in |
| 894 | assert(ev['cause'] == "remote") |
| 895 | |
| 896 | for ev in [event2a, event2b]: |
| 897 | assert(ev['peer_id'] == l1_id) # we only test these IDs the first time |
| 898 | assert(ev['channel_id'] == cid) |
| 899 | assert('short_channel_id' not in ev) # Missing until locked in |
| 900 | assert(ev['cause'] == "remote") |
| 901 | |
| 902 | for ev in [event1a, event2a]: |
| 903 | assert(ev['old_state'] == "DUALOPEND_OPEN_INIT") |
| 904 | assert(ev['new_state'] == "DUALOPEND_OPEN_COMMIT_READY") |
| 905 | assert(ev['message'] == "Ready to send our commitment sigs") |
| 906 | |
| 907 | for ev in [event1b, event2b]: |
| 908 | assert(ev['old_state'] == "DUALOPEND_OPEN_COMMIT_READY") |
| 909 | assert(ev['new_state'] == "DUALOPEND_OPEN_COMMITTED") |
| 910 | assert(ev['message'] == "Commitment transaction committed") |
| 911 | |
| 912 | for ev in [event1c, event2c]: |
| 913 | assert(ev['old_state'] == "DUALOPEND_OPEN_COMMITTED") |
| 914 | assert(ev['new_state'] == "DUALOPEND_AWAITING_LOCKIN") |
| 915 | assert(ev['message'] == "Sigs exchanged, waiting for lock-in") |
| 916 | else: |
nothing calls this directly
no test coverage detected