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

Function test_v2_open_sigs_restart

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

Source from the content-addressed store, hash-verified

143@pytest.mark.developer("uses dev-disconnect")
144@pytest.mark.openchannel('v2')
145def 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')

Callers

nothing calls this directly

Calls 12

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
connectMethod · 0.45
newaddrMethod · 0.45
listfundsMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected