Based on the repository's commit message style and the changes in the diff, here's an appropriate commit message:
``` feat: add websocket tests, PoA metrics, marketplace endpoints, and enhanced observability - Add comprehensive websocket tests for blocks and transactions streams including multi-subscriber and high-volume scenarios - Extend PoA consensus with per-proposer block metrics and rotation tracking - Add latest block interval gauge and RPC error spike alerting - Enhance mock coordinator
This commit is contained in:
@ -96,6 +96,7 @@ def list_wallets(
|
||||
WalletDescriptor(wallet_id=record.wallet_id, public_key=record.public_key, metadata=metadata)
|
||||
)
|
||||
|
||||
return WalletListResponse(items=descriptors)
|
||||
|
||||
@router.post("/wallets", response_model=WalletCreateResponse, status_code=status.HTTP_201_CREATED, summary="Create wallet")
|
||||
def create_wallet(
|
||||
@ -119,7 +120,10 @@ def create_wallet(
|
||||
metadata=request.metadata,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(exc)) from exc
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
detail={"reason": "password_too_weak", "min_length": 10, "message": str(exc)},
|
||||
) from exc
|
||||
|
||||
ledger.upsert_wallet(record.wallet_id, record.public_key, record.metadata)
|
||||
ledger.record_event(record.wallet_id, "created", {"metadata": record.metadata})
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from aitbc_chain.app import create_app # noqa: I100
|
||||
|
||||
from app.deps import get_keystore, get_ledger
|
||||
from app.deps import get_keystore, get_ledger, get_settings
|
||||
from app.main import create_app
|
||||
from app.keystore.service import KeystoreService
|
||||
from app.ledger_mock import SQLiteLedgerAdapter
|
||||
|
||||
|
||||
@pytest.fixture(name="client")
|
||||
@ -15,12 +17,24 @@ def client_fixture(tmp_path, monkeypatch):
|
||||
# Override ledger path to temporary directory
|
||||
from app.settings import Settings
|
||||
|
||||
class TestSettings(Settings):
|
||||
ledger_db_path = tmp_path / "ledger.db"
|
||||
test_settings = Settings(LEDGER_DB_PATH=str(tmp_path / "ledger.db"))
|
||||
|
||||
monkeypatch.setattr("app.deps.get_settings", lambda: TestSettings())
|
||||
monkeypatch.setattr("app.settings.settings", test_settings)
|
||||
|
||||
from app import deps
|
||||
|
||||
deps.get_settings.cache_clear()
|
||||
deps.get_keystore.cache_clear()
|
||||
deps.get_ledger.cache_clear()
|
||||
|
||||
app = create_app()
|
||||
|
||||
keystore = KeystoreService()
|
||||
ledger = SQLiteLedgerAdapter(Path(test_settings.ledger_db_path))
|
||||
|
||||
app.dependency_overrides[get_settings] = lambda: test_settings
|
||||
app.dependency_overrides[get_keystore] = lambda: keystore
|
||||
app.dependency_overrides[get_ledger] = lambda: ledger
|
||||
return TestClient(app)
|
||||
|
||||
|
||||
@ -79,4 +93,6 @@ def test_wallet_password_rules(client: TestClient):
|
||||
json={"wallet_id": "weak", "password": "short"},
|
||||
)
|
||||
assert response.status_code == 400
|
||||
***
|
||||
body = response.json()
|
||||
assert body["detail"]["reason"] == "password_too_weak"
|
||||
assert "min_length" in body["detail"]
|
||||
|
||||
Reference in New Issue
Block a user