Open History to see the last commit
1import { expect } from 'vitest'
2import { hash } from '../src/hashing/hash'
3
4// Shared by the hash law oracle and its ordinary tests. The law that
5// expectEqualHashes asserts is owned by hash-oracle.property.test.ts.
6export type HashValue = (value: unknown) => number
7
8export function expectEqualHashes(
9 value: unknown,
10 equivalent: unknown,
11 hashValue: HashValue = hash,
12): void {
13 expect(hashValue(value)).toBe(hashValue(equivalent))
14}
15
16export function expectFailureCut(
17 error: unknown,
18 reads: Array<number>,
19 expectedError: Error,
20 expectedReads: Array<number>,
21): void {
22 expect(error).toBe(expectedError)
23 expect(reads).toEqual(expectedReads)
24}