Skip to content

Commit

Permalink
chore: check artifact consistency (#10271)
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind authored Nov 28, 2024
1 parent bfd9fa6 commit 6a49405
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions yarn-project/circuits.js/src/contract/artifact_hash.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { type ContractArtifact } from '@aztec/foundation/abi';
import { loadContractArtifact } from '@aztec/types/abi';
import type { NoirCompiledContract } from '@aztec/types/noir';

import { readFileSync } from 'fs';

import { getPathToFixture, getTestContractArtifact } from '../tests/fixtures.js';
import { getTestContractArtifact } from '../tests/fixtures.js';
import { computeArtifactHash } from './artifact_hash.js';

const TEST_CONTRACT_ARTIFACT_HASH = `"0x19142676527045a118066698e292cc35db16ab4d7bd16610d35d2e1c607eb8b2"`;

describe('ArtifactHash', () => {
it('calculates the artifact hash', () => {
const emptyArtifact: ContractArtifact = {
Expand All @@ -31,19 +25,8 @@ describe('ArtifactHash', () => {
const testArtifact = getTestContractArtifact();

const calculatedArtifactHash = computeArtifactHash(testArtifact).toString();
expect(calculatedArtifactHash).toMatchInlineSnapshot(TEST_CONTRACT_ARTIFACT_HASH);
for (let i = 0; i < 1000; i++) {
expect(computeArtifactHash(testArtifact).toString()).toBe(calculatedArtifactHash);
}
});

it('calculates the test contract artifact hash', () => {
const path = getPathToFixture('Test.test.json');
const content = JSON.parse(readFileSync(path).toString()) as NoirCompiledContract;
content.outputs.structs.functions.reverse();

const testArtifact = loadContractArtifact(content);

expect(computeArtifactHash(testArtifact).toString()).toMatchInlineSnapshot(TEST_CONTRACT_ARTIFACT_HASH);
});
});

0 comments on commit 6a49405

Please sign in to comment.