1
1
import { type ContractArtifact } from '@aztec/foundation/abi' ;
2
2
3
3
import { computeArtifactHash } from './artifact_hash.js' ;
4
- import { getTestContractArtifact } from '../tests/fixtures.js' ;
4
+ import { getPathToFixture , getTestContractArtifact } from '../tests/fixtures.js' ;
5
+ import { loadContractArtifact } from '@aztec/types/abi' ;
6
+ import type { NoirCompiledContract } from '@aztec/types/noir' ;
7
+ import { readFileSync } from 'fs' ;
5
8
6
9
describe ( 'ArtifactHash' , ( ) => {
7
10
it ( 'calculates the artifact hash' , ( ) => {
@@ -17,7 +20,7 @@ describe('ArtifactHash', () => {
17
20
notes : { } ,
18
21
} ;
19
22
expect ( computeArtifactHash ( emptyArtifact ) . toString ( ) ) . toMatchInlineSnapshot (
20
- `"0x0c6fd9b48570721c5d36f978d084d77cacbfd2814f1344985f40e62bea6e61be "` ,
23
+ `"0x0dea64e7fa0688017f77bcb7075485485afb4a5f1f8508483398869439f82fdf "` ,
21
24
) ;
22
25
} ) ;
23
26
@@ -26,8 +29,20 @@ describe('ArtifactHash', () => {
26
29
27
30
for ( let i = 0 ; i < 1000 ; i ++ ) {
28
31
expect ( computeArtifactHash ( testArtifact ) . toString ( ) ) . toMatchInlineSnapshot (
29
- `"0x193c8f0e49d2a1b865f8afec829f3cf0bc136232ce7d09f823192dcc3e876df2 "` ,
32
+ `"0x0daa596e37c780de679311a601bd8b371c40d5a6898f452a06180bfef69e7df8 "` ,
30
33
) ;
31
34
}
32
35
} ) ;
36
+
37
+ it ( 'calculates the test contract artifact hash' , ( ) => {
38
+ const path = getPathToFixture ( 'Test.test.json' ) ;
39
+ const content = JSON . parse ( readFileSync ( path ) . toString ( ) ) as NoirCompiledContract ;
40
+ content . outputs . structs . functions . reverse ( ) ;
41
+
42
+ const testArtifact = loadContractArtifact ( content ) ;
43
+
44
+ expect ( computeArtifactHash ( testArtifact ) . toString ( ) ) . toMatchInlineSnapshot (
45
+ `"0x0daa596e37c780de679311a601bd8b371c40d5a6898f452a06180bfef69e7df8"` ,
46
+ ) ;
47
+ } ) ;
33
48
} ) ;
0 commit comments