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

Function test_htlc_accepted_hook_direct_restart

tests/test_plugin.py:1270–1298  ·  view source on GitHub ↗

l2 restarts while it is pondering what to do with an HTLC.

(node_factory, executor)

Source from the content-addressed store, hash-verified

1268
1269
1270def test_htlc_accepted_hook_direct_restart(node_factory, executor):
1271 """l2 restarts while it is pondering what to do with an HTLC.
1272 """
1273 l1, l2 = node_factory.line_graph(2, opts=[
1274 {'may_reconnect': True},
1275 {'may_reconnect': True,
1276 'plugin': os.path.join(os.getcwd(), 'tests/plugins/hold_htlcs.py')}
1277 ])
1278
1279 i1 = l2.rpc.invoice(amount_msat=1000, label="direct", description="desc")['bolt11']
1280 f1 = executor.submit(l1.rpc.xpay, i1)
1281
1282 l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds')
1283
1284 # Check that the status mentions the HTLC being held
1285 l2.rpc.listpeers()
1286 channel = only_one(l2.rpc.listpeerchannels()['channels'])
1287 htlc_status = channel['htlcs'][0].get('status', None)
1288 assert htlc_status == "Waiting for the htlc_accepted hook of plugin hold_htlcs.py"
1289
1290 needle = l2.daemon.logsearch_start
1291 l2.restart()
1292
1293 # Now it should try again, *after* initializing.
1294 # This may be before "Server started with public key" swallowed by restart()
1295 l2.daemon.logsearch_start = needle + 1
1296 l2.daemon.wait_for_log(r'hold_htlcs.py initializing')
1297 l2.daemon.wait_for_log(r'Holding onto an incoming htlc for 10 seconds')
1298 f1.result()
1299
1300
1301def test_htlc_accepted_hook_restart_during_shutdown(node_factory, executor):

Callers

nothing calls this directly

Calls 9

only_oneFunction · 0.90
line_graphMethod · 0.80
joinMethod · 0.80
wait_for_logMethod · 0.80
listpeerchannelsMethod · 0.80
restartMethod · 0.80
invoiceMethod · 0.45
listpeersMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected