Unit tests for FastAPI branch

Run via `make test`
This commit is contained in:
Charles Hill 2021-11-17 10:53:32 -06:00
parent d8e4237961
commit 4e6c30a909
No known key found for this signature in database
GPG key ID: 8BA978937688DB3E
19 changed files with 344 additions and 46 deletions

19
tests/helpers.py Normal file
View file

@ -0,0 +1,19 @@
import hashlib
import secrets
from lnbits.core.crud import create_payment
async def credit_wallet(wallet_id: str, amount: int):
preimage = secrets.token_hex(32)
m = hashlib.sha256()
m.update(f"{preimage}".encode())
payment_hash = m.hexdigest()
await create_payment(
wallet_id=wallet_id,
payment_request="",
payment_hash=payment_hash,
checking_id=payment_hash,
preimage=preimage,
memo="",
amount=amount,# msat
pending=False,# not pending, so it will increase the wallet's balance
)