(connections)
| 307 | |
| 308 | |
| 309 | def start_channels(connections): |
| 310 | nodes = list() |
| 311 | for src, dst, fundamount in connections: |
| 312 | nodes.append(src) |
| 313 | nodes.append(dst) |
| 314 | src.rpc.connect(dst.info["id"], "localhost", dst.port) |
| 315 | |
| 316 | bitcoind = nodes[0].bitcoin |
| 317 | # If we got here, we want to fund channels |
| 318 | for src, dst, fundamount in connections: |
| 319 | addr = src.rpc.newaddr('bech32')["bech32"] |
| 320 | bitcoind.rpc.sendtoaddress(addr, (fundamount + 1000000) / 10**8) |
| 321 | |
| 322 | bitcoind.generate_block(1) |
| 323 | sync_blockheight(bitcoind, nodes) |
| 324 | txids = [] |
| 325 | channel_ids = [] |
| 326 | for src, dst, fundamount in connections: |
| 327 | fc = src.rpc.fundchannel(dst.info["id"], fundamount, announce=True) |
| 328 | txids.append(fc["txid"]) |
| 329 | channel_ids.append(fc['channel_id']) |
| 330 | |
| 331 | # Confirm all channels |
| 332 | bitcoind.generate_block(1, wait_for_mempool=txids) |
| 333 | scids = [] |
| 334 | for conn, channel_id in zip(connections, channel_ids): |
| 335 | src = conn[0] |
| 336 | wait_for(lambda: ['short_channel_id' in c for c in src.rpc.listpeerchannels()['channels'] if c['channel_id'] == channel_id] == [True]) |
| 337 | scid = only_one([c['short_channel_id'] for c in src.rpc.listpeerchannels()['channels'] if c['channel_id'] == channel_id]) |
| 338 | scids.append(scid) |
| 339 | |
| 340 | # Make sure they have all seen block so they don't complain about |
| 341 | # the coming gossip messages |
| 342 | sync_blockheight(bitcoind, nodes) |
| 343 | |
| 344 | bitcoind.generate_block(5) |
| 345 | |
| 346 | # Make sure everyone sees all channels, all other nodes |
| 347 | for n in nodes: |
| 348 | for scid in scids: |
| 349 | n.wait_channel_active(scid) |
| 350 | |
| 351 | # Make sure we have all node announcements, too |
| 352 | for n in nodes: |
| 353 | for n2 in nodes: |
| 354 | wait_for( |
| 355 | lambda: "alias" in only_one(n.rpc.listnodes(n2.info["id"])["nodes"]) |
| 356 | ) |
| 357 | |
| 358 | |
| 359 | def test_hardmpp(node_factory): |
no test coverage detected