add proper validation for the unit field when creating an invoice (#2647)

This commit is contained in:
Gonçalo Valério 2024-08-30 12:17:52 +01:00 committed by GitHub
parent 405a2f0776
commit 4732c4b296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 1 deletions

View file

@ -150,6 +150,21 @@ async def test_create_invoice_fiat_amount(client, inkey_headers_to):
assert extra["fiat_rate"]
@pytest.mark.asyncio
@pytest.mark.parametrize("currency", ("msat", "RRR"))
async def test_create_invoice_validates_used_currency(
currency, client, inkey_headers_to
):
data = await get_random_invoice_data()
data["unit"] = currency
response = await client.post(
"/api/v1/payments", json=data, headers=inkey_headers_to
)
assert response.status_code == 400
res_data = response.json()
assert "The provided unit is not supported" in res_data["detail"]
# check POST /api/v1/payments: invoice creation for internal payments only
@pytest.mark.asyncio
async def test_create_internal_invoice(client, inkey_headers_to):