Skip to content

Commit 5de8dd8

Browse files
committed
feat: move mocks to own file
1 parent 1694d14 commit 5de8dd8

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

src/ports/job/mocks.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Network } from '@dcl/schemas'
2+
import { Squid } from '../squids/types'
3+
4+
// MOCK DATA to test locally
5+
export const MOCK_SQUIDS: Squid[] = [
6+
{
7+
name: 'mock-marketplace-squid',
8+
service_name: 'mock-marketplace-squid-server',
9+
schema_name: 'squid_marketplace',
10+
project_active_schema: 'squid_marketplace',
11+
version: 1,
12+
created_at: new Date(),
13+
health_status: 'HEALTHY',
14+
service_status: 'RUNNING',
15+
metrics: {
16+
[Network.ETHEREUM]: {
17+
sqd_processor_sync_eta_seconds: 30, // Intentionally out of sync for testing
18+
sqd_processor_mapping_blocks_per_second: 5.2,
19+
sqd_processor_last_block: 18500000,
20+
sqd_processor_chain_height: 18500100
21+
},
22+
[Network.MATIC]: {
23+
// Note: In real data, this value might be null or undefined even though
24+
// the type definition doesn't allow it. Our code handles this case.
25+
sqd_processor_sync_eta_seconds: 0, // We'll use 0 for the mock but the code will still check for null
26+
sqd_processor_mapping_blocks_per_second: 10.5,
27+
sqd_processor_last_block: 45600000,
28+
sqd_processor_chain_height: 45600200
29+
}
30+
}
31+
}
32+
]

src/ports/job/squid-monitor.ts

+1-30
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AppComponents } from '../../types'
33
import { SlackMessage } from '../slack/component'
44
import { Squid } from '../squids/types'
55
import { createJobComponent } from './component'
6+
import { MOCK_SQUIDS } from './mocks'
67
import { IJobComponent } from './types'
78

89
const ONE_MINUTE = 60 * 1000
@@ -13,36 +14,6 @@ const IS_PRODUCTION = process.env.NODE_ENV === 'production'
1314
const ENV_PREFIX = IS_PRODUCTION ? '[PRD]' : '[DEV]'
1415
const BASE_URL = IS_PRODUCTION ? 'https://decentraland.org/squid-management-ui' : 'https://decentraland.zone/squid-management-ui'
1516

16-
const MOCK_SQUIDS: Squid[] = [
17-
{
18-
name: 'mock-marketplace-squid',
19-
service_name: 'mock-marketplace-squid-server',
20-
schema_name: 'squid_marketplace',
21-
project_active_schema: 'squid_marketplace',
22-
version: 1,
23-
created_at: new Date(),
24-
health_status: 'HEALTHY',
25-
service_status: 'RUNNING',
26-
metrics: {
27-
[Network.ETHEREUM]: {
28-
sqd_processor_sync_eta_seconds: 30, // Intentionally out of sync for testing
29-
sqd_processor_mapping_blocks_per_second: 5.2,
30-
sqd_processor_last_block: 18500000,
31-
sqd_processor_chain_height: 18500100
32-
},
33-
[Network.MATIC]: {
34-
// Note: In real data, this value might be null or undefined even though
35-
// the type definition doesn't allow it. Our code handles this case.
36-
sqd_processor_sync_eta_seconds: 0, // We'll use 0 for the mock but the code will still check for null
37-
sqd_processor_mapping_blocks_per_second: 10.5,
38-
sqd_processor_last_block: 45600000,
39-
sqd_processor_chain_height: 45600200
40-
}
41-
}
42-
}
43-
]
44-
// END OF MOCK - REMOVE BEFORE PUSHING TO PRODUCTION
45-
4617
export async function createSquidMonitorJob(
4718
components: Pick<AppComponents, 'logs' | 'squids' | 'config' | 'slack'>
4819
): Promise<IJobComponent> {

0 commit comments

Comments
 (0)