[perf] Faster require invoice key (#3603)

This commit is contained in:
Vlad Stan 2025-12-05 10:03:51 +02:00 committed by GitHub
parent d9b045c526
commit 850087a8ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 175 additions and 40 deletions

View file

@ -5,7 +5,7 @@ import operator
import pytest
from lnbits.core.models import BaseWallet
from lnbits.core.models import WalletInfo
from tests.wallets.fixtures.models import FundingSourceConfig, WalletTest
wallets_module = importlib.import_module("lnbits.wallets")
@ -57,7 +57,7 @@ def build_test_id(test: WalletTest):
return f"{test.funding_source.name}.{test.function}({test.description})"
def load_funding_source(funding_source: FundingSourceConfig) -> BaseWallet:
def load_funding_source(funding_source: FundingSourceConfig) -> WalletInfo:
custom_settings = funding_source.settings
original_settings = {}
@ -67,7 +67,7 @@ def load_funding_source(funding_source: FundingSourceConfig) -> BaseWallet:
original_settings[s] = getattr(settings, s)
setattr(settings, s, custom_settings[s])
fs_instance: BaseWallet = getattr(wallets_module, funding_source.wallet_class)()
fs_instance: WalletInfo = getattr(wallets_module, funding_source.wallet_class)()
# rollback settings (global variable)
for s in original_settings:

View file

@ -5,7 +5,7 @@ import pytest
from loguru import logger
from pytest_mock.plugin import MockerFixture
from lnbits.core.models import BaseWallet
from lnbits.core.models import WalletInfo
from tests.wallets.fixtures.models import DataObject
from tests.wallets.fixtures.models import Mock as RpcMock
from tests.wallets.helpers import (
@ -91,7 +91,7 @@ def _check_calls(expected_calls):
func_call["spy"].assert_called_with(*args, **kwargs)
def _spy_mocks(mocker: MockerFixture, test_data: WalletTest, wallet: BaseWallet):
def _spy_mocks(mocker: MockerFixture, test_data: WalletTest, wallet: WalletInfo):
expected_calls: dict[str, list] = {}
for mock in test_data.mocks:
client_field = getattr(wallet, mock.name)