Add live network totals for nodes, users, published media, and posts, including local-node counts and media-count federation support.
Hop-State: A_06FPDCRHF0BSN8BDYYXW3ER Hop-Proposal: R_06FPDCQJTBM7EZK7BXFA8D0 Hop-Task: T_06FPD59337GBJTP7D756FEG Hop-Attempt: AT_06FPD59337493XRD47TM0H0
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { aggregateSwarmStats } from './registry';
|
||||
|
||||
describe('aggregateSwarmStats', () => {
|
||||
it('includes the local node and totals active peer statistics', () => {
|
||||
const result = aggregateSwarmStats([
|
||||
{ isActive: true, userCount: 3, postCount: 24, mediaCount: 7 },
|
||||
{ isActive: true, userCount: 2, postCount: 8, mediaCount: null },
|
||||
{ isActive: false, userCount: 50, postCount: 500, mediaCount: 100 },
|
||||
], {
|
||||
users: 4,
|
||||
posts: 12,
|
||||
media: 5,
|
||||
}, true);
|
||||
|
||||
expect(result).toEqual({
|
||||
totalNodes: 4,
|
||||
activeNodes: 2,
|
||||
totalUsers: 9,
|
||||
totalPosts: 44,
|
||||
totalMedia: 12,
|
||||
});
|
||||
});
|
||||
|
||||
it('excludes local counts when the node is not publicly participating', () => {
|
||||
const result = aggregateSwarmStats([
|
||||
{ isActive: true, userCount: 3, postCount: 24, mediaCount: 7 },
|
||||
], {
|
||||
users: 100,
|
||||
posts: 200,
|
||||
media: 300,
|
||||
}, false);
|
||||
|
||||
expect(result).toEqual({
|
||||
totalNodes: 1,
|
||||
activeNodes: 1,
|
||||
totalUsers: 3,
|
||||
totalPosts: 24,
|
||||
totalMedia: 7,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user