• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

decentraland / content-validator / 19470418811

18 Nov 2025 02:53PM UTC coverage: 81.689% (+1.6%) from 80.046%
19470418811

push

github

web-flow
break: Deprecate profile snapshots and content files (#336)

365 of 488 branches covered (74.8%)

Branch coverage included in aggregate %.

99 of 99 new or added lines in 4 files covered. (100.0%)

1 existing line in 1 file now uncovered.

1076 of 1276 relevant lines covered (84.33%)

8.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.18
/src/validations/content.ts
1
import { ContentValidatorComponents, DeploymentToValidate, fromErrors, ValidateFn, ValidationResponse } from '../types'
5✔
2
import { validateAll } from './validations'
5✔
3

4
/**
5
 * Validates that all hashes that belong to the entity's content are actually uploaded or stored.
6
 * If no content is present, this validation will not produce an error.
7
 * @public
8
 */
9
export function createAllHashesWereUploadedOrStoredValidateFn({
5✔
10
  externalCalls
11
}: Pick<ContentValidatorComponents, 'externalCalls'>): ValidateFn {
12
  return async function validateFn(deployment: DeploymentToValidate): Promise<ValidationResponse> {
9✔
13
    const { entity, files } = deployment
7✔
14
    const errors: string[] = []
7✔
15
    if (entity.content) {
7✔
16
      const alreadyStoredHashes = await externalCalls.isContentStoredAlready(
7✔
17
        entity.content?.map((file) => file.hash) ?? []
13!
18
      )
19

20
      for (const { hash } of entity.content) {
7✔
21
        // Validate that all hashes in entity were uploaded, or were already stored on the service
22
        if (!(files.has(hash) || alreadyStoredHashes.get(hash))) {
13✔
23
          errors.push(`This hash is referenced in the entity but was not uploaded or previously available: ${hash}`)
4✔
24
        }
25
      }
26
    }
27
    return fromErrors(...errors)
7✔
28
  }
29
}
30

31
/**
32
 * Validates that all hashes that belong to uploaded files are actually reported on the entity
33
 * by checking that the entity's content hashes are correspond to the uploaded files.
34
 * @public
35
 */
36
export async function allHashesInUploadedFilesAreReportedInTheEntityValidateFn(deployment: DeploymentToValidate) {
5✔
37
  const { entity, files } = deployment
5✔
38
  const errors: string[] = []
5✔
39
  // Validate that all hashes that belong to uploaded files are actually reported on the entity
40
  const entityHashes = new Set(entity.content?.map(({ hash }) => hash) ?? [])
5!
41
  for (const [hash] of files) {
5✔
42
    if (!entityHashes.has(hash) && hash !== entity.id) {
6✔
43
      errors.push(`This hash was uploaded but is not referenced in the entity: ${hash}`)
2✔
44
    }
45
  }
46
  return fromErrors(...errors)
5✔
47
}
48

49
/**
50
 * Validate that uploaded and reported hashes are corrects and files corresponds to snapshots
51
 * @public
52
 */
53
export function createContentValidateFn(components: ContentValidatorComponents): ValidateFn {
5✔
UNCOV
54
  return validateAll(
×
55
    createAllHashesWereUploadedOrStoredValidateFn(components),
56
    allHashesInUploadedFilesAreReportedInTheEntityValidateFn
57
  )
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc