(node_factory, executor)
| 400 | |
| 401 | |
| 402 | def test_xpay_takeover(node_factory, executor): |
| 403 | l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True, |
| 404 | opts={'xpay-handle-pay': True, |
| 405 | 'allow-deprecated-apis': True}) |
| 406 | |
| 407 | # Simple bolt11/bolt12 payment. |
| 408 | inv = l3.rpc.invoice(100000, "test_xpay_takeover1", "test_xpay_takeover1")['bolt11'] |
| 409 | l1.rpc.pay(inv) |
| 410 | l1.daemon.wait_for_log('Calling rpc_command hook of plugin cln-xpay') |
| 411 | l1.daemon.wait_for_log('Redirecting pay->xpay') |
| 412 | |
| 413 | # Quickly test that xpay does NOT receive other commands now. |
| 414 | l1.rpc.help() |
| 415 | assert not l1.daemon.is_in_log('Calling rpc_command hook of plugin cln-xpay', |
| 416 | start=l1.daemon.logsearch_start) |
| 417 | |
| 418 | # Array version |
| 419 | inv = l3.rpc.invoice(100000, "test_xpay_takeover2", "test_xpay_takeover2")['bolt11'] |
| 420 | subprocess.check_output(['cli/lightning-cli', |
| 421 | '--network={}'.format(TEST_NETWORK), |
| 422 | '--lightning-dir={}' |
| 423 | .format(l1.daemon.lightning_dir), |
| 424 | 'pay', |
| 425 | inv]) |
| 426 | l1.daemon.wait_for_log('Redirecting pay->xpay') |
| 427 | |
| 428 | offer = l3.rpc.offer(100000, "test_xpay_takeover2")['bolt12'] |
| 429 | b12 = l1.rpc.fetchinvoice(offer)['invoice'] |
| 430 | l1.rpc.pay(b12) |
| 431 | l1.daemon.wait_for_log('Redirecting pay->xpay') |
| 432 | |
| 433 | # BOLT-11 with amount. |
| 434 | inv = l3.rpc.invoice('any', "test_xpay_takeover3", "test_xpay_takeover3")['bolt11'] |
| 435 | l1.rpc.pay(inv, amount_msat=10000) |
| 436 | l1.daemon.wait_for_log('Redirecting pay->xpay') |
| 437 | |
| 438 | # Array version |
| 439 | inv = l3.rpc.invoice('any', "test_xpay_takeover4", "test_xpay_takeover4")['bolt11'] |
| 440 | subprocess.check_output(['cli/lightning-cli', |
| 441 | '--network={}'.format(TEST_NETWORK), |
| 442 | '--lightning-dir={}' |
| 443 | .format(l1.daemon.lightning_dir), |
| 444 | 'pay', |
| 445 | inv, "10000"]) |
| 446 | l1.daemon.wait_for_log('Redirecting pay->xpay') |
| 447 | |
| 448 | # retry_for, maxfee and partial_msat all work |
| 449 | inv = l3.rpc.invoice('any', "test_xpay_takeover5", "test_xpay_takeover5")['bolt11'] |
| 450 | |
| 451 | fut1 = executor.submit(l1.rpc.pay, bolt11=inv, amount_msat=2000, retry_for=0, maxfee=100, partial_msat=1000) |
| 452 | l1.daemon.wait_for_log('Redirecting pay->xpay') |
| 453 | fut2 = executor.submit(l2.rpc.pay, bolt11=inv, amount_msat=2000, retry_for=0, maxfee=0, partial_msat=1000) |
| 454 | l2.daemon.wait_for_log('Redirecting pay->xpay') |
| 455 | fut1.result(TIMEOUT) |
| 456 | fut2.result(TIMEOUT) |
| 457 | |
| 458 | # Three-array-arg replacements don't work. |
| 459 | inv = l3.rpc.invoice('any', "test_xpay_takeover6", "test_xpay_takeover6")['bolt11'] |
nothing calls this directly
no test coverage detected