import unittest

from ledger import Ledger


class HoldoutLedgerTests(unittest.TestCase):
    def test_multiple_rejections_do_not_consume_id(self):
        ledger = Ledger()
        for _ in range(2):
            with self.assertRaises(ValueError):
                ledger.apply("withdraw", "a", -2)
        ledger.apply("fund", "a", 4)
        self.assertEqual(ledger.apply("withdraw", "a", -2), 2)
