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

Function test_v2_replay_bookkeeping

tests/test_opening.py:2502–2561  ·  view source on GitHub ↗

Test that your bookkeeping for a liquidity ad is good even if we replay the opening and locking tx!

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

2500
2501@pytest.mark.openchannel('v2')
2502def test_v2_replay_bookkeeping(node_factory, bitcoind):
2503 """ Test that your bookkeeping for a liquidity ad is good
2504 even if we replay the opening and locking tx!
2505 """
2506
2507 opts = [{'funder-policy': 'match', 'funder-policy-mod': 100,
2508 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
2509 'rescan': 10, 'funding-confirms': 6, 'may_reconnect': True,
2510 'broken_log': 'channeld.*current blockheight [0-9]* less than last'},
2511 {'funder-policy': 'match', 'funder-policy-mod': 100,
2512 'lease-fee-base-sat': '100sat', 'lease-fee-basis': 100,
2513 'may_reconnect': True}]
2514
2515 l1, l2, = node_factory.get_nodes(2, opts=opts)
2516 amount = 500000
2517 feerate = 2000
2518
2519 l1.fundwallet(amount * 100)
2520 l2.fundwallet(amount * 100)
2521
2522 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
2523 rates = l1.rpc.dev_queryrates(l2.info['id'], amount, amount)
2524
2525 # l1 leases a channel from l2
2526 l1.rpc.fundchannel(l2.info['id'], amount, request_amt=amount,
2527 feerate='{}perkw'.format(feerate),
2528 compact_lease=rates['compact_lease'])
2529
2530 # add the funding transaction
2531 bitcoind.generate_block(4, wait_for_mempool=1)
2532
2533 l1.restart()
2534
2535 bitcoind.generate_block(2)
2536 l1.daemon.wait_for_log('to CHANNELD_NORMAL')
2537
2538 chan_id = first_channel_id(l1, l2)
2539 ev_tags = [e['tag'] for e in l1.rpc.bkpr_listaccountevents(chan_id)['events']]
2540 assert 'lease_fee' in ev_tags
2541
2542 # This should work ok
2543 l1.rpc.bkpr_listbalances()
2544
2545 bitcoind.generate_block(2)
2546 sync_blockheight(bitcoind, [l1])
2547
2548 l1.restart()
2549
2550 chan_id = first_channel_id(l1, l2)
2551 ev_tags = [e['tag'] for e in l1.rpc.bkpr_listaccountevents(chan_id)['events']]
2552 assert 'lease_fee' in ev_tags
2553
2554 l1.rpc.close(l2.info['id'], 1)
2555 bitcoind.generate_block(6, wait_for_mempool=1)
2556
2557 l1.daemon.wait_for_log(' to ONCHAIN')
2558 l2.daemon.wait_for_log(' to ONCHAIN')
2559

Callers

nothing calls this directly

Calls 10

first_channel_idFunction · 0.90
sync_blockheightFunction · 0.90
get_nodesMethod · 0.80
fundwalletMethod · 0.80
generate_blockMethod · 0.80
restartMethod · 0.80
wait_for_logMethod · 0.80
connectMethod · 0.45
fundchannelMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected