Skip to content

Commit

Permalink
fix validate logic
Browse files Browse the repository at this point in the history
  • Loading branch information
apexearth committed Dec 19, 2024
1 parent 49c292f commit ec191d2
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/validation/validate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import assert from 'assert'
import { compact } from 'lodash'

import { Block, Context } from '@processor'
import { Entity, EntityClass } from '@subsquid/typeorm-store/lib/store'
Expand All @@ -19,16 +18,14 @@ export const validateBlocks = async (
) => {
let firstBlock = true
if (env.BLOCK_FROM || env.PROCESSOR) return
let promises: Promise<void>[] = []
for (const block of ctx.blocks) {
const validations = []
for (const { entity, expectations } of expectationSets) {
validations.push(validateExpectations(ctx, block, entity, firstBlock, expectations))
firstBlock = false
}
promises.push(...compact(validations))
await Promise.all(
expectationSets.map(({ entity, expectations }) =>
validateExpectations(ctx, block, entity, firstBlock, expectations),
),
)
firstBlock = false
}
await Promise.all(promises)
}

// If there is nothing to validate, we don't return a promise. (for performance)
Expand Down

0 comments on commit ec191d2

Please sign in to comment.