summaryrefslogtreecommitdiff
path: root/test_ledger_process.py
diff options
context:
space:
mode:
authoruvok2025-04-18 19:39:53 +0200
committeruvok2025-04-18 19:39:53 +0200
commit4c151464b276db6d1a5b2a74736f1c696b1d3f52 (patch)
treebdf1ae971b48c5e0822592011bdab79d08ff3df7 /test_ledger_process.py
parentcd0777e35e114ed485706fa58d475e2352e1c42a (diff)
Test withdraw-before-trade
Diffstat (limited to 'test_ledger_process.py')
-rw-r--r--test_ledger_process.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/test_ledger_process.py b/test_ledger_process.py
index 3fe54dc..cf5e64c 100644
--- a/test_ledger_process.py
+++ b/test_ledger_process.py
@@ -66,6 +66,39 @@ class TestLedgerProcess(unittest.TestCase):
with self.assertRaises(TradeNotFound):
self.lp.process_ledger([deposit])
+ def test_withdraw_before_trade(self):
+ """Test withdrawing before the trade occurred."""
+
+ withdrawal = LedgerAction(
+ type="withdrawal",
+ asset="BTC",
+ # already includes removed fee
+ amount=Decimal("-0.098"),
+ fee=Decimal("0.001"),
+ timestamp="2024-04-17 12:00:00",
+ refid="67890",
+ )
+
+ 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])
+
def test_withdraw_afterbalance(self):
"""Test withdrawing and subsequently checking balance."""
@@ -158,5 +191,6 @@ class TestLedgerProcess(unittest.TestCase):
self.lp.external_wallet["BTC"].get_remaining_amount(), Decimal("0.0")
)
+
if __name__ == "__main__":
unittest.main()