Skip to content

Commit b3d4e16

Browse files
cdeckerrustyrussell
authored andcommitted
pytest: Add test for dev-forget-channel
Signed-off-by: Christian Decker <decker.christian@gmail.com>
1 parent d05e8ed commit b3d4e16

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

tests/test_lightningd.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ def test_closing_different_fees(self):
10531053
p.daemon.wait_for_log(' to ONCHAIND_MUTUAL')
10541054

10551055
l1.daemon.wait_for_logs([' to ONCHAIND_MUTUAL'] * num_peers)
1056-
1056+
10571057
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
10581058
def test_permfail(self):
10591059
l1,l2 = self.connect()
@@ -3364,7 +3364,7 @@ def test_cli(self):
33643364
'-J',
33653365
'help', 'command=help']).decode('utf-8')
33663366
j, _ = json.JSONDecoder().raw_decode(out)
3367-
assert 'help [command]' in j['verbose']
3367+
assert 'help [command]' in j['verbose']
33683368

33693369
# Test keyword input (forced)
33703370
out = subprocess.check_output(['cli/lightning-cli',
@@ -3373,7 +3373,7 @@ def test_cli(self):
33733373
'-J', '-k',
33743374
'help', 'command=help']).decode('utf-8')
33753375
j, _ = json.JSONDecoder().raw_decode(out)
3376-
assert 'help [command]' in j['verbose']
3376+
assert 'help [command]' in j['verbose']
33773377

33783378
# Test ordered input (autodetect)
33793379
out = subprocess.check_output(['cli/lightning-cli',
@@ -3382,7 +3382,7 @@ def test_cli(self):
33823382
'-J',
33833383
'help', 'help']).decode('utf-8')
33843384
j, _ = json.JSONDecoder().raw_decode(out)
3385-
assert 'help [command]' in j['verbose']
3385+
assert 'help [command]' in j['verbose']
33863386

33873387
# Test ordered input (forced)
33883388
out = subprocess.check_output(['cli/lightning-cli',
@@ -3391,7 +3391,7 @@ def test_cli(self):
33913391
'-J', '-o',
33923392
'help', 'help']).decode('utf-8')
33933393
j, _ = json.JSONDecoder().raw_decode(out)
3394-
assert 'help [command]' in j['verbose']
3394+
assert 'help [command]' in j['verbose']
33953395

33963396
# Test missing parameters.
33973397
try:
@@ -3405,6 +3405,28 @@ def test_cli(self):
34053405
except:
34063406
pass
34073407

3408+
@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
3409+
def test_forget_channel(self):
3410+
l1 = self.node_factory.get_node()
3411+
l2 = self.node_factory.get_node()
3412+
self.give_funds(l1, 10**6)
3413+
l1.rpc.connect(l2.info['id'], 'localhost', l2.info['port'])
3414+
l1.rpc.fundchannel(l2.info['id'], 10**5)
3415+
3416+
assert len(l1.rpc.listpeers()['peers']) == 1
3417+
3418+
# This should fail, the funding tx is in the mempool and may confirm
3419+
self.assertRaises(ValueError, l1.rpc.dev_forget_channel, l2.info['id'])
3420+
assert len(l1.rpc.listpeers()['peers']) == 1
3421+
3422+
# Forcing should work
3423+
l1.rpc.dev_forget_channel(l2.info['id'], True)
3424+
assert len(l1.rpc.listpeers()['peers']) == 0
3425+
3426+
# And restarting should keep that peer forgotten
3427+
l1.restart()
3428+
assert len(l1.rpc.listpeers()['peers']) == 0
3429+
34083430

34093431
if __name__ == '__main__':
34103432
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)