Cover the lot price field and that admin_cost touches no lots

This commit is contained in:
ai-bot committed 2026-11-14 18:19:02 +00:00
1 parent 0d50f61fad
commit 4bd4e155bc
1 file changed
+31
+31
View File
@@ -245,6 +245,37 @@ class LedgerTestCase(unittest.TestCase):
self.assertEqual(ledger.holdings_at("2024-12-31"), {market_id: 150000000}) self.assertEqual(ledger.holdings_at("2024-12-31"), {market_id: 150000000})
self.assertEqual(ledger.sats_on_hand(), {market_id: 150000000}) self.assertEqual(ledger.sats_on_hand(), {market_id: 150000000})
def test_candidate_lots_carry_the_bitcoin_price(self):
market_id = golden_market()
ledger.rebuild()
lots = ledger.candidate_lots(market_id, "2024-12-31")
# April: 500 000 kr for 1,0 BTC. August: 200 000 kr for 0,5 BTC.
self.assertEqual(
[lot["btc_price_ore"] for lot in lots], [50000000, 40000000]
)
self.assertEqual([lot["sats_remaining"] for lot in lots], [100000000, 50000000])
def test_admin_cost_consumes_nothing(self):
market_id = golden_market()
cost = create_transaction(market_id=None, date="2024-12-01", type="admin_cost",
leg_out_sats=50000)
ledger.rebuild()
self.assertEqual(consumptions(cost), [])
self.assertEqual(ledger.holdings_at("2024-12-31"), {market_id: 150000000})
self.assertEqual(ledger.sats_on_hand(), {market_id: 150000000})
self.assertEqual(
sum(lot["sats_remaining"] for lot in lots_of(market_id)), 150000000
)
def test_rebuild_stays_the_same_with_an_admin_cost(self):
golden_market()
create_transaction(market_id=None, date="2024-12-01", type="admin_cost",
leg_out_sats=50000)
ledger.rebuild()
first = snapshot()
ledger.rebuild()
self.assertEqual(snapshot(), first)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()