Skip to content

Commit

Permalink
chore: dont import things that themselves import jest in imported fun…
Browse files Browse the repository at this point in the history
…ctions (#10260)
  • Loading branch information
dbanks12 authored Nov 27, 2024
1 parent 4ee8344 commit 9440c1c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions yarn-project/simulator/src/public/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type ContractClassPublic,
type ContractInstanceWithAddress,
DEFAULT_GAS_LIMIT,
type FunctionSelector,
FunctionSelector,
Gas,
GasFees,
GasSettings,
Expand All @@ -23,15 +23,16 @@ import {
computePublicBytecodeCommitment,
} from '@aztec/circuits.js';
import { makeContractClassPublic, makeContractInstanceFromClassId } from '@aztec/circuits.js/testing';
import { type ContractArtifact } from '@aztec/foundation/abi';
import { type ContractArtifact, type FunctionArtifact } from '@aztec/foundation/abi';
import { AztecAddress } from '@aztec/foundation/aztec-address';
import { Fr, Point } from '@aztec/foundation/fields';
import { openTmpStore } from '@aztec/kv-store/utils';
import { AvmTestContractArtifact } from '@aztec/noir-contracts.js';
import { PublicTxSimulator, WorldStateDB } from '@aztec/simulator';
import { NoopTelemetryClient } from '@aztec/telemetry-client/noop';
import { MerkleTrees } from '@aztec/world-state';

import { getAvmTestContractBytecode, getAvmTestContractFunctionSelector } from '../../avm/fixtures/index.js';
import { strict as assert } from 'assert';

/**
* If assertionErrString is set, we expect a (non exceptional halting) revert due to a failing assertion and
Expand Down Expand Up @@ -210,3 +211,24 @@ class MockedAvmTestContractDataSource {
return Promise.resolve();
}
}

function getAvmTestContractFunctionSelector(functionName: string): FunctionSelector {
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!;
assert(!!artifact, `Function ${functionName} not found in AvmTestContractArtifact`);
const params = artifact.parameters;
return FunctionSelector.fromNameAndParameters(artifact.name, params);
}

function getAvmTestContractArtifact(functionName: string): FunctionArtifact {
const artifact = AvmTestContractArtifact.functions.find(f => f.name === functionName)!;
assert(
!!artifact?.bytecode,
`No bytecode found for function ${functionName}. Try re-running bootstrap.sh on the repository root.`,
);
return artifact;
}

function getAvmTestContractBytecode(functionName: string): Buffer {
const artifact = getAvmTestContractArtifact(functionName);
return artifact.bytecode;
}

0 comments on commit 9440c1c

Please sign in to comment.