We open and close a channel and check notifications both sides. The misc_notifications.py plugin logs `channel_state_changed` events.
(node_factory, bitcoind)
| 754 | @pytest.mark.openchannel('v1') |
| 755 | @pytest.mark.openchannel('v2') |
| 756 | def test_channel_state_changed_bilateral(node_factory, bitcoind): |
| 757 | """ We open and close a channel and check notifications both sides. |
| 758 | |
| 759 | The misc_notifications.py plugin logs `channel_state_changed` events. |
| 760 | """ |
| 761 | opts = {"plugin": os.path.join(os.getcwd(), "tests/plugins/misc_notifications.py")} |
| 762 | l1, l2 = node_factory.line_graph(2, opts=opts) |
| 763 | |
| 764 | l1_id = l1.rpc.getinfo()["id"] |
| 765 | l2_id = l2.rpc.getinfo()["id"] |
| 766 | cid = l1.get_channel_id(l2) |
| 767 | scid = l1.get_channel_scid(l2) |
| 768 | |
| 769 | # a helper that gives us the next channel_state_changed log entry |
| 770 | def wait_for_event(node): |
| 771 | msg = node.daemon.wait_for_log("channel_state_changed.*new_state.*") |
| 772 | event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0]) |
| 773 | return event |
| 774 | |
| 775 | # check channel 'opener' and 'closer' within this testcase ... |
| 776 | assert(l1.rpc.listpeers()['peers'][0]['channels'][0]['opener'] == 'local') |
| 777 | assert(l2.rpc.listpeers()['peers'][0]['channels'][0]['opener'] == 'remote') |
| 778 | # the 'closer' should be missing initially |
| 779 | assert 'closer' not in l1.rpc.listpeers()['peers'][0]['channels'][0] |
| 780 | assert 'closer' not in l2.rpc.listpeers()['peers'][0]['channels'][0] |
| 781 | |
| 782 | event1 = wait_for_event(l1) |
| 783 | event2 = wait_for_event(l2) |
| 784 | assert(event1['peer_id'] == l2_id) # we only test these IDs the first time |
| 785 | assert(event1['channel_id'] == cid) |
| 786 | assert(event1['short_channel_id'] is None) # None until locked in |
| 787 | assert(event1['cause'] == "user") |
| 788 | |
| 789 | assert(event2['peer_id'] == l1_id) # we only test these IDs the first time |
| 790 | assert(event2['channel_id'] == cid) |
| 791 | assert(event2['short_channel_id'] is None) # None until locked in |
| 792 | assert(event2['cause'] == "remote") |
| 793 | |
| 794 | for ev in [event1, event2]: |
| 795 | # Dual funded channels |
| 796 | if l1.config('experimental-dual-fund'): |
| 797 | assert(ev['old_state'] == "DUALOPEND_OPEN_INIT") |
| 798 | assert(ev['new_state'] == "DUALOPEND_AWAITING_LOCKIN") |
| 799 | assert(ev['message'] == "Sigs exchanged, waiting for lock-in") |
| 800 | else: |
| 801 | assert(ev['old_state'] == "unknown") |
| 802 | assert(ev['new_state'] == "CHANNELD_AWAITING_LOCKIN") |
| 803 | assert(ev['message'] == "new channel opened") |
| 804 | |
| 805 | event1 = wait_for_event(l1) |
| 806 | event2 = wait_for_event(l2) |
| 807 | assert(event1['short_channel_id'] == scid) |
| 808 | if l1.config('experimental-dual-fund'): |
| 809 | assert(event1['old_state'] == "DUALOPEND_AWAITING_LOCKIN") |
| 810 | else: |
| 811 | assert(event1['old_state'] == "CHANNELD_AWAITING_LOCKIN") |
| 812 | assert(event1['new_state'] == "CHANNELD_NORMAL") |
| 813 | assert(event1['cause'] == "user") |
nothing calls this directly
no test coverage detected