chore: adhere to ruff's "N" rules (#2377)

* chore: adhere to ruff's "N" rules

WARN: reinstall failing extensions!

bunch of more consistent variable naming. inspired by this issue.
https://github.com/lnbits/lnbits/issues/2308

* fixup! chore: adhere to ruff's "N" rules
* rename to funding_source
* skip jmeter

---------

Co-authored-by: Pavol Rusnak <pavol@rusnak.io>
This commit is contained in:
dni ⚡ 2024-04-15 09:02:21 +02:00 committed by GitHub
parent 055426ab53
commit 6d5ad9e229
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 191 additions and 173 deletions

View file

@ -176,8 +176,8 @@ async def adminkey_headers_to(to_wallet):
@pytest_asyncio.fixture(scope="session")
async def invoice(to_wallet):
data = await get_random_invoice_data()
invoiceData = CreateInvoice(**data)
invoice = await api_payments_create_invoice(invoiceData, to_wallet)
invoice_data = CreateInvoice(**data)
invoice = await api_payments_create_invoice(invoice_data, to_wallet)
yield invoice
del invoice

View file

@ -10,7 +10,7 @@ from lnbits.core.services import fee_reserve_total
from lnbits.core.views.admin_api import api_auditor
from lnbits.core.views.payment_api import api_payment
from lnbits.settings import settings
from lnbits.wallets import get_wallet_class
from lnbits.wallets import get_funding_source
from ...helpers import (
cancel_invoice,
@ -22,7 +22,7 @@ from ...helpers import (
settle_invoice,
)
WALLET = get_wallet_class()
funding_source = get_funding_source()
# create account POST /api/v1/account
@ -407,7 +407,8 @@ async def test_api_payment_with_key(invoice, inkey_headers_from):
# check POST /api/v1/payments: invoice creation with a description hash
@pytest.mark.skipif(
WALLET.__class__.__name__ in ["CoreLightningWallet", "CoreLightningRestWallet"],
funding_source.__class__.__name__
in ["CoreLightningWallet", "CoreLightningRestWallet"],
reason="wallet does not support description_hash",
)
@pytest.mark.asyncio
@ -428,7 +429,7 @@ async def test_create_invoice_with_description_hash(client, inkey_headers_to):
@pytest.mark.skipif(
WALLET.__class__.__name__ in ["CoreLightningRestWallet"],
funding_source.__class__.__name__ in ["CoreLightningRestWallet"],
reason="wallet does not support unhashed_description",
)
@pytest.mark.asyncio
@ -540,8 +541,8 @@ async def test_pay_real_invoice(
payment_status = response.json()
assert payment_status["paid"]
WALLET = get_wallet_class()
status = await WALLET.get_payment_status(invoice["payment_hash"])
funding_source = get_funding_source()
status = await funding_source.get_payment_status(invoice["payment_hash"])
assert status.paid
await asyncio.sleep(1)
@ -571,7 +572,7 @@ async def test_create_real_invoice(client, adminkey_headers_from, inkey_headers_
async def listen():
found_checking_id = False
async for checking_id in get_wallet_class().paid_invoices_stream():
async for checking_id in get_funding_source().paid_invoices_stream():
if checking_id == invoice["checking_id"]:
found_checking_id = True
return
@ -622,8 +623,8 @@ async def test_pay_real_invoice_set_pending_and_check_state(
assert response["paid"]
# make sure that the backend also thinks it's paid
WALLET = get_wallet_class()
status = await WALLET.get_payment_status(invoice["payment_hash"])
funding_source = get_funding_source()
status = await funding_source.get_payment_status(invoice["payment_hash"])
assert status.paid
# get the outgoing payment from the db
@ -800,7 +801,7 @@ async def test_receive_real_invoice_set_pending_and_check_state(
async def listen():
found_checking_id = False
async for checking_id in get_wallet_class().paid_invoices_stream():
async for checking_id in get_funding_source().paid_invoices_stream():
if checking_id == invoice["checking_id"]:
found_checking_id = True
return

View file

@ -10,14 +10,15 @@ from lnbits.nodes.base import ChannelPoint, ChannelState, NodeChannel
from tests.conftest import pytest_asyncio, settings
from ...helpers import (
WALLET,
funding_source,
get_random_invoice_data,
get_unconnected_node_uri,
mine_blocks,
)
pytestmark = pytest.mark.skipif(
WALLET.__node_cls__ is None, reason="Cant test if node implementation isnt avilable"
funding_source.__node_cls__ is None,
reason="Cant test if node implementation isnt available",
)

View file

@ -14,7 +14,7 @@ from pydantic import BaseModel
from lnbits import core
from lnbits.db import DB_TYPE, POSTGRES, FromRowModel
from lnbits.wallets import get_wallet_class, set_wallet_class
from lnbits.wallets import get_funding_source, set_funding_source
class DbTestModel(FromRowModel):
@ -23,10 +23,10 @@ class DbTestModel(FromRowModel):
value: Optional[str] = None
def get_random_string(N: int = 10):
def get_random_string(iterations: int = 10):
return "".join(
random.SystemRandom().choice(string.ascii_uppercase + string.digits)
for _ in range(N)
for _ in range(iterations)
)
@ -34,9 +34,9 @@ async def get_random_invoice_data():
return {"out": False, "amount": 10, "memo": f"test_memo_{get_random_string(10)}"}
set_wallet_class()
WALLET = get_wallet_class()
is_fake: bool = WALLET.__class__.__name__ == "FakeWallet"
set_funding_source()
funding_source = get_funding_source()
is_fake: bool = funding_source.__class__.__name__ == "FakeWallet"
is_regtest: bool = not is_fake