diff options
author | uvok | 2025-04-18 18:06:20 +0200 |
---|---|---|
committer | uvok | 2025-04-18 18:06:20 +0200 |
commit | 47dea4347bb2f60347d0ed2ae5f4f1ea9d8c1b83 (patch) | |
tree | 27c3cb53346bfc6af833a2708edf8ce737ed616b /test_ledger_process.py | |
parent | ce147ed6f2851b922b26b5041100ac4e22d09bcf (diff) |
Check withdrawal
Diffstat (limited to 'test_ledger_process.py')
-rw-r--r-- | test_ledger_process.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test_ledger_process.py b/test_ledger_process.py index e5399d3..0dc58b8 100644 --- a/test_ledger_process.py +++ b/test_ledger_process.py @@ -66,6 +66,45 @@ class TestLedgerProcess(unittest.TestCase): with self.assertRaises(TradeNotFound): self.lp.process_ledger([deposit]) + def test_withdraw_afterbalance(self): + """Test withdrawing 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", + amount=Decimal("-0.099"), + fee=Decimal("0.00"), + timestamp="2025-04-17 12:00:00", + refid="67890", + ) + + self.lp.process_ledger([eur_trade, crypto_trade, withdrawal]) + + self.assertEqual(len(self.lp.fifo_queues["BTC"]), 0) + self.assertEqual( + self.lp.fifo_queues["BTC"].get_remaining_amount(), Decimal("0.0") + ) + self.assertEqual(len(self.lp.external_wallet["BTC"]), 1) + self.assertEqual( + self.lp.external_wallet["BTC"].get_remaining_amount(), Decimal("0.099") + ) if __name__ == "__main__": unittest.main() |