test should pass now, WALLET is initialised after the settings are loaded from db.
This commit is contained in:
parent
35536dde9b
commit
89933c2d30
|
@ -15,7 +15,12 @@ from fastapi.staticfiles import StaticFiles
|
|||
from loguru import logger
|
||||
|
||||
from lnbits.core.tasks import register_task_listeners
|
||||
from lnbits.settings import check_admin_settings, get_wallet_class, settings
|
||||
from lnbits.settings import (
|
||||
check_admin_settings,
|
||||
get_wallet_class,
|
||||
set_wallet_class,
|
||||
settings,
|
||||
)
|
||||
|
||||
from .commands import migrate_databases
|
||||
from .core import core_app
|
||||
|
@ -144,7 +149,10 @@ def register_startup(app: FastAPI):
|
|||
|
||||
log_server_info()
|
||||
|
||||
# 3. initialize funding source
|
||||
# 3. initialize WALLET
|
||||
set_wallet_class()
|
||||
|
||||
# 4. initialize funding source
|
||||
await check_funding_source()
|
||||
|
||||
|
||||
|
|
|
@ -251,10 +251,20 @@ async def check_admin_settings():
|
|||
wallets_module = importlib.import_module("lnbits.wallets")
|
||||
FAKE_WALLET = getattr(wallets_module, "FakeWallet")()
|
||||
|
||||
# initialize as fake wallet
|
||||
WALLET = FAKE_WALLET
|
||||
|
||||
|
||||
# set wallet class after settings are loaded
|
||||
def set_wallet_class():
|
||||
wallet_class = getattr(wallets_module, settings.lnbits_backend_wallet_class)
|
||||
global WALLET
|
||||
WALLET = wallet_class()
|
||||
|
||||
|
||||
def get_wallet_class():
|
||||
wallet_class = getattr(wallets_module, settings.lnbits_backend_wallet_class)
|
||||
return wallet_class()
|
||||
# wallet_class = getattr(wallets_module, settings.lnbits_backend_wallet_class)
|
||||
return WALLET
|
||||
|
||||
|
||||
def send_admin_user_to_saas():
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
from mock import AsyncMock
|
||||
|
||||
from lnbits import bolt11
|
||||
from lnbits.settings import get_wallet_class
|
||||
from lnbits.wallets.base import PaymentResponse, PaymentStatus, StatusResponse
|
||||
from lnbits.wallets.fake import FakeWallet
|
||||
|
||||
from .helpers import get_random_string, is_fake
|
||||
from .helpers import WALLET, get_random_string, is_fake
|
||||
|
||||
WALLET = get_wallet_class()
|
||||
|
||||
# generates an invoice with FakeWallet
|
||||
async def generate_mock_invoice(**x):
|
||||
|
|
Loading…
Reference in New Issue
Block a user