(node_factory)
| 1404 | |
| 1405 | |
| 1406 | def test_sendamount(node_factory): |
| 1407 | l1, l2, l3, l4 = node_factory.get_nodes(4) |
| 1408 | node_factory.join_nodes([l1, l2, l3, l4], wait_for_announce=True) |
| 1409 | |
| 1410 | # pay bolt11 |
| 1411 | b11 = l4.rpc.invoice("any", "test_sendamount_bolt11", "test_sendamount bolt11")[ |
| 1412 | "bolt11" |
| 1413 | ] |
| 1414 | ret = l1.rpc.sendamount(b11, "100sat") |
| 1415 | assert ret["successful_parts"] == 1 |
| 1416 | assert ret["amount_sent_msat"] == 100000 |
| 1417 | |
| 1418 | # pay bolt12 |
| 1419 | b12 = l4.rpc.offer("any")["bolt12"] |
| 1420 | ret = l1.rpc.sendamount(b12, "100sat") |
| 1421 | assert ret["successful_parts"] == 1 |
| 1422 | assert ret["amount_sent_msat"] == 100000 |
| 1423 | |
| 1424 | # pay to self bolt11 |
| 1425 | b11 = l4.rpc.invoice( |
| 1426 | "any", "test_sendamount_bolt11_self", "test_sendamount_bolt11_self" |
| 1427 | )["bolt11"] |
| 1428 | ret = l4.rpc.sendamount(b11, "100sat") |
| 1429 | assert ret["successful_parts"] == 1 |
| 1430 | assert ret["amount_sent_msat"] == 100000 |
| 1431 | |
| 1432 | # pay to self bolt12 |
| 1433 | b12 = l4.rpc.offer("any")["bolt12"] |
| 1434 | ret = l4.rpc.sendamount(b12, "100sat") |
| 1435 | assert ret["successful_parts"] == 1 |
| 1436 | assert ret["amount_sent_msat"] == 100000 |
| 1437 | |
| 1438 | # pay bolt11 direct peer |
| 1439 | b11 = l4.rpc.invoice( |
| 1440 | "any", "test_sendamount_bolt11_direct", "test_sendamount bolt11_direct" |
| 1441 | )["bolt11"] |
| 1442 | ret = l3.rpc.sendamount(b11, "100sat") |
| 1443 | assert ret["successful_parts"] == 1 |
| 1444 | assert ret["amount_sent_msat"] == 100000 |
| 1445 | |
| 1446 | # pay bolt12 direct peer |
| 1447 | b12 = l4.rpc.offer("any")["bolt12"] |
| 1448 | ret = l3.rpc.sendamount(b12, "100sat") |
| 1449 | assert ret["successful_parts"] == 1 |
| 1450 | assert ret["amount_sent_msat"] == 100000 |
| 1451 | |
| 1452 | # cannot sendamount to bolt11 with fixed amount |
| 1453 | b11 = l4.rpc.invoice( |
| 1454 | "100sat", "test_sendamount_bolt11_fail", "test_sendamount bolt11_fail" |
| 1455 | )["bolt11"] |
| 1456 | with pytest.raises(RpcError, match=r"Expecting a Bolt11 invoice with no amount."): |
| 1457 | ret = l1.rpc.sendamount(b11, "100sat") |
| 1458 | |
| 1459 | # cannot sendamount to bolt12 offer with fixed amount |
| 1460 | b12 = l4.rpc.offer("100sat", "test sendamount bolt12 offer fail")["bolt12"] |
| 1461 | with pytest.raises(RpcError, match=r"Expecting an offer with no amount"): |
| 1462 | ret = l1.rpc.sendamount(b12, "100sat") |
| 1463 |
nothing calls this directly
no test coverage detected