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.
This commit is contained in:
Jeroen Ubbink
2026-07-23 10:51:21 +02:00
parent 7e8c2033ae
commit 03b00f3eb6
+5 -1
View File
@@ -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