Skip to content

Commit

Permalink
pytest: Add the test for compact of deprecated close style
Browse files Browse the repository at this point in the history
  • Loading branch information
trueptolemy authored and niftynei committed Oct 10, 2019
1 parent bb5aa77 commit 9d4cccd
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/test_closing.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fixtures import * # noqa: F401,F403
from flaky import flaky
from lightning import RpcError
from utils import only_one, sync_blockheight, wait_for, DEVELOPER, TIMEOUT, VALGRIND, SLOW_MACHINE
from utils import only_one, sync_blockheight, wait_for, DEVELOPER, TIMEOUT, VALGRIND, SLOW_MACHINE, COMPAT

import os
import queue
Expand Down Expand Up @@ -361,6 +361,39 @@ def test_closing_specified_destination(node_factory, bitcoind):
assert 1 == bitcoind.rpc.gettxout(closetxid[idindex[n]], output_num1)['confirmations']


@unittest.skipIf(not COMPAT, "needs COMPAT=1")
def test_deprecated_closing_compat(node_factory, bitcoind):
""" The old-style close command is:
close {id} {force} {timeout}
"""
l1, l2 = node_factory.get_nodes(2, opts=[{'allow-deprecated-apis': True}, {}])
addr = 'bcrt1qeyyk6sl5pr49ycpqyckvmttus5ttj25pd0zpvg'
nodeid = l2.info['id']

l1.rpc.check(command_to_check='close', id=nodeid)
# New-style
l1.rpc.check(command_to_check='close', id=nodeid, unilateraltimeout=10, destination=addr)
l1.rpc.check(command_to_check='close', id=nodeid, unilateraltimeout=0)
l1.rpc.check(command_to_check='close', id=nodeid, destination=addr)
# Old-style
l1.rpc.check(command_to_check='close', id=nodeid, force=False)
l1.rpc.check(command_to_check='close', id=nodeid, force=False, timeout=10)
l1.rpc.check(command_to_check='close', id=nodeid, timeout=10)

l1.rpc.call('check', ['close', nodeid])
# Array(new-style)
l1.rpc.call('check', ['close', nodeid, 10])
l1.rpc.call('check', ['close', nodeid, 0, addr])
l1.rpc.call('check', ['close', nodeid, None, addr])
# Array(old-style)
l1.rpc.call('check', ['close', nodeid, True, 10])
l1.rpc.call('check', ['close', nodeid, False])
l1.rpc.call('check', ['close', nodeid, None, 10])
# Not new-style nor old-style
with pytest.raises(RpcError, match=r'Expected unilerataltimeout to be a number'):
l1.rpc.call('check', ['close', nodeid, "Given enough eyeballs, all bugs are shallow."])


@unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1")
def test_penalty_inhtlc(node_factory, bitcoind, executor, chainparams):
"""Test penalty transaction with an incoming HTLC"""
Expand Down

0 comments on commit 9d4cccd

Please sign in to comment.