(node_factory, bitcoind)
| 2409 | |
| 2410 | |
| 2411 | def test_setchannel_zero(node_factory, bitcoind): |
| 2412 | # TEST SETUP |
| 2413 | # |
| 2414 | # [l1] <--default_fees--> [l2] <--specific_fees--> [l3] |
| 2415 | # |
| 2416 | # - json listchannels is able to see the new values in foreign node |
| 2417 | # - routing calculates fees correctly |
| 2418 | # - payment can be done using zero fees |
| 2419 | DEF_BASE = 1 |
| 2420 | DEF_PPM = 10 |
| 2421 | MAX_HTLC = Millisatoshi(int(FUNDAMOUNT * 1000 * 0.99)) |
| 2422 | |
| 2423 | l1, l2, l3 = node_factory.line_graph( |
| 2424 | 3, announce_channels=True, wait_for_announce=True, |
| 2425 | opts={'fee-base': DEF_BASE, 'fee-per-satoshi': DEF_PPM}) |
| 2426 | |
| 2427 | # get short channel id for 2->3 |
| 2428 | scid = l2.get_channel_scid(l3) |
| 2429 | |
| 2430 | # TEST ZERO fees possible |
| 2431 | l2.rpc.setchannel(scid, 0, 0) |
| 2432 | wait_for(lambda: [c['base_fee_millisatoshi'] for c in l1.rpc.listchannels(scid)['channels']] == [0, DEF_BASE]) |
| 2433 | wait_for(lambda: [c['fee_per_millionth'] for c in l1.rpc.listchannels(scid)['channels']] == [0, DEF_PPM]) |
| 2434 | |
| 2435 | # test if zero fees are applied |
| 2436 | route = l1.single_route(l3.info['id'], 4999999) |
| 2437 | assert len(route) == 2 |
| 2438 | assert route[0]['amount_out_msat'] == 4999999 |
| 2439 | assert route[1]['amount_out_msat'] == 4999999 |
| 2440 | |
| 2441 | # Wait for l3 to know about our low-balling, otherwise they'll add a wrong |
| 2442 | # routehint to the invoice. |
| 2443 | wait_for(lambda: [(c['base_fee_millisatoshi'], c['fee_per_millionth'], c['active']) for c in l3.rpc.listchannels(scid)['channels']] == [(0, 0, True), (DEF_BASE, DEF_PPM, True)]) |
| 2444 | |
| 2445 | # do and check actual payment |
| 2446 | inv = l3.rpc.invoice(4999999, 'test_setchannel_3', 'desc')['bolt11'] |
| 2447 | result = l1.dev_pay(inv, dev_use_shadow=False) |
| 2448 | assert result['status'] == 'complete' |
| 2449 | assert result['amount_sent_msat'] == 4999999 |
| 2450 | |
| 2451 | # FIXME: hack something up to advertize min_htlc > 0, then test mintoolow. |
| 2452 | with pytest.raises(RpcError, match="htlcmax cannot be less than htlcmin"): |
| 2453 | l2.rpc.setchannel(scid, htlcmin=100000, htlcmax=99999) |
| 2454 | |
| 2455 | ret = l2.rpc.setchannel(scid, htlcmax=FUNDAMOUNT * 1000) |
| 2456 | assert 'warning_htlcmax_too_high' in only_one(ret['channels']) |
| 2457 | assert only_one(ret['channels'])['maximum_htlc_out_msat'] == MAX_HTLC |
| 2458 | |
| 2459 | |
| 2460 | def test_setchannel_restart(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected