(node_factory, bitcoind)
| 2458 | |
| 2459 | |
| 2460 | def test_setchannel_restart(node_factory, bitcoind): |
| 2461 | # TEST SETUP |
| 2462 | # |
| 2463 | # [l1] <--default_fees--> [l2] <--specific_fees--> [l3] |
| 2464 | # |
| 2465 | # - l2 sets fees to custom values and restarts |
| 2466 | # - l1 routing can be made with the custom fees |
| 2467 | # - l2 sets fees to UIN32_MAX (db update default) and restarts |
| 2468 | # - l1 routing can be made to l3 and global (1 10) fees are applied |
| 2469 | DEF_BASE = 1 |
| 2470 | DEF_PPM = 10 |
| 2471 | MIN_HTLC = Millisatoshi(0) |
| 2472 | MAX_HTLC = Millisatoshi(int(FUNDAMOUNT * 1000 * 0.99)) |
| 2473 | OPTS = {'may_reconnect': True, 'fee-base': DEF_BASE, 'fee-per-satoshi': DEF_PPM} |
| 2474 | |
| 2475 | l1, l2, l3 = node_factory.line_graph(3, announce_channels=True, wait_for_announce=True, opts=OPTS) |
| 2476 | |
| 2477 | # get short channel idS |
| 2478 | scid12 = l1.get_channel_scid(l2) |
| 2479 | scid23 = l2.get_channel_scid(l3) |
| 2480 | |
| 2481 | # l2 set custom fees |
| 2482 | l2.rpc.setchannel(scid23, 1337, 137, 17, 500001) |
| 2483 | |
| 2484 | # restart l2 and reconnect |
| 2485 | l2.restart() |
| 2486 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 2487 | l2.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 2488 | |
| 2489 | # Make sure l1's gossipd registered channeld activating channel. |
| 2490 | wait_for(lambda: [c['active'] for c in l1.rpc.listchannels(scid12)['channels']] == [True, True]) |
| 2491 | |
| 2492 | # l1 wait for channel update from l2 |
| 2493 | wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['htlc_minimum_msat'], c['htlc_maximum_msat'], c['active']) for c in l1.rpc.listchannels(scid23)['channels']] == [(1337, 137, 17, 500001, True), (DEF_BASE, DEF_PPM, MIN_HTLC, MAX_HTLC, True)]) |
| 2494 | |
| 2495 | # In case l3 includes a routehint, we need to make sure they also know |
| 2496 | # about the new fees, otherwise we may end up with the old feerate |
| 2497 | wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['htlc_minimum_msat'], c['htlc_maximum_msat'], c['active']) for c in l3.rpc.listchannels(scid23)['channels']] == [(1337, 137, 17, 500001, True), (DEF_BASE, DEF_PPM, MIN_HTLC, MAX_HTLC, True)]) |
| 2498 | |
| 2499 | # l1 can make payment to l3 with custom fees being applied |
| 2500 | # Note: BOLT #7 math works out to 1405 msat fees |
| 2501 | inv = l3.rpc.invoice(499999, 'test_setchannel_1', 'desc')['bolt11'] |
| 2502 | result = l1.dev_pay(inv, dev_use_shadow=False) |
| 2503 | assert result['status'] == 'complete' |
| 2504 | assert result['amount_sent_msat'] == 501404 |
| 2505 | |
| 2506 | |
| 2507 | def test_setchannel_all(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected