Skip to content

Commit

Permalink
fix moar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant committed Feb 4, 2025
1 parent 0f0da77 commit 1b384c8
Show file tree
Hide file tree
Showing 7 changed files with 1,339 additions and 1,169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ export function describeArchiverDataStore(
const blockNum = 10;

beforeEach(async () => {
const randomInstance = await SerializableContractInstance.random();
const classId = Fr.random();
const randomInstance = await SerializableContractInstance.random({
currentContractClassId: classId,
originalContractClassId: classId,
});
contractInstance = { ...randomInstance, address: await AztecAddress.random() };
await store.addContractInstances([contractInstance], blockNum);
});
Expand Down
12 changes: 8 additions & 4 deletions yarn-project/circuit-types/src/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,14 @@ export const randomContractInstanceWithAddress = async (
opts: { contractClassId?: Fr } = {},
address?: AztecAddress,
): Promise<ContractInstanceWithAddress> => {
const instance = await SerializableContractInstance.random({
currentContractClassId: opts.contractClassId,
originalContractClassId: opts.contractClassId,
});
const instance = await SerializableContractInstance.random(
opts.contractClassId
? {
currentContractClassId: opts.contractClassId,
originalContractClassId: opts.contractClassId,
}
: undefined,
);
return instance.withAddress(address ?? (await computeContractAddressFromInstance(instance)));
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export class ScheduledDelayChange {

toField(): Fr {
// high bits [ pre_is_some: u1 | post_is_some: u1 | block_of_change: u32 | pre_inner: u32 | post_inner: u32 ] low bits
let result = this.post || 0;
result |= (this.previous || 0) << 32;
result |= this.blockOfChange << 64;
result |= this.post === undefined ? 0 : 1 << 96;
result |= this.previous === undefined ? 0 : 1 << 97;
let result = BigInt(this.post || 0);
result |= BigInt(this.previous || 0) << 32n;
result |= BigInt(this.blockOfChange) << 64n;
result |= this.post === undefined ? 0n : 1n << 96n;
result |= this.previous === undefined ? 0n : 1n << 97n;
return new Fr(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
computeTaggingSecretPoint,
deriveKeys,
} from '@aztec/circuits.js';
import { type FunctionArtifact, FunctionType } from '@aztec/foundation/abi';
import { type FunctionArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi';
import { timesParallel } from '@aztec/foundation/collection';
import { pedersenHash, poseidon2Hash } from '@aztec/foundation/crypto';
import { KeyStore } from '@aztec/key-store';
Expand Down Expand Up @@ -655,7 +655,12 @@ describe('Simulator oracle', () => {

// We test that a call to `processLog` is made with the correct function artifact and contract address
expect(runUnconstrainedSpy).toHaveBeenCalledTimes(3);
expect(runUnconstrainedSpy).toHaveBeenCalledWith(expect.anything(), processLogFuncArtifact, contractAddress, []);
expect(runUnconstrainedSpy).toHaveBeenCalledWith(
expect.anything(),
contractAddress,
await FunctionSelector.fromNameAndParameters(processLogFuncArtifact.name, processLogFuncArtifact.parameters),
[],
);
}, 30_000);

it('should not store notes that do not belong to us', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ describe('PhasesTxValidator', () => {
contractDataSource = mock<ContractDataSource>({
getContract: mockFn().mockImplementation(() => {
return {
contractClassId: Fr.random(),
currentContractClassId: Fr.random(),
originalContractClassId: Fr.random(),
};
}),
});
Expand Down Expand Up @@ -71,7 +72,8 @@ describe('PhasesTxValidator', () => {
contractDataSource.getContract.mockImplementationOnce(contractAddress => {
if (address.equals(contractAddress)) {
return Promise.resolve({
contractClassId: allowedContractClass,
currentContractClassId: allowedContractClass,
originalContractClassId: Fr.random(),
} as any);
} else {
return Promise.resolve(undefined);
Expand All @@ -94,7 +96,8 @@ describe('PhasesTxValidator', () => {
contractDataSource.getContract.mockImplementationOnce(contractAddress => {
if (address.equals(contractAddress)) {
return Promise.resolve({
contractClassId: Fr.random(),
currentContractClassId: Fr.random(),
originalContractClassId: Fr.random(),
} as any);
} else {
return Promise.resolve(undefined);
Expand Down
Loading

0 comments on commit 1b384c8

Please sign in to comment.