test fixes

This commit is contained in:
Kyle
2025-08-06 23:48:13 -04:00
parent 2aebef7722
commit f0bb897f75
4 changed files with 13 additions and 5 deletions
+5 -2
View File
@@ -226,7 +226,7 @@ class TestmintWallet:
# For testing, create a refund token
return await self.mint_tokens(amount)
async def send_token(self, amount: int, unit: str, mint_url: str = None) -> str:
async def send_token(self, amount: int, unit: str, mint_url: Optional[str] = None) -> str:
"""Send token with compatible signature for mocking router.wallet.send_token"""
return await self.send(amount)
@@ -275,7 +275,9 @@ class TestmintWallet:
return amount_msat
except Exception as e:
print(f"ERROR: credit_balance failed: {e}")
raise
import traceback
print(f"ERROR: Full traceback: {traceback.format_exc()}")
raise ValueError(f"Failed to redeem token: {str(e)}")
@pytest_asyncio.fixture
@@ -472,6 +474,7 @@ async def integration_app(
patch("router.wallet.PRIMARY_MINT_URL", "http://mint:3338"),
patch("router.auth.credit_balance", testmint_wallet.credit_balance),
patch("router.wallet.credit_balance", testmint_wallet.credit_balance),
patch("router.balance.credit_balance", testmint_wallet.credit_balance),
patch("router.wallet.send_token", testmint_wallet.send_token),
patch("router.balance.send_token", testmint_wallet.send_token),
):
@@ -179,7 +179,9 @@ class TestInvalidInputHandling:
# All should fail with 400
assert response.status_code == 400, f"Token {repr(token)} should fail"
assert "invalid" in response.json()["detail"].lower()
# Accept various error messages that indicate token validation failure
error_detail = response.json()["detail"].lower()
assert any(keyword in error_detail for keyword in ["invalid", "failed to redeem", "failed to decode"]), f"Unexpected error message: {error_detail}"
@pytest.mark.asyncio
async def test_invalid_json_payloads(
+3
View File
@@ -89,6 +89,9 @@ async def test_full_wallet_flow(
"/v1/wallet/topup", params={"cashu_token": topup_token}
)
if topup_response.status_code != 200:
print(f"ERROR: Topup failed with status {topup_response.status_code}")
print(f"ERROR: Response body: {topup_response.json()}")
assert topup_response.status_code == 200
assert topup_response.json()["msats"] == topup_amount * 1000
@@ -105,8 +105,8 @@ async def test_root_endpoint_environment_variables(
data = response.json()
# Check that environment variables are reflected in response
# These are set in conftest.py
assert "https://mint.minibits.cash/Bitcoin" in data["mints"]
# These are set in conftest.py for test environment
assert "http://mint:3338" in data["mints"]
# Name should have a default value or be configurable
assert len(data["name"]) > 0