From 6fe09352584565d5720f32a75d138d80dd4dd48e Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 1 Aug 2023 12:37:57 +0000 Subject: [PATCH] chore: more bad selectors in tests --- yarn-project/acir-simulator/src/public/index.test.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/yarn-project/acir-simulator/src/public/index.test.ts b/yarn-project/acir-simulator/src/public/index.test.ts index a4fff4d32ab..a1ebf9020ec 100644 --- a/yarn-project/acir-simulator/src/public/index.test.ts +++ b/yarn-project/acir-simulator/src/public/index.test.ts @@ -7,9 +7,8 @@ import { PrivateHistoricTreeRoots, } from '@aztec/circuits.js'; import { pedersenPlookupCommitInputs } from '@aztec/circuits.js/barretenberg'; -import { FunctionAbi, encodeArguments } from '@aztec/foundation/abi'; +import { FunctionAbi, encodeArguments, generateFunctionSelector } from '@aztec/foundation/abi'; import { AztecAddress } from '@aztec/foundation/aztec-address'; -import { keccak } from '@aztec/foundation/crypto'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { toBigInt } from '@aztec/foundation/serialize'; @@ -63,7 +62,7 @@ describe('ACIR public execution simulator', () => { it('should run the mint function', async () => { const contractAddress = AztecAddress.random(); const mintAbi = PublicTokenContractAbi.functions.find(f => f.name === 'mint')!; - const functionData = new FunctionData(Buffer.alloc(4), false, false, false); + const functionData = FunctionData.fromAbi(mintAbi); const args = encodeArguments(mintAbi, [140, recipient]); const callContext = CallContext.from({ @@ -190,11 +189,14 @@ describe('ACIR public execution simulator', () => { it('calls the public entry point in the parent', async () => { const parentContractAddress = AztecAddress.random(); const parentEntryPointFn = ParentContractAbi.functions.find(f => f.name === 'pubEntryPoint')!; - const parentEntryPointFnSelector = keccak(Buffer.from(parentEntryPointFn.name)).subarray(0, 4); + const parentEntryPointFnSelector = generateFunctionSelector( + parentEntryPointFn.name, + parentEntryPointFn.parameters, + ); const childContractAddress = AztecAddress.random(); const childValueFn = ChildContractAbi.functions.find(f => f.name === 'pubValue')!; - const childValueFnSelector = keccak(Buffer.from(childValueFn.name)).subarray(0, 4); + const childValueFnSelector = generateFunctionSelector(childValueFn.name, childValueFn.parameters); const initialValue = 3n;