Skip to content

Commit

Permalink
tests: use listpeerchannels.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincenzopalazzo authored and rustyrussell committed Jan 13, 2023
1 parent 1fa3233 commit a2347c7
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 289 deletions.
2 changes: 1 addition & 1 deletion tests/test_bookkeeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ def test_rebalance_tracking(node_factory, bitcoind):

wait_for(lambda: 'invoice' not in [ev['tag'] for ev in l1.rpc.bkpr_listincome()['income_events']])
inc_evs = l1.rpc.bkpr_listincome()['income_events']
outbound_chan_id = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['channel_id']
outbound_chan_id = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['channel_id']

outbound_ev = only_one([ev for ev in inc_evs if ev['tag'] == 'rebalance_fee'])
assert outbound_ev['account'] == outbound_chan_id
Expand Down
101 changes: 52 additions & 49 deletions tests/test_closing.py

Large diffs are not rendered by default.

183 changes: 98 additions & 85 deletions tests/test_connection.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def test_max_channel_id(node_factory, bitcoind):
l2.wait_for_channel_onchain(l1.info['id'])

bitcoind.generate_block(101)
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'])['channels'] == [])
wait_for(lambda: only_one(l2.rpc.listpeers()['peers'])['channels'] == [])
wait_for(lambda: l1.rpc.listpeerchannels()['channels'] == [])
wait_for(lambda: l2.rpc.listpeerchannels()['channels'] == [])

# Stop l2, and restart
l2.stop()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_gossip.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@ def test_gossip_query_channel_range(node_factory, bitcoind, chainparams):
# Make sure l4 has received all the gossip.
l4.daemon.wait_for_logs(['Received node_announcement for node ' + n.info['id'] for n in (l1, l2, l3)])

scid12 = only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'][0]['short_channel_id']
scid23 = only_one(l3.rpc.listpeers(l2.info['id'])['peers'])['channels'][0]['short_channel_id']
scid12 = l1.rpc.listpeerchannels(l2.info['id'])['channels'][0]['short_channel_id']
scid23 = l3.rpc.listpeerchannels(l2.info['id'])['channels'][0]['short_channel_id']
block12 = int(scid12.split('x')[0])
block23 = int(scid23.split('x')[0])

Expand Down Expand Up @@ -1419,7 +1419,7 @@ def test_gossip_notices_close(node_factory, bitcoind):
node_announcement = l1.daemon.is_in_log(r'\[IN\] 0101').split(' ')[-1][:-1]

txid = l2.rpc.close(l3.info['id'])['txid']
wait_for(lambda: only_one(l2.rpc.listpeers(l3.info['id'])['peers'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
wait_for(lambda: l2.rpc.listpeerchannels(l3.info['id'])['channels'][0]['state'] == 'CLOSINGD_COMPLETE')
bitcoind.generate_block(13, txid)

wait_for(lambda: l1.rpc.listchannels()['channels'] == [])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_invoice_routeboost(node_factory, bitcoind):
# Route array has single route with single element.
r = only_one(only_one(l1.rpc.decodepay(inv['bolt11'])['routes']))
assert r['pubkey'] == l1.info['id']
assert r['short_channel_id'] == l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['short_channel_id']
assert r['short_channel_id'] == l2.rpc.listpeerchannels(l1.info['id'])['channels'][0]['short_channel_id']
assert r['fee_base_msat'] == 1
assert r['fee_proportional_millionths'] == 10
assert r['cltv_expiry_delta'] == 6
Expand Down Expand Up @@ -233,7 +233,7 @@ def test_invoice_routeboost_private(node_factory, bitcoind):
# Make sure channel is totally public.
wait_for(lambda: [c['public'] for c in l2.rpc.listchannels(scid_dummy)['channels']] == [True, True])

alias = only_one(only_one(l1.rpc.listpeers(l2.info['id'])['peers'])['channels'])['alias']['local']
alias = only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['alias']['local']
# Since there's only one route, it will reluctantly hint that even
# though it's private
inv = l2.rpc.invoice(amount_msat=123456, label="inv0", description="?")
Expand Down
8 changes: 4 additions & 4 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ def test_funding_reorg_private(node_factory, bitcoind):
bitcoind.generate_block(1) # height 106

daemon = 'DUALOPEND' if l1.config('experimental-dual-fund') else 'CHANNELD'
wait_for(lambda: only_one(l1.rpc.listpeers()['peers'][0]['channels'])['status']
wait_for(lambda: only_one(l1.rpc.listpeerchannels()['channels'])['status']
== ['{}_AWAITING_LOCKIN:Funding needs 1 more confirmations to be ready.'.format(daemon)])
bitcoind.generate_block(1) # height 107
l1.wait_channel_active('106x1x0')
Expand Down Expand Up @@ -1325,7 +1325,7 @@ def no_more_blocks(req):
bitcoind.generate_block(1)
l1.daemon.wait_for_log(r'Peer transient failure .* short_channel_id changed to 104x1x0 \(was 103x1x0\)')

wait_for(lambda: only_one(l2.rpc.listpeers()['peers'][0]['channels'])['status'] == [
wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['status'] == [
'CHANNELD_NORMAL:Reconnected, and reestablished.',
'CHANNELD_NORMAL:Channel ready for use. They need our announcement signatures.'])

Expand All @@ -1335,7 +1335,7 @@ def no_more_blocks(req):
wait_for(lambda: chan_active(l2, '104x1x0', True))
assert l2.rpc.listchannels('103x1x0')['channels'] == []

wait_for(lambda: only_one(l2.rpc.listpeers()['peers'][0]['channels'])['status'] == [
wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['status'] == [
'CHANNELD_NORMAL:Reconnected, and reestablished.',
'CHANNELD_NORMAL:Channel ready for use. Channel announced.'])

Expand Down Expand Up @@ -2663,7 +2663,7 @@ def test_listforwards_and_listhtlcs(node_factory, bitcoind):
# Once channels are gone, htlcs are gone.
for n in (l1, l2, l3, l4):
# They might reconnect, but still will have no channels
wait_for(lambda: all(p['channels'] == [] for p in n.rpc.listpeers()['peers']))
wait_for(lambda: n.rpc.listpeerchannels()['channels'] == [])
assert n.rpc.listhtlcs() == {'htlcs': []}

# But forwards are not forgotten!
Expand Down
Loading

0 comments on commit a2347c7

Please sign in to comment.