(node_factory, bitcoind)
| 143 | @pytest.mark.developer("uses dev-disconnect") |
| 144 | @pytest.mark.openchannel('v2') |
| 145 | def test_v2_open_sigs_restart(node_factory, bitcoind): |
| 146 | disconnects_1 = ['-WIRE_TX_SIGNATURES'] |
| 147 | disconnects_2 = ['+WIRE_TX_SIGNATURES'] |
| 148 | |
| 149 | l1, l2 = node_factory.get_nodes(2, |
| 150 | opts=[{'disconnect': disconnects_1, |
| 151 | 'may_reconnect': True}, |
| 152 | {'disconnect': disconnects_2, |
| 153 | 'may_reconnect': True}]) |
| 154 | |
| 155 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 156 | amount = 2**24 |
| 157 | chan_amount = 100000 |
| 158 | bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01) |
| 159 | bitcoind.generate_block(1) |
| 160 | # Wait for it to arrive. |
| 161 | wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0) |
| 162 | |
| 163 | # Fund the channel, should appear to finish ok even though the |
| 164 | # peer fails |
| 165 | with pytest.raises(RpcError): |
| 166 | l1.rpc.fundchannel(l2.info['id'], chan_amount) |
| 167 | |
| 168 | chan_id = first_channel_id(l1, l2) |
| 169 | log = l1.daemon.is_in_log('{} psbt'.format(chan_id)) |
| 170 | assert log |
| 171 | psbt = re.search("psbt (.*)", log).group(1) |
| 172 | |
| 173 | l1.daemon.wait_for_log('Peer has reconnected, state DUALOPEND_OPEN_INIT') |
| 174 | try: |
| 175 | # FIXME: why do we need to retry signed? |
| 176 | l1.rpc.openchannel_signed(chan_id, psbt) |
| 177 | except RpcError: |
| 178 | pass |
| 179 | |
| 180 | l2.daemon.wait_for_log('Broadcasting funding tx') |
| 181 | txid = l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'][0]['funding_txid'] |
| 182 | bitcoind.generate_block(6, wait_for_mempool=txid) |
| 183 | |
| 184 | # Make sure we're ok. |
| 185 | l1.daemon.wait_for_log(r'to CHANNELD_NORMAL') |
| 186 | l2.daemon.wait_for_log(r'to CHANNELD_NORMAL') |
| 187 | |
| 188 | |
| 189 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
nothing calls this directly
no test coverage detected