Skip to content

Commit

Permalink
pytest: check that listpeerchannels gives the same channel type as re…
Browse files Browse the repository at this point in the history
…turned from fund/openchannel

Could have done this in an earlier commit, but that would be a messy rebase.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Dec 6, 2023
1 parent 78d15e6 commit c6764c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/test_opening.py
Original file line number Diff line number Diff line change
Expand Up @@ -2606,6 +2606,8 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
ret = l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT,
channel_type=ctype + zeroconf)
assert ret['channel_type']['bits'] == ctype + zeroconf
assert only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == ctype + zeroconf
# Note: l2 doesn't show it in listpeerchannels yet...
l1.rpc.fundchannel_cancel(l2.info['id'])

# Zeroconf is refused to l4.
Expand All @@ -2619,6 +2621,8 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
for ctype in ([STATIC_REMOTEKEY], [STATIC_REMOTEKEY, ANCHORS_ZERO_FEE_HTLC_TX]):
ret = l1.rpc.openchannel_init(l3.info['id'], FUNDAMOUNT - 1000, psbt, channel_type=ctype)
assert ret['channel_type']['bits'] == ctype
assert only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == ctype
assert only_one(l3.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == ctype
l1.rpc.openchannel_abort(ret['channel_id'])

# Old anchors not supported for new channels
Expand Down Expand Up @@ -2652,13 +2656,17 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):

ret = l1.rpc.fundchannel_start(l2.info['id'], FUNDAMOUNT, channel_type=[STATIC_REMOTEKEY, ANCHORS_OLD])
assert ret['channel_type']['bits'] == [STATIC_REMOTEKEY, ANCHORS_OLD]
assert only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == [STATIC_REMOTEKEY, ANCHORS_OLD]
# Note: l3 doesn't show it in listpeerchannels yet...
l1.rpc.fundchannel_cancel(l2.info['id'])

l1.rpc.unreserveinputs(psbt)

# Works with fundchannel / multifundchannel
ret = l1.rpc.fundchannel(l2.info['id'], FUNDAMOUNT // 3, channel_type=[STATIC_REMOTEKEY])
assert ret['channel_type']['bits'] == [STATIC_REMOTEKEY]
assert only_one(l1.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == [STATIC_REMOTEKEY]
assert only_one(l2.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == [STATIC_REMOTEKEY]
# FIXME: Check type is actually correct!

# Mine that so we can spend change.
Expand All @@ -2668,3 +2676,5 @@ def test_opening_explicit_channel_type(node_factory, bitcoind):
l1.connect(l3)
ret = l1.rpc.fundchannel(l3.info['id'], FUNDAMOUNT // 3, channel_type=[STATIC_REMOTEKEY])
assert ret['channel_type']['bits'] == [STATIC_REMOTEKEY]
assert only_one(l1.rpc.listpeerchannels(l3.info['id'])['channels'])['channel_type']['bits'] == [STATIC_REMOTEKEY]
assert only_one(l3.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == [STATIC_REMOTEKEY]

0 comments on commit c6764c1

Please sign in to comment.