mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-26 17:51:53 +01:00
test: fix lndrest on regtest (#2811)
* fix: lndrest on regtest * fix some race conditions on lndrest
This commit is contained in:
parent
61c71660b8
commit
1b9bb32ca0
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -75,7 +75,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.10"]
|
||||
backend-wallet-class: ["LndWallet", "CoreLightningWallet", "CoreLightningRestWallet", "LNbitsWallet", "EclairWallet"]
|
||||
backend-wallet-class: ["LndRestWallet", "LndWallet", "CoreLightningWallet", "CoreLightningRestWallet", "LNbitsWallet", "EclairWallet"]
|
||||
with:
|
||||
custom-pytest: "poetry run pytest tests/regtest"
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
@ -159,9 +159,15 @@ class LndRestNode(Node):
|
||||
timeout=None,
|
||||
) as stream:
|
||||
async for chunk in stream.aiter_text():
|
||||
if chunk:
|
||||
chunk = json.loads(chunk)
|
||||
logger.info(f"LND Channel close update: {chunk['result']}")
|
||||
if not chunk:
|
||||
continue
|
||||
chunk = json.loads(chunk)
|
||||
if "error" in chunk:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
|
||||
detail=chunk["error"].get("message"),
|
||||
)
|
||||
logger.info(f"LND Channel close update: {chunk.get('result')}")
|
||||
|
||||
async def close_channel(
|
||||
self,
|
||||
|
@ -3,11 +3,6 @@ import pytest
|
||||
from .helpers import get_hold_invoice, get_real_invoice
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def anyio_backend():
|
||||
return "asyncio"
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
async def hold_invoice():
|
||||
invoice = get_hold_invoice(100)
|
||||
|
@ -20,7 +20,8 @@ docker_lightning_cli = [
|
||||
docker_bitcoin_cli = [
|
||||
"docker",
|
||||
"exec",
|
||||
"lnbits-bitcoind-1-1" "bitcoin-cli",
|
||||
"lnbits-bitcoind-1",
|
||||
"bitcoin-cli",
|
||||
"-rpcuser=lnbits",
|
||||
"-rpcpassword=lnbits",
|
||||
"-regtest",
|
||||
|
@ -57,6 +57,7 @@ async def test_pay_real_invoice(
|
||||
|
||||
await asyncio.sleep(1)
|
||||
balance = await get_node_balance_sats()
|
||||
# TODO: maybe take fee into consideration?
|
||||
assert prev_balance - balance == 100
|
||||
|
||||
|
||||
@ -158,7 +159,7 @@ async def test_pay_hold_invoice_check_pending(
|
||||
headers=adminkey_headers_from,
|
||||
)
|
||||
)
|
||||
await asyncio.sleep(1)
|
||||
await asyncio.sleep(3)
|
||||
# get payment hash from the invoice
|
||||
invoice_obj = bolt11.decode(invoice["payment_request"])
|
||||
settle_invoice(preimage)
|
||||
|
@ -102,6 +102,8 @@ async def test_node_payments(node_client, real_invoice, adminkey_headers_from):
|
||||
@pytest.mark.anyio
|
||||
async def test_channel_management(node_client):
|
||||
async def get_channels():
|
||||
# lndrest is slow / async with channel commands
|
||||
await asyncio.sleep(3)
|
||||
response = await node_client.get("/node/api/v1/channels")
|
||||
assert response.status_code == 200
|
||||
return parse_obj_as(list[NodeChannel], response.json())
|
||||
@ -134,6 +136,7 @@ async def test_channel_management(node_client):
|
||||
)
|
||||
assert response.status_code == 200
|
||||
created = ChannelPoint(**response.json())
|
||||
|
||||
data = await get_channels()
|
||||
assert any(
|
||||
channel.point == created and channel.state == ChannelState.PENDING
|
||||
@ -145,6 +148,8 @@ async def test_channel_management(node_client):
|
||||
# left for testing
|
||||
mine_blocks(5)
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_peer_management(node_client):
|
||||
|
Loading…
x
Reference in New Issue
Block a user