Skip to content

Commit

Permalink
nuking brittle test
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Oct 25, 2024
1 parent b6f3f95 commit 8ec29d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 93 deletions.
6 changes: 3 additions & 3 deletions yarn-project/simulator/src/client/private_execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
import { asyncMap } from '@aztec/foundation/async-map';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { times } from '@aztec/foundation/collection';
import { poseidon2HashWithSeparator, randomInt } from '@aztec/foundation/crypto';
import { poseidon2Hash, poseidon2HashWithSeparator, randomInt } from '@aztec/foundation/crypto';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
Expand All @@ -74,7 +74,6 @@ import { MessageLoadOracleInputs } from '../acvm/index.js';
import { buildL1ToL2Message } from '../test/utils.js';
import { type DBOracle } from './db_oracle.js';
import { AcirSimulator } from './simulator.js';
import { computeNoteHash } from './test_utils.js';

jest.setTimeout(60_000);

Expand Down Expand Up @@ -314,7 +313,8 @@ describe('Private Execution test suite', () => {
const noteHashIndex = randomInt(1); // mock index in TX's final noteHashes array
const nonce = computeNoteHashNonce(mockFirstNullifier, noteHashIndex);
const note = new Note([new Fr(amount), ownerNpkMHash, Fr.random()]);
const noteHash = computeNoteHash(storageSlot, note.items);
// Note: The following does not correspond to how note hashing is generally done in real notes.
const noteHash = poseidon2Hash([storageSlot, ...note.items]);
return {
contractAddress,
storageSlot,
Expand Down
34 changes: 1 addition & 33 deletions yarn-project/simulator/src/client/simulator.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { type AztecNode, CompleteAddress, Note } from '@aztec/circuit-types';
import { GeneratorIndex, KeyValidationRequest, computeAppNullifierSecretKey, deriveKeys } from '@aztec/circuits.js';
import { computeUniqueNoteHash, siloNoteHash } from '@aztec/circuits.js/hash';
import { KeyValidationRequest, computeAppNullifierSecretKey, deriveKeys } from '@aztec/circuits.js';
import { type FunctionArtifact, getFunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
import { Fr, type Point } from '@aztec/foundation/fields';
import { TokenBlacklistContractArtifact } from '@aztec/noir-contracts.js';

import { type MockProxy, mock } from 'jest-mock-extended';

import { type DBOracle } from './db_oracle.js';
import { AcirSimulator } from './simulator.js';
import { computeNoteHash } from './test_utils.js';

describe('Simulator', () => {
let oracle: MockProxy<DBOracle>;
Expand Down Expand Up @@ -59,35 +56,6 @@ describe('Simulator', () => {
const createNote = (amount = 123n) =>
new Note([new Fr(amount), new Fr(0), ownerMasterNullifierPublicKey.hash(), Fr.random()]);

it('should compute note hashes and nullifier', async () => {
oracle.getFunctionArtifactByName.mockResolvedValue(artifact);

const note = createNote();
const noteHash = computeNoteHash(storageSlot, note.items);
const uniqueNoteHash = computeUniqueNoteHash(nonce, noteHash);
const siloedNoteHash = siloNoteHash(contractAddress, uniqueNoteHash);
const innerNullifier = poseidon2HashWithSeparator(
[siloedNoteHash, appNullifierSecretKey],
GeneratorIndex.NOTE_NULLIFIER,
);

const result = await simulator.computeNoteHashAndOptionallyANullifier(
contractAddress,
nonce,
storageSlot,
noteTypeId,
true,
note,
);

expect(result).toEqual({
noteHash,
uniqueNoteHash,
siloedNoteHash,
innerNullifier,
});
});

it('throw if the contract does not implement "compute_note_hash_and_optionally_a_nullifier"', async () => {
oracle.getFunctionArtifactByName.mockResolvedValue(undefined);

Expand Down
57 changes: 0 additions & 57 deletions yarn-project/simulator/src/client/test_utils.ts

This file was deleted.

0 comments on commit 8ec29d8

Please sign in to comment.