From 58a5dac33d8fc37158f2190cf6d0501b15644a69 Mon Sep 17 00:00:00 2001 From: uvok Date: Fri, 18 Apr 2025 19:46:01 +0200 Subject: Add test --- test_ledger_process.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test_ledger_process.py') diff --git a/test_ledger_process.py b/test_ledger_process.py index cf5e64c..0824a7b 100644 --- a/test_ledger_process.py +++ b/test_ledger_process.py @@ -66,6 +66,51 @@ class TestLedgerProcess(unittest.TestCase): with self.assertRaises(TradeNotFound): self.lp.process_ledger([deposit]) + def test_deposit_before_trade(self): + """Test depositing before the trade occurred. + + Can't work anyway b/c there's no matching withdraw. + """ + + withdrawal = LedgerAction( + type="withdrawal", + asset="BTC", + # already includes removed fee + amount=Decimal("-0.098"), + fee=Decimal("0.001"), + timestamp="2025-04-18 12:00:00", + refid="67890", + ) + + deposit = LedgerAction( + type="deposit", + asset="BTC", + amount=Decimal("0.098"), + fee=Decimal("0.001"), + timestamp="2024-04-18 12:00:00", + refid="ABCDE", + ) + + eur_trade = LedgerAction( + type="trade", + asset="EUR", + amount=Decimal("-500.00"), + fee=Decimal("2.00"), + timestamp="2025-04-17 10:00:00", + refid="12345", + ) + crypto_trade = LedgerAction( + type="trade", + asset="BTC", + amount=Decimal("0.1"), + fee=Decimal("0.001"), + timestamp="2025-04-17 10:00:00", + refid="12345", + ) + + with self.assertRaises(TradeNotFound): + self.lp.process_ledger([eur_trade, withdrawal, crypto_trade, deposit]) + def test_withdraw_before_trade(self): """Test withdrawing before the trade occurred.""" -- cgit v1.2.3