Add Lightning amount threshold validation
This commit is contained in:
parent
28e8ba218f
commit
8936d802a6
3 changed files with 87 additions and 0 deletions
|
|
@ -324,6 +324,77 @@ class TestCreateExchange:
|
|||
assert response.status_code == 400
|
||||
assert "Invalid bitcoin_transfer_method" in response.json()["detail"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lightning_above_threshold_rejected(
|
||||
self, client_factory, regular_user, admin_user
|
||||
):
|
||||
"""Lightning payment above threshold is rejected."""
|
||||
target_date = await setup_availability_and_price(client_factory, admin_user)
|
||||
|
||||
with mock_price_fetcher(20000.0):
|
||||
async with client_factory.create(cookies=regular_user["cookies"]) as client:
|
||||
# Try Lightning with amount above threshold (€1000 = 100000 cents)
|
||||
response = await client.post(
|
||||
"/api/exchange",
|
||||
json={
|
||||
"slot_start": f"{target_date}T09:00:00Z",
|
||||
"direction": "buy",
|
||||
"bitcoin_transfer_method": "lightning",
|
||||
"eur_amount": 110000, # €1100, above €1000 threshold
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 400
|
||||
assert "Lightning payments are only allowed" in response.json()["detail"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_lightning_below_threshold_accepted(
|
||||
self, client_factory, regular_user, admin_user
|
||||
):
|
||||
"""Lightning payment below threshold is accepted."""
|
||||
target_date = await setup_availability_and_price(client_factory, admin_user)
|
||||
|
||||
with mock_price_fetcher(20000.0):
|
||||
async with client_factory.create(cookies=regular_user["cookies"]) as client:
|
||||
# Lightning with amount at threshold
|
||||
response = await client.post(
|
||||
"/api/exchange",
|
||||
json={
|
||||
"slot_start": f"{target_date}T09:00:00Z",
|
||||
"direction": "buy",
|
||||
"bitcoin_transfer_method": "lightning",
|
||||
"eur_amount": 100000, # €1000, exactly at threshold
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["bitcoin_transfer_method"] == "lightning"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_onchain_above_threshold_accepted(
|
||||
self, client_factory, regular_user, admin_user
|
||||
):
|
||||
"""Onchain payment above threshold is accepted."""
|
||||
target_date = await setup_availability_and_price(client_factory, admin_user)
|
||||
|
||||
with mock_price_fetcher(20000.0):
|
||||
async with client_factory.create(cookies=regular_user["cookies"]) as client:
|
||||
# Onchain with amount above Lightning threshold
|
||||
response = await client.post(
|
||||
"/api/exchange",
|
||||
json={
|
||||
"slot_start": f"{target_date}T09:00:00Z",
|
||||
"direction": "buy",
|
||||
"bitcoin_transfer_method": "onchain",
|
||||
"eur_amount": 110000, # €1100, above €1000 threshold
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["bitcoin_transfer_method"] == "onchain"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_amount_below_minimum_rejected(
|
||||
self, client_factory, regular_user, admin_user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue