Skip to content

Commit

Permalink
keep one
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Nov 5, 2024
1 parent c518c6b commit bae748d
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions tests/test_db.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import datetime
import os
import time
Expand All @@ -13,7 +14,7 @@
from cashu.mint.ledger import Ledger
from cashu.wallet.wallet import Wallet
from tests.conftest import SERVER_ENDPOINT
from tests.helpers import is_github_actions, is_postgres
from tests.helpers import is_github_actions, is_postgres, pay_if_regtest


async def assert_err(f, msg):
Expand Down Expand Up @@ -188,26 +189,26 @@ async def get_connection():
await assert_err(get_connection(), "failed to acquire database lock")


# @pytest.mark.asyncio
# async def test_db_verify_spent_proofs_and_set_pending_race_condition(
# wallet: Wallet, ledger: Ledger
# ):
# # fill wallet
# mint_quote = await wallet.request_mint(64)
# await pay_if_regtest(mint_quote.request)
# await wallet.mint(64, quote_id=mint_quote.quote)
# assert wallet.balance == 64

# await assert_err_multiple(
# asyncio.gather(
# ledger.db_write._verify_spent_proofs_and_set_pending(wallet.proofs),
# ledger.db_write._verify_spent_proofs_and_set_pending(wallet.proofs),
# ),
# [
# "failed to acquire database lock",
# "proofs are pending",
# ], # depending on how fast the database is, it can be either
# )
@pytest.mark.asyncio
async def test_db_verify_spent_proofs_and_set_pending_race_condition(
wallet: Wallet, ledger: Ledger
):
# fill wallet
mint_quote = await wallet.request_mint(64)
await pay_if_regtest(mint_quote.request)
await wallet.mint(64, quote_id=mint_quote.quote)
assert wallet.balance == 64

await assert_err_multiple(
asyncio.gather(
ledger.db_write._verify_spent_proofs_and_set_pending(wallet.proofs),
ledger.db_write._verify_spent_proofs_and_set_pending(wallet.proofs),
),
[
"failed to acquire database lock",
"proofs are pending",
], # depending on how fast the database is, it can be either
)


# @pytest.mark.asyncio
Expand Down

0 comments on commit bae748d

Please sign in to comment.