Open a channel succeeds; opening a second channel failure should not drop the connection
(node_factory, bitcoind)
| 404 | |
| 405 | @pytest.mark.openchannel('v2') |
| 406 | def test_v2_fail_second(node_factory, bitcoind): |
| 407 | """ Open a channel succeeds; opening a second channel |
| 408 | failure should not drop the connection """ |
| 409 | l1, l2 = node_factory.line_graph(2, wait_for_announce=True) |
| 410 | |
| 411 | # Should have one channel between them. |
| 412 | only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels']) |
| 413 | |
| 414 | amount = 2**24 - 1 |
| 415 | l1.fundwallet(amount + 10000000) |
| 416 | |
| 417 | # make sure we can generate PSBTs. |
| 418 | addr = l1.rpc.newaddr('bech32')['bech32'] |
| 419 | bitcoind.rpc.sendtoaddress(addr, (amount + 1000000) / 10**8) |
| 420 | bitcoind.generate_block(1) |
| 421 | wait_for(lambda: len(l1.rpc.listfunds()["outputs"]) != 0) |
| 422 | |
| 423 | # Some random (valid) psbt |
| 424 | psbt = l1.rpc.fundpsbt(amount, '253perkw', 250, reserve=0)['psbt'] |
| 425 | start = l1.rpc.openchannel_init(l2.info['id'], amount, psbt) |
| 426 | |
| 427 | # They will both see a pair of channels |
| 428 | assert len(l1.rpc.listpeerchannels(l2.info['id'])['channels']) == 2 |
| 429 | assert len(l2.rpc.listpeerchannels(l1.info['id'])['channels']) == 2 |
| 430 | |
| 431 | # We can abort a channel |
| 432 | l1.rpc.openchannel_abort(start['channel_id']) |
| 433 | |
| 434 | # We should have deleted the 'in-progress' channel info |
| 435 | only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels']) |
| 436 | only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels']) |
| 437 | |
| 438 | # check that tx-abort was sent |
| 439 | l1.daemon.wait_for_log(r'peer_out WIRE_TX_ABORT') |
| 440 | l2.daemon.wait_for_log(r'peer_out WIRE_TX_ABORT') |
| 441 | |
| 442 | # Should be able to reattempt without reconnecting |
| 443 | assert l1.rpc.getpeer(l2.info['id'])['connected'] |
| 444 | start = l1.rpc.openchannel_init(l2.info['id'], amount, psbt) |
| 445 | assert len(l1.rpc.listpeerchannels(l2.info['id'])['channels']) == 2 |
| 446 | |
| 447 | |
| 448 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
nothing calls this directly
no test coverage detected