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

Function test_channel_state_change_history

tests/test_plugin.py:1009–1042  ·  view source on GitHub ↗

We open and close a channel and check for state_canges entries.

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1007@pytest.mark.openchannel('v1')
1008@pytest.mark.openchannel('v2')
1009def test_channel_state_change_history(node_factory, bitcoind):
1010 """ We open and close a channel and check for state_canges entries.
1011
1012 """
1013 l1, l2 = node_factory.line_graph(2)
1014 scid = l1.get_channel_scid(l2)
1015 l1.rpc.close(scid)
1016
1017 history = l1.rpc.listpeers()['peers'][0]['channels'][0]['state_changes']
1018 if l1.config('experimental-dual-fund'):
1019 assert(history[0]['cause'] == "user")
1020 assert(history[0]['old_state'] == "DUALOPEND_OPEN_INIT")
1021 assert(history[0]['new_state'] == "DUALOPEND_AWAITING_LOCKIN")
1022 assert(history[1]['cause'] == "user")
1023 assert(history[1]['old_state'] == "DUALOPEND_AWAITING_LOCKIN")
1024 assert(history[1]['new_state'] == "CHANNELD_NORMAL")
1025 assert(history[2]['cause'] == "user")
1026 assert(history[2]['new_state'] == "CHANNELD_SHUTTING_DOWN")
1027 assert(history[3]['cause'] == "user")
1028 assert(history[3]['new_state'] == "CLOSINGD_SIGEXCHANGE")
1029 assert(history[4]['cause'] == "user")
1030 assert(history[4]['new_state'] == "CLOSINGD_COMPLETE")
1031 assert(history[4]['message'] == "Closing complete")
1032 else:
1033 assert(history[0]['cause'] == "user")
1034 assert(history[0]['old_state'] == "CHANNELD_AWAITING_LOCKIN")
1035 assert(history[0]['new_state'] == "CHANNELD_NORMAL")
1036 assert(history[1]['cause'] == "user")
1037 assert(history[1]['new_state'] == "CHANNELD_SHUTTING_DOWN")
1038 assert(history[2]['cause'] == "user")
1039 assert(history[2]['new_state'] == "CLOSINGD_SIGEXCHANGE")
1040 assert(history[3]['cause'] == "user")
1041 assert(history[3]['new_state'] == "CLOSINGD_COMPLETE")
1042 assert(history[3]['message'] == "Closing complete")
1043
1044
1045@pytest.mark.developer("without DEVELOPER=1, gossip v slow")

Callers

nothing calls this directly

Calls 5

line_graphMethod · 0.80
get_channel_scidMethod · 0.80
configMethod · 0.80
closeMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected