mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-07-30 15:26:14 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user