lnbits/tests/helpers.py
calle 8535d70d36
Poetry dev (#837)
* black and isort for tests

* black and isort for build

* use poetry in Makefile, update pyproject.toml dependencies and add configs for black, pytest, mypy, isort there

* switching github workflow to poetry

* set mininum version to python 3.7

* fix tests

* add types-protobuf to dev packages

* fix cln regtest

* update docs

* try fix 1

* mypy fix2

* fix isort formatting workflow

* add prettier to dev docs

* multiple valid python version for pyproject

* update poetry.lock

* remove development installation, not needed anymore

* fix migration workflows

* format into one test

* fix yaml

* fix pipeline

* fix pipeline

* fix again

* fix

* rename checks

* remove venv tests

* venv test once

Co-authored-by: dni <dni.khr@gmail.com>
2022-08-03 14:10:32 +02:00

35 lines
926 B
Python

import hashlib
import random
import secrets
import string
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=f"funding_test_{get_random_string(5)}",
amount=amount, # msat
pending=False, # not pending, so it will increase the wallet's balance
)
def get_random_string(N=10):
return "".join(
random.SystemRandom().choice(string.ascii_uppercase + string.digits)
for _ in range(10)
)
async def get_random_invoice_data():
return {"out": False, "amount": 10, "memo": f"test_memo_{get_random_string(10)}"}