From 03b00f3eb6a5847e68b16c70c4a81b7190c414e0 Mon Sep 17 00:00:00 2001 From: Jeroen Ubbink Date: Wed, 22 Jul 2026 17:01:28 +0200 Subject: [PATCH] test(wallet): isolate get_balance from the module wallet cache test_get_balance mocked Wallet.with_db but not the module-level _wallets cache, so a real wallet cached by an earlier unmocked path (e.g. an admin-withdraw amount-rejection test) could shadow the mock and fail the assertion depending on collection order. Reset the cache for the test, as the sibling wallet tests already do. --- tests/unit/test_wallet.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_wallet.py b/tests/unit/test_wallet.py index 3bb36a28..ddb5aa54 100644 --- a/tests/unit/test_wallet.py +++ b/tests/unit/test_wallet.py @@ -26,7 +26,11 @@ async def test_get_balance() -> None: mock_wallet.load_mint = AsyncMock() mock_wallet.load_proofs = AsyncMock() - with patch("routstr.wallet.Wallet.with_db", return_value=mock_wallet): + # Reset the module-level wallet cache so a real wallet cached by an earlier + # test (e.g. an unmocked admin-withdraw path) can't shadow the mock here. + with patch("routstr.wallet._wallets", {}), patch( + "routstr.wallet.Wallet.with_db", return_value=mock_wallet + ): balance = await get_balance("sat") assert balance == 50000