Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
name: Tests

on:
push:
branches: [ "main", "feature/*" ]
pull_request:
branches: [ "main", "feature/*" ]

jobs:
backend-tests:
runs-on: ubuntu-latest
Expand All @@ -24,9 +19,11 @@ jobs:
pip install -r requirements.txt
pip install pytest pytest-mock
- name: Run tests
run: |
pytest tests/

run: pytest tests/
env:
RPC_URL: http://localhost:8332
RPC_USER: test
RPC_PASSWORD: test
frontend-tests:
runs-on: ubuntu-latest
defaults:
Expand Down
1 change: 0 additions & 1 deletion backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ test_secure_connection.py
test_rpc_ports.py
test_getbestblockhash.py

rpc_config.ini

36 changes: 0 additions & 36 deletions backend/src/services/rpc_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,51 +120,15 @@ def get_single_block_stats(height: int) -> Dict[str, Any]:
def get_block_count() -> int:
return _rpc_call("getblockcount", [])


def get_mempool_health_statistics() -> List[Dict[str, Any]]:
"""
Fetches stats for the last 5 blocks to compare their weights with
the current mempool's readiness.
"""
current_height = get_block_count()
stats = []

# Using getmempoolfeeratediagram for accurate total weight
mempool_diagram = _rpc_call("getmempoolfeeratediagram", [])
total_mempool_weight = mempool_diagram[-1]["weight"] if mempool_diagram else 0

for h in range(current_height - 4, current_height + 1):
try:
b = get_single_block_stats(h)
weight = b.get("total_weight", 0)

stats.append({
"block_height": h,
"block_weight": weight,
"mempool_txs_weight": total_mempool_weight,
"ratio": min(1.0, total_mempool_weight / 4_000_000)
})
except Exception:
continue
return stats


def estimate_smart_fee(conf_target: int, mode: str = "unset", verbosity_level: int = 2) -> Dict[str, Any]:
effective_target = _clamp_target(conf_target)
result = _rpc_call("estimatesmartfee", [effective_target, mode, verbosity_level])
if result and "feerate" in result:
# feerate is BTC/kVB → sat/vB: × 1e8 (BTC→sat) ÷ 1e3 (kVB→vB) = × 1e5
result["feerate_sat_per_vb"] = result["feerate"] * 100_000

# Include health stats for the frontend
try:
result["mempool_health_statistics"] = get_mempool_health_statistics()
except Exception as e:
logger.error(f"Failed to include health stats: {e}")

return result


def get_mempool_feerate_diagram_analysis() -> Dict[str, Any]:
raw_points = _rpc_call("getmempoolfeeratediagram", [])
if not raw_points:
Expand Down
Loading