Add virtual coin loans
check / local-gate (push) Failing after 42s

This commit is contained in:
JWeBot Contributors
2026-10-15 18:43:49 +08:00
parent 2bb2effc04
commit bbddb5be6f
25 changed files with 346 additions and 25 deletions
@@ -91,6 +91,7 @@ class LocalExtensionInventoryTests(unittest.TestCase):
"dice": JWEBOT_AUTHOR,
"coin": JWEBOT_AUTHOR,
"coin-transfer": JWEBOT_AUTHOR,
"coin-loan": JWEBOT_AUTHOR,
"random-number": JWEBOT_AUTHOR,
"draw-lot": JWEBOT_AUTHOR,
"daily-fortune": JWEBOT_AUTHOR,
@@ -128,6 +129,7 @@ class LocalExtensionInventoryTests(unittest.TestCase):
"person_memory",
"memory_help",
),
"coin-loan": ("loan", "repay"),
"server-status": ("local_status", "server_status"),
"dice": ("dice", "dice_challenge"),
},
+27
View File
@@ -219,6 +219,33 @@ class Release063GameTests(unittest.TestCase):
self.assertEqual(self.state()["balance"], 1000)
self.assertEqual(self.state("Bob")["balance"], 1000)
def test_loan_repay_and_replay_once(self):
self.assertIn("金币 1000", self.command("/金币"))
first = self.command("/贷款 300", event_id="loan-1")
replay = self.command("/贷款 300", event_id="loan-1")
self.assertEqual(replay, first)
self.assertIn("贷款 300 金币已到账", first)
self.assertEqual(self.state()["balance"], 1300)
self.assertEqual(self.state()["loan"]["principal"], 300)
self.assertIn("未还贷款 300", self.command("/金币"))
self.assertIn("已有未还贷款 300", self.command("/贷款 100"))
partial = self.command("/还款 120")
self.assertIn("已还款 120 金币", partial)
self.assertEqual(self.state()["balance"], 1180)
self.assertEqual(self.state()["loan"]["principal"], 180)
done = self.command("/还款 全部")
self.assertIn("已还清贷款 180 金币", done)
self.assertEqual(self.state()["balance"], 1000)
self.assertIsNone(self.state()["loan"])
def test_loan_rejects_invalid_amounts_and_empty_repay(self):
self.assertIn("贷款金额必须为 1~500", self.command("/贷款 0"))
self.assertIn("贷款金额必须为 1~500", self.command("/loan 501"))
self.assertIn("当前没有未还贷款", self.command("/还款 全部"))
def test_open_round_and_history_survive_restart(self):
root = Path(self.temp.name)
self.command("/彩票开始")