mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-05-19 22:34:46 -07:00
global: fixes
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
"""GET /api/v1/fees/mempool-blocks"""
|
||||
|
||||
from _lib import assert_same_structure, show
|
||||
|
||||
|
||||
def test_fees_mempool_blocks(brk, mempool):
|
||||
"""Projected mempool blocks must have the same element structure."""
|
||||
path = "/api/v1/fees/mempool-blocks"
|
||||
b = brk.get_json(path)
|
||||
m = mempool.get_json(path)
|
||||
show("GET", path, f"({len(b)} blocks)", f"({len(m)} blocks)")
|
||||
assert isinstance(b, list) and isinstance(m, list)
|
||||
assert len(b) > 0
|
||||
if b and m:
|
||||
assert_same_structure(b[0], m[0])
|
||||
|
||||
|
||||
def test_fees_mempool_blocks_fee_range(brk, mempool):
|
||||
"""Each projected block must have a 7-element feeRange."""
|
||||
path = "/api/v1/fees/mempool-blocks"
|
||||
for label, client in [("brk", brk), ("mempool", mempool)]:
|
||||
blocks = client.get_json(path)
|
||||
for i, block in enumerate(blocks[:3]):
|
||||
assert "feeRange" in block, f"{label} block {i} missing feeRange"
|
||||
assert len(block["feeRange"]) == 7, (
|
||||
f"{label} block {i} feeRange has {len(block['feeRange'])} items, expected 7"
|
||||
)
|
||||
@@ -0,0 +1,42 @@
|
||||
"""GET /api/v1/fees/precise"""
|
||||
|
||||
from _lib import assert_same_structure, show
|
||||
|
||||
|
||||
EXPECTED_FEE_KEYS = [
|
||||
"fastestFee", "halfHourFee", "hourFee", "economyFee", "minimumFee",
|
||||
]
|
||||
|
||||
|
||||
def test_fees_precise_structure(brk, mempool):
|
||||
"""Precise fees must have the same structure as recommended."""
|
||||
path = "/api/v1/fees/precise"
|
||||
b = brk.get_json(path)
|
||||
m = mempool.get_json(path)
|
||||
show("GET", path, b, m)
|
||||
assert_same_structure(b, m)
|
||||
for key in EXPECTED_FEE_KEYS:
|
||||
assert key in b
|
||||
|
||||
|
||||
def test_fees_precise_ordering(brk, mempool):
|
||||
"""Precise fee tiers must be ordered: fastest >= halfHour >= hour >= economy >= minimum."""
|
||||
path = "/api/v1/fees/precise"
|
||||
for label, client in [("brk", brk), ("mempool", mempool)]:
|
||||
d = client.get_json(path)
|
||||
assert d["fastestFee"] >= d["halfHourFee"] >= d["hourFee"], (
|
||||
f"{label}: precise fee ordering violated {d}"
|
||||
)
|
||||
assert d["hourFee"] >= d["economyFee"] >= d["minimumFee"], (
|
||||
f"{label}: precise fee ordering violated {d}"
|
||||
)
|
||||
|
||||
|
||||
def test_fees_precise_numeric(brk):
|
||||
"""Each tier in /precise must be a non-negative number."""
|
||||
d = brk.get_json("/api/v1/fees/precise")
|
||||
show("GET", "/api/v1/fees/precise", d, "—")
|
||||
for key in EXPECTED_FEE_KEYS:
|
||||
v = d[key]
|
||||
assert isinstance(v, (int, float)), f"{key} not numeric: {type(v).__name__}"
|
||||
assert v >= 0, f"{key} is negative: {v}"
|
||||
@@ -0,0 +1,33 @@
|
||||
"""GET /api/v1/fees/recommended"""
|
||||
|
||||
from _lib import assert_same_structure, show
|
||||
|
||||
|
||||
EXPECTED_FEE_KEYS = [
|
||||
"fastestFee", "halfHourFee", "hourFee", "economyFee", "minimumFee",
|
||||
]
|
||||
|
||||
|
||||
def test_fees_recommended(brk, mempool):
|
||||
"""Recommended fees must have the same keys and numeric types."""
|
||||
path = "/api/v1/fees/recommended"
|
||||
b = brk.get_json(path)
|
||||
m = mempool.get_json(path)
|
||||
show("GET", path, b, m)
|
||||
assert_same_structure(b, m)
|
||||
for key in EXPECTED_FEE_KEYS:
|
||||
assert key in b, f"brk missing '{key}'"
|
||||
assert isinstance(b[key], (int, float)), f"'{key}' is not numeric: {type(b[key])}"
|
||||
|
||||
|
||||
def test_fees_recommended_ordering(brk, mempool):
|
||||
"""Fee tiers must be ordered: fastest >= halfHour >= hour >= economy >= minimum."""
|
||||
path = "/api/v1/fees/recommended"
|
||||
for label, client in [("brk", brk), ("mempool", mempool)]:
|
||||
d = client.get_json(path)
|
||||
assert d["fastestFee"] >= d["halfHourFee"] >= d["hourFee"], (
|
||||
f"{label}: fee ordering violated {d}"
|
||||
)
|
||||
assert d["hourFee"] >= d["economyFee"] >= d["minimumFee"], (
|
||||
f"{label}: fee ordering violated {d}"
|
||||
)
|
||||
Reference in New Issue
Block a user