Skip to content

Commit

Permalink
tests: Check that optional channel exists
Browse files Browse the repository at this point in the history
Check that an optional channel exists before accessing the attr.

Please note that the channel array on the list_peers call got
deprecated and is going to be removed after v24.02.

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed May 19, 2024
1 parent d22b507 commit 126ee60
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/gl-testing/tests/test_gl_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def test_configure_close_to_addr(node_factory, clients, bitcoind):
l2.rpc.fundchannel(c.node_id.hex(), 'all')
bitcoind.generate_block(1, wait_for_mempool=1)

# the channels array is optional
wait_for(lambda: hasattr(gl1.list_peers().peers[0], "channels"))
wait_for(lambda:
gl1.list_peers().peers[0].channels[0].state == 2
)
Expand Down
6 changes: 6 additions & 0 deletions libs/gl-testing/tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ def test_node_invoice_amountless(bitcoind, node_factory, clients):
amount=clnpb.AmountOrAll(amount=clnpb.Amount(msat=10**9))
)
bitcoind.generate_block(6, wait_for_mempool=1)

# the channels array is optional
wait_for(lambda: hasattr(gl1.list_peers().peers[0], "channels"))
wait_for(lambda: gl1.list_peers().peers[0].channels[0].state == 2) # CHANNELD_NORMAL

# Generate an invoice without amount:
Expand Down Expand Up @@ -201,6 +204,9 @@ def test_node_listpays_preimage(clients, node_factory, bitcoind):
amount=clnpb.AmountOrAll(amount=clnpb.Amount(msat=10**9))
)
bitcoind.generate_block(6, wait_for_mempool=1)

# the channels array is optional
wait_for(lambda: hasattr(gl1.list_peers().peers[0], "channels"))
wait_for(lambda: gl1.list_peers().peers[0].channels[0].state == 2) # CHANNELD_NORMAL

preimage = "00"*32
Expand Down

0 comments on commit 126ee60

Please sign in to comment.