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

Function test_forget_channel

tests/test_connection.py:2584–2609  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

2582@pytest.mark.openchannel('v1')
2583@pytest.mark.openchannel('v2')
2584def test_forget_channel(node_factory):
2585 l1 = node_factory.get_node()
2586 l2 = node_factory.get_node()
2587 l1.fundwallet(10**6)
2588 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2589 l1.rpc.fundchannel(l2.info['id'], 10**5)
2590
2591 assert len(l1.rpc.listpeers()['peers']) == 1
2592
2593 # This should fail, the funding tx is in the mempool and may confirm
2594 with pytest.raises(RpcError, match=r'Cowardly refusing to forget channel'):
2595 l1.rpc.dev_forget_channel(l2.info['id'])
2596
2597 assert len(l1.rpc.listpeers()['peers']) == 1
2598
2599 # Forcing should work
2600 l1.rpc.dev_forget_channel(l2.info['id'], True)
2601 wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'] == [])
2602
2603 # And restarting should keep that peer forgotten
2604 l1.restart()
2605 assert len(l1.rpc.listpeers()['peers']) == 0
2606
2607 # The entry in the channels table should still be there
2608 assert l1.db_query("SELECT count(*) as c FROM channels;")[0]['c'] == 1
2609 assert l2.db_query("SELECT count(*) as c FROM channels;")[0]['c'] == 1
2610
2611
2612@pytest.mark.openchannel('v1')

Callers

nothing calls this directly

Calls 10

wait_forFunction · 0.90
only_oneFunction · 0.90
fundwalletMethod · 0.80
dev_forget_channelMethod · 0.80
restartMethod · 0.80
db_queryMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected