Skip to content

Commit e40c7eb

Browse files
Fix backend and frontend CI test failures (#15)
* backend: revert returning mempool diagram from estimatesmartfee * prune redundant package json files * test: accept optional baseUrl in API constructor so test suite uses the injected mock URL. Co-authored-by: b-l-u-e <winnie.gitau282@gmail.com> * chore: commit package-lock.json * chore: remove redundant rpc_config.ini from backend .gitignore (covered by root) * ci: add workflow env vars run on every push --------- Co-authored-by: b-l-u-e <winnie.gitau282@gmail.com>
1 parent 744a0e5 commit e40c7eb

File tree

7 files changed

+11352
-911
lines changed

7 files changed

+11352
-911
lines changed

.github/workflows/tests.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
name: Tests
2-
32
on:
43
push:
5-
branches: [ "main", "feature/*" ]
6-
pull_request:
7-
branches: [ "main", "feature/*" ]
8-
94
jobs:
105
backend-tests:
116
runs-on: ubuntu-latest
@@ -24,9 +19,11 @@ jobs:
2419
pip install -r requirements.txt
2520
pip install pytest pytest-mock
2621
- name: Run tests
27-
run: |
28-
pytest tests/
29-
22+
run: pytest tests/
23+
env:
24+
RPC_URL: http://localhost:8332
25+
RPC_USER: test
26+
RPC_PASSWORD: test
3027
frontend-tests:
3128
runs-on: ubuntu-latest
3229
defaults:

backend/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ test_secure_connection.py
44
test_rpc_ports.py
55
test_getbestblockhash.py
66

7-
rpc_config.ini
87

backend/src/services/rpc_service.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -120,51 +120,15 @@ def get_single_block_stats(height: int) -> Dict[str, Any]:
120120
def get_block_count() -> int:
121121
return _rpc_call("getblockcount", [])
122122

123-
124-
def get_mempool_health_statistics() -> List[Dict[str, Any]]:
125-
"""
126-
Fetches stats for the last 5 blocks to compare their weights with
127-
the current mempool's readiness.
128-
"""
129-
current_height = get_block_count()
130-
stats = []
131-
132-
# Using getmempoolfeeratediagram for accurate total weight
133-
mempool_diagram = _rpc_call("getmempoolfeeratediagram", [])
134-
total_mempool_weight = mempool_diagram[-1]["weight"] if mempool_diagram else 0
135-
136-
for h in range(current_height - 4, current_height + 1):
137-
try:
138-
b = get_single_block_stats(h)
139-
weight = b.get("total_weight", 0)
140-
141-
stats.append({
142-
"block_height": h,
143-
"block_weight": weight,
144-
"mempool_txs_weight": total_mempool_weight,
145-
"ratio": min(1.0, total_mempool_weight / 4_000_000)
146-
})
147-
except Exception:
148-
continue
149-
return stats
150-
151-
152123
def estimate_smart_fee(conf_target: int, mode: str = "unset", verbosity_level: int = 2) -> Dict[str, Any]:
153124
effective_target = _clamp_target(conf_target)
154125
result = _rpc_call("estimatesmartfee", [effective_target, mode, verbosity_level])
155126
if result and "feerate" in result:
156127
# feerate is BTC/kVB → sat/vB: × 1e8 (BTC→sat) ÷ 1e3 (kVB→vB) = × 1e5
157128
result["feerate_sat_per_vb"] = result["feerate"] * 100_000
158129

159-
# Include health stats for the frontend
160-
try:
161-
result["mempool_health_statistics"] = get_mempool_health_statistics()
162-
except Exception as e:
163-
logger.error(f"Failed to include health stats: {e}")
164-
165130
return result
166131

167-
168132
def get_mempool_feerate_diagram_analysis() -> Dict[str, Any]:
169133
raw_points = _rpc_call("getmempoolfeeratediagram", [])
170134
if not raw_points:

0 commit comments

Comments
 (0)