Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,20 @@ def create_onchain_payment(cls, order, user, preliminary_amount):
# Create onchain_payment
onchain_payment = OnchainPayment.objects.create(receiver=user)

if \
config("TIMING_EXTRA_IN_TESTS", cast=bool, default=False) and \
config("TESTING", cast=bool, default=False) and \
config("LNVENDOR", cast=str, default="LND") == "CLN":
import time
retries = 0
while onchain_payment.balance.onchain_confirmed == 0:
retries += 1
if retries > 30:
break
print("TIMING_EXTRA_IN_TESTS: onchain_payment.balance.onchain_confirmed is not 0, sleeping 2s")
time.sleep(2)
onchain_payment = OnchainPayment.objects.create(receiver=user)

# Compute a safer available onchain liquidity: (confirmed_utxos - reserve - pending_outgoing_txs))
# Accounts for already committed outgoing TX for previous users.
confirmed = onchain_payment.balance.onchain_confirmed
Expand Down
7 changes: 7 additions & 0 deletions api/management/commands/follow_invoices.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ def follow_hold_invoices(self):
INVGEN / LOCKED status and do InvoiceLookupV2 every X seconds to update their status.
"""

if \
config("TIMING_EXTRA_IN_TESTS", cast=bool, default=False) and \
config("TESTING", cast=bool, default=False) and \
config("LNVENDOR", cast=str, default="LND") == "LND":
print("TIMING_EXTRA_IN_TESTS: follow_hold_invoices LND, sleeping 0.2s")
time.sleep(0.2)

# time it for debugging
t0 = time.time()

Expand Down
Loading