Skip to content

Commit

Permalink
tests: Replace rpc call to fetch peer channels
Browse files Browse the repository at this point in the history
Replace list_peers().channel (which is optional)  with
list_peer_channels().

Signed-off-by: Peter Neuroth <[email protected]>
  • Loading branch information
nepet committed May 19, 2024
1 parent 7ae91e2 commit 6af1e57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
23 changes: 11 additions & 12 deletions libs/gl-testing/tests/test_gl_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,23 @@ def check(gl1):
wait_for(lambda: check(gl1))

def test_configure_close_to_addr(node_factory, clients, bitcoind):
l1, l2 = node_factory.line_graph(2)
l2.fundwallet(sats=2*10**6)

l1 = node_factory.get_node()
c = clients.new()
c.register(configure=True)
gl1 = c.node()

s = c.signer().run_in_thread()
gl1.connect_peer(l2.info['id'], f'127.0.0.1:{l2.daemon.port}')

s = c.signer().run_in_thread()

close_to_addr = bitcoind.getnewaddress()
gl1.configure(close_to_addr)

gl1.connect_peer(l1.info['id'], f'127.0.0.1:{l1.daemon.port}')

l2.rpc.fundchannel(c.node_id.hex(), 'all')
bitcoind.generate_block(1, wait_for_mempool=1)
l1.fundwallet(sats=2*10**6)
l1.rpc.fundchannel(c.node_id.hex(), 'all')
bitcoind.generate_block(6, wait_for_mempool=1)

wait_for(lambda:
gl1.list_peers().peers[0].channels[0].state == 2
)
wait_for(lambda: len(gl1.list_peer_channels().channels) > 0)
wait_for(lambda: gl1.list_peer_channels().channels[0].state == 2)

assert gl1.list_peers().peers[0].channels[0].close_to_addr == close_to_addr
assert gl1.list_peer_channels().channels[0].close_to_addr == close_to_addr
13 changes: 10 additions & 3 deletions libs/gl-testing/tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def test_node_network(node_factory, clients, bitcoind):
bitcoind.generate_block(6, wait_for_mempool=1)

# Now wait for the channel to confirm
wait_for(lambda: gl1.list_peers().peers[0].channels[0].state == 'CHANNELD_NORMAL')
wait_for(lambda: len(gl1.list_peer_channels().channels) > 0)
wait_for(lambda: gl1.list_peer_channels().channels[0].state == 2) # CHANNELD_NORMAL
wait_for(lambda: len(l1.rpc.listchannels()['channels']) == 2)

inv = gl1.invoice(
Expand Down Expand Up @@ -163,7 +164,10 @@ 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)
wait_for(lambda: gl1.list_peers().peers[0].channels[0].state == 2) # CHANNELD_NORMAL

# the channels array is optional
wait_for(lambda: len(gl1.list_peer_channels().channels) > 0)
wait_for(lambda: gl1.list_peer_channels().channels[0].state == 2) # CHANNELD_NORMAL

# Generate an invoice without amount:
inv = l1.rpc.call('invoice', payload={
Expand Down Expand Up @@ -201,7 +205,10 @@ 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)
wait_for(lambda: gl1.list_peers().peers[0].channels[0].state == 2) # CHANNELD_NORMAL

# the channels array is optional
wait_for(lambda: len(gl1.list_peer_channels().channels) > 0)
wait_for(lambda: gl1.list_peer_channels().channels[0].state == 2) # CHANNELD_NORMAL

preimage = "00"*32

Expand Down

0 comments on commit 6af1e57

Please sign in to comment.