diff options
-rw-r--r-- | test_ledger_process.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test_ledger_process.py b/test_ledger_process.py index 274060f..f33988c 100644 --- a/test_ledger_process.py +++ b/test_ledger_process.py @@ -107,5 +107,56 @@ class TestLedgerProcess(unittest.TestCase): self.lp.external_wallet["BTC"].get_remaining_amount(), Decimal("0.098") ) + def test_withdraw_and_deposit_afterbalance(self): + """Test withdrawing, then depositing, and subsequently checking balance.""" + + 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", + ) + + withdrawal = LedgerAction( + type="withdrawal", + asset="BTC", + # already includes removed fee + amount=Decimal("-0.098"), + fee=Decimal("0.001"), + timestamp="2025-04-17 12:00:00", + refid="67890", + ) + + # TODO: Check how Kraken handles deposits + deposit = LedgerAction( + type="deposit", + asset="BTC", + amount=Decimal("0.098"), + fee=Decimal("0.000"), + timestamp="2025-04-17 14:00:00", + refid="55555", + ) + + self.lp.process_ledger([eur_trade, crypto_trade, withdrawal, deposit]) + + self.assertEqual(len(self.lp.fifo_queues["BTC"]), 1) + self.assertEqual( + self.lp.fifo_queues["BTC"].get_remaining_amount(), Decimal("0.098") + ) + self.assertEqual(len(self.lp.external_wallet["BTC"]), 0) + self.assertEqual( + self.lp.external_wallet["BTC"].get_remaining_amount(), Decimal("0.0") + ) + if __name__ == "__main__": unittest.main() |