Check that best_effort flag works.
(node_factory, bitcoind)
| 2199 | |
| 2200 | @pytest.mark.openchannel('v1') |
| 2201 | def test_multifunding_best_effort(node_factory, bitcoind): |
| 2202 | ''' |
| 2203 | Check that best_effort flag works. |
| 2204 | ''' |
| 2205 | disconnects = ["-WIRE_INIT", |
| 2206 | "-WIRE_ACCEPT_CHANNEL", |
| 2207 | "-WIRE_FUNDING_SIGNED"] |
| 2208 | l1 = node_factory.get_node() |
| 2209 | l2 = node_factory.get_node() |
| 2210 | l3 = node_factory.get_node(disconnect=disconnects) |
| 2211 | l4 = node_factory.get_node() |
| 2212 | |
| 2213 | l1.fundwallet(2000000) |
| 2214 | |
| 2215 | destinations = [{"id": '{}@localhost:{}'.format(l2.info['id'], l2.port), |
| 2216 | "amount": 50000}, |
| 2217 | {"id": '{}@localhost:{}'.format(l3.info['id'], l3.port), |
| 2218 | "amount": 50000}, |
| 2219 | {"id": '{}@localhost:{}'.format(l4.info['id'], l4.port), |
| 2220 | "amount": 50000}] |
| 2221 | |
| 2222 | for i, d in enumerate(disconnects): |
| 2223 | # Should succeed due to best-effort flag. |
| 2224 | l1.rpc.multifundchannel(destinations, minchannels=2) |
| 2225 | bitcoind.generate_block(6, wait_for_mempool=1) |
| 2226 | |
| 2227 | # Only l3 should fail to have channels. |
| 2228 | for node in [l1, l2, l4]: |
| 2229 | node.daemon.wait_for_log(r'to CHANNELD_NORMAL') |
| 2230 | |
| 2231 | # There should be working channels to l2 and l4. |
| 2232 | for ldest in [l2, l4]: |
| 2233 | inv = ldest.rpc.invoice(5000, 'i{}'.format(i), 'i{}'.format(i))['bolt11'] |
| 2234 | l1.rpc.xpay(inv) |
| 2235 | |
| 2236 | # Function to find the SCID of the channel that is |
| 2237 | # currently open. |
| 2238 | # Cannot use LightningNode.get_channel_scid since |
| 2239 | # it assumes the *first* channel found is the one |
| 2240 | # wanted, but in our case we close channels and |
| 2241 | # open again, so multiple channels may remain |
| 2242 | # listed. |
| 2243 | def get_funded_channel_scid(n1, n2): |
| 2244 | channels = n1.rpc.listpeerchannels(n2.info['id'])['channels'] |
| 2245 | assert channels |
| 2246 | for c in channels: |
| 2247 | state = c['state'] |
| 2248 | if state in ('CHANNELD_AWAITING_LOCKIN', 'CHANNELD_NORMAL'): |
| 2249 | return c['short_channel_id'] |
| 2250 | assert False |
| 2251 | |
| 2252 | # Now close channels to l2 and l4, for the next run. |
| 2253 | l1.rpc.close(get_funded_channel_scid(l1, l2)) |
| 2254 | l1.rpc.close(get_funded_channel_scid(l1, l4)) |
| 2255 | |
| 2256 | for node in [l1, l2, l4]: |
| 2257 | node.daemon.wait_for_log(r'to CLOSINGD_COMPLETE') |
| 2258 |
nothing calls this directly
no test coverage detected