Skip to content

Commit 678507c

Browse files
authored
fixes tests and runs in ci (#46)
1 parent ff0b0c3 commit 678507c

File tree

2 files changed

+38
-53
lines changed

2 files changed

+38
-53
lines changed

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Run Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [18.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'yarn'
25+
26+
- name: Install dependencies
27+
run: yarn install --frozen-lockfile
28+
29+
- name: Run tests
30+
run: yarn test

packages/assertion-monitor/__test__/monitoring.test.ts

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ describe('Assertion Health Monitoring', () => {
121121
const alerts = await analyzeAssertionEvents(
122122
chainState,
123123
mockChainInfo,
124-
false,
125124
true
126125
)
127126

@@ -136,7 +135,6 @@ describe('Assertion Health Monitoring', () => {
136135
const alerts = await analyzeAssertionEvents(
137136
chainState,
138137
mockChainInfo,
139-
false,
140138
true
141139
)
142140

@@ -154,7 +152,6 @@ describe('Assertion Health Monitoring', () => {
154152
const alerts = await analyzeAssertionEvents(
155153
chainState,
156154
mockChainInfo,
157-
false,
158155
true
159156
)
160157

@@ -172,7 +169,6 @@ describe('Assertion Health Monitoring', () => {
172169
const alerts = await analyzeAssertionEvents(
173170
chainState,
174171
mockChainInfo,
175-
false,
176172
true
177173
)
178174

@@ -211,7 +207,6 @@ describe('Assertion Health Monitoring', () => {
211207
const alerts = await analyzeAssertionEvents(
212208
chainState,
213209
mockChainInfo,
214-
false,
215210
true
216211
)
217212

@@ -230,7 +225,6 @@ describe('Assertion Health Monitoring', () => {
230225
const alerts = await analyzeAssertionEvents(
231226
chainState,
232227
mockChainInfo,
233-
false,
234228
true
235229
)
236230

@@ -266,28 +260,28 @@ describe('Assertion Health Monitoring', () => {
266260
number: 100n, // 200 blocks behind, exceeds confirmPeriodBlocks(100) + VALIDATOR_AFK_BLOCKS(50)
267261
} as Block
268262

263+
chainState.isBaseStakeBelowThreshold = true
264+
chainState.isValidatorWhitelistDisabled = true
265+
269266
const alerts = await analyzeAssertionEvents(
270267
chainState,
271268
mockChainInfo,
272-
false,
273269
true
274270
)
275271

276272
// Check for expected alert
277273
expect(alerts).toContain(CONFIRMATION_DELAY_ALERT)
278274

279-
// Test with whitelist disabled
280275
const alertsWithWhitelistDisabled = await analyzeAssertionEvents(
281276
chainState,
282277
mockChainInfo,
283-
true,
284278
true
285279
)
286280

287281
// Should have both alerts
288282
expect(alertsWithWhitelistDisabled).toContain(CONFIRMATION_DELAY_ALERT)
289283
expect(alertsWithWhitelistDisabled).toContain(
290-
VALIDATOR_WHITELIST_DISABLED_ALERT
284+
BOLD_LOW_BASE_STAKE_ALERT
291285
)
292286
})
293287

@@ -326,7 +320,6 @@ describe('Assertion Health Monitoring', () => {
326320
const alerts = await analyzeAssertionEvents(
327321
chainState,
328322
mockChainInfo,
329-
false,
330323
true
331324
)
332325

@@ -338,35 +331,6 @@ describe('Assertion Health Monitoring', () => {
338331
expect(alerts).toContain(CONFIRMATION_DELAY_ALERT)
339332
})
340333

341-
test('should alert when validator whitelist is disabled', async () => {
342-
const chainState = createBaseChainState()
343-
344-
// Test with validator whitelist disabled
345-
const alerts = await analyzeAssertionEvents(
346-
chainState,
347-
mockChainInfo,
348-
true,
349-
true
350-
)
351-
352-
// Check if alerts array exists and has at least one element
353-
expect(alerts.length).toBeGreaterThan(0)
354-
355-
// Check for the validator whitelist disabled alert
356-
expect(alerts).toContain(VALIDATOR_WHITELIST_DISABLED_ALERT)
357-
358-
// Test with whitelist enabled to confirm no alert is generated
359-
const alertsWithWhitelist = await analyzeAssertionEvents(
360-
chainState,
361-
mockChainInfo,
362-
false,
363-
true
364-
)
365-
expect(alertsWithWhitelist).not.toContain(
366-
VALIDATOR_WHITELIST_DISABLED_ALERT
367-
)
368-
})
369-
370334
test('should use parent chain blocks for confirmation delay when available', async () => {
371335
const chainState = createBaseChainState()
372336

@@ -395,7 +359,6 @@ describe('Assertion Health Monitoring', () => {
395359
const alerts = await analyzeAssertionEvents(
396360
chainState,
397361
mockChainInfo,
398-
false,
399362
true
400363
)
401364

@@ -431,7 +394,6 @@ describe('Assertion Health Monitoring', () => {
431394
const alerts = await analyzeAssertionEvents(
432395
chainState,
433396
mockChainInfo,
434-
false,
435397
true
436398
)
437399

@@ -468,7 +430,6 @@ describe('Assertion Health Monitoring', () => {
468430
const alerts = await analyzeAssertionEvents(
469431
chainState,
470432
mockChainInfo,
471-
false,
472433
true
473434
)
474435

@@ -550,7 +511,6 @@ describe('Assertion Health Monitoring', () => {
550511
const alerts = await analyzeAssertionEvents(
551512
chainState,
552513
mockChainInfo,
553-
false,
554514
false
555515
)
556516

@@ -565,7 +525,6 @@ describe('Assertion Health Monitoring', () => {
565525
const alerts = await analyzeAssertionEvents(
566526
chainState,
567527
mockChainInfo,
568-
false,
569528
false
570529
)
571530

@@ -583,7 +542,6 @@ describe('Assertion Health Monitoring', () => {
583542
const alerts = await analyzeAssertionEvents(
584543
chainState,
585544
mockChainInfo,
586-
false,
587545
false
588546
)
589547

@@ -601,7 +559,6 @@ describe('Assertion Health Monitoring', () => {
601559
const alerts = await analyzeAssertionEvents(
602560
chainState,
603561
mockChainInfo,
604-
false,
605562
false
606563
)
607564

@@ -640,7 +597,6 @@ describe('Assertion Health Monitoring', () => {
640597
const alerts = await analyzeAssertionEvents(
641598
chainState,
642599
mockChainInfo,
643-
false,
644600
false // non-BOLD
645601
)
646602

@@ -659,7 +615,6 @@ describe('Assertion Health Monitoring', () => {
659615
const alerts = await analyzeAssertionEvents(
660616
chainState,
661617
mockChainInfo,
662-
false,
663618
false
664619
)
665620

@@ -704,7 +659,6 @@ describe('Assertion Health Monitoring', () => {
704659
const alerts = await analyzeAssertionEvents(
705660
chainState,
706661
mockChainInfo,
707-
false,
708662
false // non-BOLD
709663
)
710664

@@ -717,11 +671,12 @@ describe('Assertion Health Monitoring', () => {
717671
test('should alert when validator whitelist is disabled for non-BOLD chain', async () => {
718672
const chainState = createBaseChainState()
719673

674+
chainState.isValidatorWhitelistDisabled = true
675+
720676
// Test with validator whitelist disabled
721677
const alerts = await analyzeAssertionEvents(
722678
chainState,
723679
mockChainInfo,
724-
true,
725680
false
726681
)
727682

@@ -731,11 +686,12 @@ describe('Assertion Health Monitoring', () => {
731686
// Check for the validator whitelist disabled alert
732687
expect(alerts).toContain(VALIDATOR_WHITELIST_DISABLED_ALERT)
733688

689+
chainState.isValidatorWhitelistDisabled = false
690+
734691
// Test with whitelist enabled to confirm no alert is generated
735692
const alertsWithWhitelist = await analyzeAssertionEvents(
736693
chainState,
737694
mockChainInfo,
738-
false,
739695
false
740696
)
741697
expect(alertsWithWhitelist).not.toContain(
@@ -772,7 +728,6 @@ describe('Assertion Health Monitoring', () => {
772728
const alerts = await analyzeAssertionEvents(
773729
chainState,
774730
mockChainInfo,
775-
false,
776731
false // isBold = false for non-BOLD chain
777732
)
778733

0 commit comments

Comments
 (0)