We open, disconnect, force-close a channel and check for notifications. The misc_notifications.py plugin logs `channel_state_changed` events.
(node_factory, bitcoind)
| 1035 | @pytest.mark.openchannel('v1') |
| 1036 | @pytest.mark.openchannel('v2') |
| 1037 | def test_channel_state_changed_unilateral(node_factory, bitcoind): |
| 1038 | """ We open, disconnect, force-close a channel and check for notifications. |
| 1039 | |
| 1040 | The misc_notifications.py plugin logs `channel_state_changed` events. |
| 1041 | """ |
| 1042 | opts = {"plugin": os.path.join(os.getcwd(), "tests/plugins/misc_notifications.py"), |
| 1043 | "allow_warning": True, |
| 1044 | 'may_reconnect': True} |
| 1045 | |
| 1046 | l1, l2 = node_factory.line_graph(2, opts=opts) |
| 1047 | |
| 1048 | l1_id = l1.rpc.getinfo()["id"] |
| 1049 | cid = l1.get_channel_id(l2) |
| 1050 | scid = l1.get_channel_scid(l2) |
| 1051 | |
| 1052 | # a helper that gives us the next channel_state_changed log entry |
| 1053 | def wait_for_event(node): |
| 1054 | msg = node.daemon.wait_for_log("plugin-misc_notifications.py: channel_state_changed.*new_state.*") |
| 1055 | event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0]) |
| 1056 | return event |
| 1057 | |
| 1058 | event2 = wait_for_event(l2) |
| 1059 | assert(event2['peer_id'] == l1_id) |
| 1060 | assert(event2['channel_id'] == cid) |
| 1061 | assert('short_channel_id' not in event2) |
| 1062 | assert(event2['cause'] == "remote") |
| 1063 | |
| 1064 | if l2.config('experimental-dual-fund'): |
| 1065 | assert(event2['old_state'] == "DUALOPEND_OPEN_INIT") |
| 1066 | assert(event2['new_state'] == "DUALOPEND_OPEN_COMMIT_READY") |
| 1067 | assert(event2['message'] == "Ready to send our commitment sigs") |
| 1068 | |
| 1069 | event2 = wait_for_event(l2) |
| 1070 | assert event2['old_state'] == "DUALOPEND_OPEN_COMMIT_READY" |
| 1071 | assert event2['new_state'] == "DUALOPEND_OPEN_COMMITTED" |
| 1072 | assert event2['message'] == "Commitment transaction committed" |
| 1073 | |
| 1074 | event2 = wait_for_event(l2) |
| 1075 | assert event2['old_state'] == "DUALOPEND_OPEN_COMMITTED" |
| 1076 | assert event2['new_state'] == "DUALOPEND_AWAITING_LOCKIN" |
| 1077 | assert event2['message'] == "Sigs exchanged, waiting for lock-in" |
| 1078 | else: |
| 1079 | assert "unknown" not in event2 |
| 1080 | assert(event2['new_state'] == "CHANNELD_AWAITING_LOCKIN") |
| 1081 | assert(event2['message'] == "new channel opened") |
| 1082 | |
| 1083 | event2 = wait_for_event(l2) |
| 1084 | assert(event2['short_channel_id'] == scid) |
| 1085 | if l2.config('experimental-dual-fund'): |
| 1086 | assert(event2['old_state'] == "DUALOPEND_AWAITING_LOCKIN") |
| 1087 | else: |
| 1088 | assert(event2['old_state'] == "CHANNELD_AWAITING_LOCKIN") |
| 1089 | assert(event2['new_state'] == "CHANNELD_NORMAL") |
| 1090 | assert(event2['cause'] == "remote") |
| 1091 | assert(event2['message'] == "Lockin complete") |
| 1092 | |
| 1093 | # close channel unilaterally and look for stateful events |
| 1094 | l1.rpc.stop() |
nothing calls this directly
no test coverage detected