Skip to content

Commit

Permalink
test: testing toFields length
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Feb 1, 2024
1 parent c34603a commit 6394d46
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CONTRACT_DEPLOYMENT_DATA_LENGTH } from '../constants.gen.js';
import { makeContractDeploymentData } from '../tests/factories.js';
import { ContractDeploymentData } from './contract_deployment_data.js';


describe('ContractDeploymentData', () => {
it(`serializes to buffer and deserializes it back`, () => {
const expected = makeContractDeploymentData(1);
Expand All @@ -14,4 +16,10 @@ describe('ContractDeploymentData', () => {
const target = ContractDeploymentData.empty();
expect(target.isEmpty()).toBe(true);
});
});

it('number of fields matches constant', () => {
const target = makeContractDeploymentData(327);
const fields = target.toFields();
expect(fields.length).toBe(CONTRACT_DEPLOYMENT_DATA_LENGTH);
});
});
17 changes: 14 additions & 3 deletions yarn-project/circuits.js/src/structs/function_data.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import { FunctionSelector } from '@aztec/foundation/abi';

import { FUNCTION_DATA_LENGTH } from '../constants.gen.js';
import { FunctionData } from './function_data.js';

describe('FunctionData', () => {
let functionData: FunctionData;

beforeAll(() => {
functionData = new FunctionData(new FunctionSelector(123), false, true, true);
});

it(`serializes to buffer and deserializes it back`, () => {
const expected = new FunctionData(new FunctionSelector(123), false, true, true);
const buffer = expected.toBuffer();
const buffer = functionData.toBuffer();
const res = FunctionData.fromBuffer(buffer);
expect(res).toEqual(expected);
expect(res).toEqual(functionData);
expect(res.isEmpty()).toBe(false);
});

it('number of fields matches constant', () => {
const fields = functionData.toFields();
expect(fields.length).toBe(FUNCTION_DATA_LENGTH);
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH } from '../constants.gen.js';
import { makePublicCircuitPublicInputs } from '../tests/factories.js';
import { PublicCircuitPublicInputs } from './public_circuit_public_inputs.js';

Expand All @@ -15,4 +16,10 @@ describe('PublicCircuitPublicInputs', () => {
const target = PublicCircuitPublicInputs.empty();
expect(target.isEmpty()).toBe(true);
});

it("number of fields matches constant", () => {
const target = makePublicCircuitPublicInputs(327);
const fields = target.toFields();
expect(fields.length).toBe(PUBLIC_CIRCUIT_PUBLIC_INPUTS_LENGTH);
});
});

0 comments on commit 6394d46

Please sign in to comment.