forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.test.ts
More file actions
26 lines (23 loc) · 886 Bytes
/
Copy pathanalytics.test.ts
File metadata and controls
26 lines (23 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Tests for analytics engine
import { cacheMetrics, getCachedMetrics } from './analytics.cache';
import { aggregateMetrics, getAggregatedMetrics } from './analytics.aggregate';
import { PlatformMetrics } from './analytics.metrics';
describe('Analytics Engine', () => {
const sampleMetric: PlatformMetrics = {
splitsPerSecond: 10,
activeUsers: 100,
paymentSuccessRate: 0.98,
averageSettlementTime: 2.5,
geographicDistribution: { US: 50, UK: 30, IN: 20 },
};
it('should cache metrics in Redis', async () => {
await cacheMetrics(sampleMetric);
const cached = await getCachedMetrics();
expect(cached).toEqual(sampleMetric);
});
it('should aggregate metrics in ClickHouse', async () => {
await aggregateMetrics(sampleMetric);
const aggregated = await getAggregatedMetrics();
expect(aggregated).toMatchObject(sampleMetric);
});
});