Github CI with Postgres (#417)

* with postgres

* postgres test explicit

* make format

* start postgres only if needed

* remove if again

* print db

* db in matrix

* delete schema

* use new env var MINT_TEST_DATABASE for tests

* add db path to regtest
This commit is contained in:
callebtc
2024-02-11 15:52:02 +01:00
committed by GitHub
parent 78de84f3eb
commit f74f18c9ca
7 changed files with 41 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ settings.mint_lightning_backend = settings.mint_lightning_backend or "FakeWallet
settings.fakewallet_brr = True
settings.fakewallet_delay_payment = False
settings.fakewallet_stochastic_invoice = False
settings.mint_database = "./test_data/test_mint"
settings.mint_database = settings.mint_test_database
settings.mint_derivation_path = "m/0'/0'/0'"
settings.mint_derivation_path_list = []
settings.mint_private_key = "TEST_PRIVATE_KEY"
@@ -100,6 +100,13 @@ async def ledger():
db_file = os.path.join(settings.mint_database, "mint.sqlite3")
if os.path.exists(db_file):
os.remove(db_file)
else:
# clear postgres database
db = Database("mint", settings.mint_database)
async with db.connect() as conn:
await conn.execute("DROP SCHEMA public CASCADE;")
await conn.execute("CREATE SCHEMA public;")
wallets_module = importlib.import_module("cashu.lightning")
lightning_backend = getattr(wallets_module, settings.mint_lightning_backend)()
backends = {

View File

@@ -31,6 +31,7 @@ is_fake: bool = WALLET.__class__.__name__ == "FakeWallet"
is_regtest: bool = not is_fake
is_deprecated_api_only = settings.debug_mint_only_deprecated
is_github_actions = os.getenv("GITHUB_ACTIONS") == "true"
is_postgres = settings.mint_database.startswith("postgres")
docker_lightning_cli = [
"docker",

View File

@@ -6,6 +6,7 @@ from cashu.mint.ledger import Ledger
from cashu.wallet.wallet import Wallet
from cashu.wallet.wallet import Wallet as Wallet1
from tests.conftest import SERVER_ENDPOINT
from tests.helpers import is_postgres
async def assert_err(f, msg):
@@ -61,3 +62,10 @@ async def test_melt_quote(wallet1: Wallet, ledger: Ledger):
assert quote.checking_id == invoice.payment_hash
assert quote.paid_time is None
assert quote.created_time
@pytest.mark.asyncio
@pytest.mark.skipif(not is_postgres, reason="only works with Postgres")
async def test_postgres_working():
assert is_postgres
assert True