(node_factory, bitcoind)
| 2382 | |
| 2383 | |
| 2384 | def test_setchannel_zero(node_factory, bitcoind): |
| 2385 | # TEST SETUP |
| 2386 | # |
| 2387 | # [l1] <--default_fees--> [l2] <--specific_fees--> [l3] |
| 2388 | # |
| 2389 | # - json listchannels is able to see the new values in foreign node |
| 2390 | # - routing calculates fees correctly |
| 2391 | # - payment can be done using zero fees |
| 2392 | DEF_BASE = 1 |
| 2393 | DEF_PPM = 10 |
| 2394 | MAX_HTLC = Millisatoshi(int(FUNDAMOUNT * 1000 * 0.99)) |
| 2395 | |
| 2396 | l1, l2, l3 = node_factory.line_graph( |
| 2397 | 3, announce_channels=True, wait_for_announce=True, |
| 2398 | opts={'fee-base': DEF_BASE, 'fee-per-satoshi': DEF_PPM}) |
| 2399 | |
| 2400 | # get short channel id for 2->3 |
| 2401 | scid = l2.get_channel_scid(l3) |
| 2402 | |
| 2403 | # TEST ZERO fees possible |
| 2404 | l2.rpc.setchannel(scid, 0, 0) |
| 2405 | wait_for(lambda: [c['base_fee_millisatoshi'] for c in l1.rpc.listchannels(scid)['channels']] == [0, DEF_BASE]) |
| 2406 | wait_for(lambda: [c['fee_per_millionth'] for c in l1.rpc.listchannels(scid)['channels']] == [0, DEF_PPM]) |
| 2407 | |
| 2408 | # test if zero fees are applied |
| 2409 | route = l1.single_route(l3.info['id'], 4999999) |
| 2410 | assert len(route) == 2 |
| 2411 | assert route[0]['amount_out_msat'] == 4999999 |
| 2412 | assert route[1]['amount_out_msat'] == 4999999 |
| 2413 | |
| 2414 | # Wait for l3 to know about our low-balling, otherwise they'll add a wrong |
| 2415 | # routehint to the invoice. |
| 2416 | 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)]) |
| 2417 | |
| 2418 | # do and check actual payment |
| 2419 | inv = l3.rpc.invoice(4999999, 'test_setchannel_3', 'desc')['bolt11'] |
| 2420 | result = l1.dev_pay(inv, dev_use_shadow=False) |
| 2421 | assert result['status'] == 'complete' |
| 2422 | assert result['amount_sent_msat'] == 4999999 |
| 2423 | |
| 2424 | # FIXME: hack something up to advertize min_htlc > 0, then test mintoolow. |
| 2425 | with pytest.raises(RpcError, match="htlcmax cannot be less than htlcmin"): |
| 2426 | l2.rpc.setchannel(scid, htlcmin=100000, htlcmax=99999) |
| 2427 | |
| 2428 | ret = l2.rpc.setchannel(scid, htlcmax=FUNDAMOUNT * 1000) |
| 2429 | assert 'warning_htlcmax_too_high' in only_one(ret['channels']) |
| 2430 | assert only_one(ret['channels'])['maximum_htlc_out_msat'] == MAX_HTLC |
| 2431 | |
| 2432 | |
| 2433 | def test_setchannel_restart(node_factory, bitcoind): |
nothing calls this directly
no test coverage detected