From e50fa281439c9981c8ea69da09d7bbfe5d2123b5 Mon Sep 17 00:00:00 2001 From: ai-bot Date: Mon, 16 Nov 2026 19:33:24 +0000 Subject: [PATCH] Add a helper that finds the sale --- tests/test_ledger.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_ledger.py b/tests/test_ledger.py index a865b70..b89b27d 100644 --- a/tests/test_ledger.py +++ b/tests/test_ledger.py @@ -130,6 +130,20 @@ def consumptions(tx_id): conn.close() +def sale_id(market_id): + """The one transaction of an account that gives sats away.""" + conn = database.connect() + try: + row = conn.execute( + "SELECT id FROM transactions WHERE market_id = ? AND leg_out_sats IS NOT NULL" + " ORDER BY id LIMIT 1", + (market_id,), + ).fetchone() + return row["id"] + finally: + conn.close() + + def snapshot(): conn = database.connect() try: