MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_multifunding_best_effort

Function test_multifunding_best_effort

tests/test_connection.py:2094–2162  ·  view source on GitHub ↗

Check that best_effort flag works.

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2092@pytest.mark.openchannel('v1')
2093@pytest.mark.developer("disconnect=... needs DEVELOPER=1")
2094def test_multifunding_best_effort(node_factory, bitcoind):
2095 '''
2096 Check that best_effort flag works.
2097 '''
2098 disconnects = ["-WIRE_INIT",
2099 "-WIRE_ACCEPT_CHANNEL",
2100 "-WIRE_FUNDING_SIGNED"]
2101 l1 = node_factory.get_node()
2102 l2 = node_factory.get_node()
2103 l3 = node_factory.get_node(disconnect=disconnects)
2104 l4 = node_factory.get_node()
2105
2106 l1.fundwallet(2000000)
2107
2108 destinations = [{"id": '{}@localhost:{}'.format(l2.info['id'], l2.port),
2109 "amount": 50000},
2110 {"id": '{}@localhost:{}'.format(l3.info['id'], l3.port),
2111 "amount": 50000},
2112 {"id": '{}@localhost:{}'.format(l4.info['id'], l4.port),
2113 "amount": 50000}]
2114
2115 for i, d in enumerate(disconnects):
2116 # Should succeed due to best-effort flag.
2117 l1.rpc.multifundchannel(destinations, minchannels=2)
2118 bitcoind.generate_block(6, wait_for_mempool=1)
2119
2120 # Only l3 should fail to have channels.
2121 for node in [l1, l2, l4]:
2122 node.daemon.wait_for_log(r'to CHANNELD_NORMAL')
2123
2124 # There should be working channels to l2 and l4.
2125 for ldest in [l2, l4]:
2126 inv = ldest.rpc.invoice(5000, 'i{}'.format(i), 'i{}'.format(i))['bolt11']
2127 l1.rpc.pay(inv)
2128
2129 # Function to find the SCID of the channel that is
2130 # currently open.
2131 # Cannot use LightningNode.get_channel_scid since
2132 # it assumes the *first* channel found is the one
2133 # wanted, but in our case we close channels and
2134 # open again, so multiple channels may remain
2135 # listed.
2136 def get_funded_channel_scid(n1, n2):
2137 peers = n1.rpc.listpeers(n2.info['id'])['peers']
2138 assert len(peers) == 1
2139 peer = peers[0]
2140 channels = peer['channels']
2141 assert channels
2142 for c in channels:
2143 state = c['state']
2144 if state in ('CHANNELD_AWAITING_LOCKIN', 'CHANNELD_NORMAL'):
2145 return c['short_channel_id']
2146 assert False
2147
2148 # Now close channels to l2 and l4, for the next run.
2149 l1.rpc.close(get_funded_channel_scid(l1, l2))
2150 l1.rpc.close(get_funded_channel_scid(l1, l4))
2151

Callers

nothing calls this directly

Calls 10

fundwalletMethod · 0.80
multifundchannelMethod · 0.80
generate_blockMethod · 0.80
wait_for_logMethod · 0.80
get_funded_channel_scidFunction · 0.70
get_nodeMethod · 0.45
invoiceMethod · 0.45
payMethod · 0.45
closeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected