mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-11 17:57:53 +01:00
* add status to statusdialog * first commits for boltz update * formatting * add latest boltz-clien package * big refactor, depending on boltz_client package, clean up, mypy issues, not tested yet * blacking, sorting and stuff * remove unused req_wrap helper * remove api docs from frontend * bug: frontend boltz limits error * clean up buttons * update to boltz-client 0.0.8 * fix tests to poetry version 1.3.1 * update requirements * formatting * recurring swap works now, need more finetuning * add exceptions for multiple auto swaps and swapping in with active auto swap * black * auto reverse swap actually works :) * remove swap status dialogs * update to boltz_client 0.0.9 * update to boltz-client 0.1.1, and fix startup * update requirement.txt for boltz-client * fixup columns in table, remove unused payment.extra, change deezy label * remove balance check for auto swap out * update boltzc-lient to 0.1.2, fix mypy issue inside boltz package * nitpicks calle tasks.py * calle nitpicks crud * calle nitpicks crud * refactor * fix formatting * circular import * black :) Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
102 lines
3.9 KiB
Python
102 lines
3.9 KiB
Python
import pytest
|
|
|
|
from tests.helpers import is_fake
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.skipif(is_fake, reason="this test is only passes with regtest")
|
|
async def test_mempool_url(client):
|
|
response = await client.get("/boltz/api/v1/swap/mempool")
|
|
assert response.status_code == 200
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.skipif(is_fake, reason="this test is only passes with regtest")
|
|
async def test_boltz_config(client):
|
|
response = await client.get("/boltz/api/v1/swap/boltz")
|
|
assert response.status_code == 200
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.skipif(is_fake, reason="this test is only passes with regtest")
|
|
async def test_endpoints_unauthenticated(client):
|
|
response = await client.get("/boltz/api/v1/swap?all_wallets=true")
|
|
assert response.status_code == 401
|
|
response = await client.get("/boltz/api/v1/swap/reverse?all_wallets=true")
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap")
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/reverse")
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/status")
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/check")
|
|
assert response.status_code == 401
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.skipif(is_fake, reason="this test is only passes with regtest")
|
|
async def test_endpoints_inkey(client, inkey_headers_to):
|
|
response = await client.get(
|
|
"/boltz/api/v1/swap?all_wallets=true", headers=inkey_headers_to
|
|
)
|
|
assert response.status_code == 200
|
|
response = await client.get(
|
|
"/boltz/api/v1/swap/reverse?all_wallets=true", headers=inkey_headers_to
|
|
)
|
|
assert response.status_code == 200
|
|
|
|
response = await client.post("/boltz/api/v1/swap", headers=inkey_headers_to)
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/reverse", headers=inkey_headers_to)
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/refund", headers=inkey_headers_to)
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/status", headers=inkey_headers_to)
|
|
assert response.status_code == 401
|
|
response = await client.post("/boltz/api/v1/swap/check", headers=inkey_headers_to)
|
|
assert response.status_code == 401
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.skipif(is_fake, reason="this test is only passes with regtest")
|
|
async def test_endpoints_adminkey_badrequest(client, adminkey_headers_to):
|
|
response = await client.post("/boltz/api/v1/swap", headers=adminkey_headers_to)
|
|
assert response.status_code == 400
|
|
response = await client.post(
|
|
"/boltz/api/v1/swap/reverse", headers=adminkey_headers_to
|
|
)
|
|
assert response.status_code == 400
|
|
response = await client.post(
|
|
"/boltz/api/v1/swap/refund", headers=adminkey_headers_to
|
|
)
|
|
assert response.status_code == 400
|
|
response = await client.post(
|
|
"/boltz/api/v1/swap/status", headers=adminkey_headers_to
|
|
)
|
|
assert response.status_code == 400
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
@pytest.mark.skipif(is_fake, reason="this test is only passes with regtest")
|
|
async def test_endpoints_adminkey_regtest(client, from_wallet, adminkey_headers_to):
|
|
swap = {
|
|
"wallet": from_wallet.id,
|
|
"refund_address": "bcrt1q3cwq33y435h52gq3qqsdtczh38ltlnf69zvypm",
|
|
"amount": 50_000,
|
|
}
|
|
response = await client.post(
|
|
"/boltz/api/v1/swap", json=swap, headers=adminkey_headers_to
|
|
)
|
|
assert response.status_code == 201
|
|
|
|
reverse_swap = {
|
|
"wallet": from_wallet.id,
|
|
"instant_settlement": True,
|
|
"onchain_address": "bcrt1q4vfyszl4p8cuvqh07fyhtxve5fxq8e2ux5gx43",
|
|
"amount": 50_000,
|
|
}
|
|
response = await client.post(
|
|
"/boltz/api/v1/swap/reverse", json=reverse_swap, headers=adminkey_headers_to
|
|
)
|
|
assert response.status_code == 201
|