mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
global: snapshot
This commit is contained in:
@@ -40,6 +40,12 @@ function getAllMetrics(obj, path = "") {
|
||||
return metrics;
|
||||
}
|
||||
|
||||
// Endpoints with sparse data (holes at the end) - skip these
|
||||
const SKIP_ENDPOINTS = new Set([
|
||||
"distribution.addressesData.empty.by.emptyaddressindex",
|
||||
"distribution.addressesData.loaded.by.loadedaddressindex",
|
||||
]);
|
||||
|
||||
async function testAllEndpoints() {
|
||||
const client = new BrkClient({ baseUrl: "http://localhost:3110", timeout: 15000 });
|
||||
|
||||
@@ -47,24 +53,31 @@ async function testAllEndpoints() {
|
||||
console.log(`\nFound ${metrics.length} metrics`);
|
||||
|
||||
let success = 0;
|
||||
let skipped = 0;
|
||||
|
||||
for (const { path, metric, indexes } of metrics) {
|
||||
for (const idxName of indexes) {
|
||||
const fullPath = `${path}.by.${idxName}`;
|
||||
if (SKIP_ENDPOINTS.has(fullPath)) {
|
||||
skipped++;
|
||||
console.log(`SKIP: ${fullPath} -> sparse data`);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const endpoint = metric.by[idxName];
|
||||
const res = await endpoint.last(1);
|
||||
const count = res.data.length;
|
||||
if (count !== 1) {
|
||||
console.log(
|
||||
`FAIL: ${path}.by.${idxName} -> expected 1, got ${count}`,
|
||||
`FAIL: ${fullPath} -> expected 1, got ${count}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
success++;
|
||||
console.log(`OK: ${path}.by.${idxName} -> ${count} items`);
|
||||
console.log(`OK: ${fullPath} -> ${count} items`);
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`FAIL: ${path}.by.${idxName} -> ${e instanceof Error ? e.message : e}`,
|
||||
`FAIL: ${fullPath} -> ${e instanceof Error ? e.message : e}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -73,6 +86,7 @@ async function testAllEndpoints() {
|
||||
|
||||
console.log(`\n=== Results ===`);
|
||||
console.log(`Success: ${success}`);
|
||||
console.log(`Skipped: ${skipped}`);
|
||||
}
|
||||
|
||||
testAllEndpoints();
|
||||
|
||||
Reference in New Issue
Block a user