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

Function test_v2_open_sigs_restart_while_dead

tests/test_opening.py:192–242  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

190@pytest.mark.developer("uses dev-disconnect")
191@pytest.mark.openchannel('v2')
192def test_v2_open_sigs_restart_while_dead(node_factory, bitcoind):
193 # Same thing as above, except the transaction mines
194 # while we're asleep
195 disconnects_1 = ['-WIRE_TX_SIGNATURES']
196 disconnects_2 = ['+WIRE_TX_SIGNATURES']
197
198 l1, l2 = node_factory.get_nodes(2,
199 opts=[{'disconnect': disconnects_1,
200 'may_reconnect': True,
201 'may_fail': True},
202 {'disconnect': disconnects_2,
203 'may_reconnect': True,
204 'may_fail': True}])
205
206 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
207 amount = 2**24
208 chan_amount = 100000
209 bitcoind.rpc.sendtoaddress(l1.rpc.newaddr()['bech32'], amount / 10**8 + 0.01)
210 bitcoind.generate_block(1)
211 # Wait for it to arrive.
212 wait_for(lambda: len(l1.rpc.listfunds()['outputs']) > 0)
213
214 # Fund the channel, should appear to finish ok even though the
215 # peer fails
216 with pytest.raises(RpcError):
217 l1.rpc.fundchannel(l2.info['id'], chan_amount)
218
219 chan_id = first_channel_id(l1, l2)
220 log = l1.daemon.is_in_log('{} psbt'.format(chan_id))
221 assert log
222 psbt = re.search("psbt (.*)", log).group(1)
223
224 l1.daemon.wait_for_log('Peer has reconnected, state DUALOPEND_OPEN_INIT')
225 try:
226 # FIXME: why do we need to retry signed?
227 l1.rpc.openchannel_signed(chan_id, psbt)
228 except RpcError:
229 pass
230
231 l2.daemon.wait_for_log('Broadcasting funding tx')
232 l2.daemon.wait_for_log('sendrawtx exit 0')
233
234 l1.stop()
235 l2.stop()
236 bitcoind.generate_block(6)
237 l1.restart()
238 l2.restart()
239
240 # Make sure we're ok.
241 l2.daemon.wait_for_log(r'to CHANNELD_NORMAL')
242 l1.daemon.wait_for_log(r'to CHANNELD_NORMAL')
243
244
245@unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need')

Callers

nothing calls this directly

Calls 13

wait_forFunction · 0.90
first_channel_idFunction · 0.90
get_nodesMethod · 0.80
generate_blockMethod · 0.80
is_in_logMethod · 0.80
wait_for_logMethod · 0.80
openchannel_signedMethod · 0.80
restartMethod · 0.80
connectMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected