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

Function test_bookkeeping_missed_chans_pushed

tests/test_bookkeeper.py:404–464  ·  view source on GitHub ↗

Test for a push_msat value in a missed channel open.

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

402@unittest.skipIf(TEST_NETWORK != 'regtest', "network fees hardcoded")
403@pytest.mark.openchannel('v1', 'Uses push-msat')
404def test_bookkeeping_missed_chans_pushed(node_factory, bitcoind):
405 """
406 Test for a push_msat value in a missed channel open.
407 """
408 coin_mvt_plugin = Path(__file__).parent / "plugins" / "coin_movements.py"
409 l1, l2 = node_factory.get_nodes(2, opts={'disable-plugin': 'bookkeeper',
410 'plugin': str(coin_mvt_plugin)})
411
412 # Double check there's no bookkeeper plugin on
413 assert l1.daemon.opts['disable-plugin'] == 'bookkeeper'
414 assert l2.daemon.opts['disable-plugin'] == 'bookkeeper'
415
416 open_amt = 10**7
417 push_amt = 10**6 * 1000
418 invoice_msat = 11000000
419
420 l1.fundwallet(200000000)
421 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
422 txid = l1.rpc.fundchannel(l2.info['id'], open_amt, push_msat=push_amt)['txid']
423 bitcoind.generate_block(1, wait_for_mempool=[txid])
424 wait_for(lambda: l1.channel_state(l2) == 'CHANNELD_NORMAL')
425 scid = l1.get_channel_scid(l2)
426 l1.wait_channel_active(scid)
427 channel_id = first_channel_id(l1, l2)
428
429 # Send l2 funds via the channel
430 l1.pay(l2, invoice_msat)
431 l1.daemon.wait_for_log(r'coin movement:.*\'invoice\'')
432
433 # Now turn the bookkeeper on and restart
434 l1.stop()
435 l2.stop()
436 del l1.daemon.opts['disable-plugin']
437 del l2.daemon.opts['disable-plugin']
438 l1.start()
439 l2.start()
440
441 # Wait for the balance snapshot to fire/finish
442 l1.daemon.wait_for_log('Snapshot balances updated')
443 l2.daemon.wait_for_log('Snapshot balances updated')
444
445 def _check_events(node, channel_id, exp_events):
446 chan_events = [ev for ev in node.rpc.bkpr_listaccountevents()['events'] if ev['account'] == channel_id]
447 assert len(chan_events) == len(exp_events)
448 for ev, exp in zip(chan_events, exp_events):
449 assert ev['tag'] == exp[0]
450 assert ev['credit_msat'] == Millisatoshi(exp[1])
451 assert ev['debit_msat'] == Millisatoshi(exp[2])
452
453 # l1 events
454 exp_events = [('channel_open', open_amt * 1000, 0),
455 ('onchain_fee', 5257000, 0),
456 ('pushed', 0, push_amt),
457 ('journal_entry', 0, invoice_msat)]
458 _check_events(l1, channel_id, exp_events)
459
460 # l2 events
461 exp_events = [('channel_open', 0, 0),

Callers

nothing calls this directly

Calls 15

wait_forFunction · 0.90
first_channel_idFunction · 0.90
_check_eventsFunction · 0.85
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
channel_stateMethod · 0.80
get_channel_scidMethod · 0.80
wait_channel_activeMethod · 0.80
wait_for_logMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected