-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
94 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { CALL_CONTEXT_LENGTH } from '../constants.gen.js'; | ||
import { makeCallContext } from '../tests/factories.js'; | ||
import { CallContext } from './call_context.js'; | ||
|
||
describe('CallContext', () => { | ||
let callContext: CallContext; | ||
|
||
beforeAll(() => { | ||
const randomInt = Math.floor(Math.random() * 1000); | ||
callContext = makeCallContext(randomInt); | ||
}); | ||
|
||
it(`serializes to buffer and deserializes it back`, () => { | ||
const buffer = callContext.toBuffer(); | ||
const res = CallContext.fromBuffer(buffer); | ||
expect(res).toEqual(callContext); | ||
expect(res.isEmpty()).toBe(false); | ||
}); | ||
|
||
it('number of fields matches constant', () => { | ||
const fields = callContext.toFields(); | ||
expect(fields.length).toBe(CALL_CONTEXT_LENGTH); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 17 additions & 9 deletions
26
yarn-project/circuits.js/src/structs/contract_storage_update_request.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
import { CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH } from '../constants.gen.js'; | ||
import { makeContractStorageUpdateRequest } from '../tests/factories.js'; | ||
import { ContractStorageUpdateRequest } from './contract_storage_update_request.js'; | ||
|
||
describe('ContractStorageUpdateRequest', () => { | ||
it('serializes to buffer and deserializes it back', () => { | ||
let request: ContractStorageUpdateRequest; | ||
|
||
beforeAll(() => { | ||
const randomInt = Math.floor(Math.random() * 1000); | ||
const expected = makeContractStorageUpdateRequest(randomInt); | ||
const buffer = expected.toBuffer(); | ||
request = makeContractStorageUpdateRequest(randomInt); | ||
}); | ||
|
||
it('serializes to buffer and deserializes it back', () => { | ||
const buffer = request.toBuffer(); | ||
const res = ContractStorageUpdateRequest.fromBuffer(buffer); | ||
expect(res).toEqual(expected); | ||
expect(res).toEqual(request); | ||
}); | ||
|
||
it('serializes to field array and deserializes it back', () => { | ||
const randomInt = Math.floor(Math.random() * 1000); | ||
const expected = makeContractStorageUpdateRequest(randomInt); | ||
|
||
const fieldArray = expected.toFields(); | ||
const fieldArray = request.toFields(); | ||
const res = ContractStorageUpdateRequest.fromFields(fieldArray); | ||
expect(res).toEqual(expected); | ||
expect(res).toEqual(request); | ||
}); | ||
|
||
it('number of fields matches constant', () => { | ||
const fields = request.toFields(); | ||
expect(fields.length).toBe(CONTRACT_STORAGE_UPDATE_REQUEST_LENGTH); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 17 additions & 6 deletions
23
yarn-project/circuits.js/src/structs/private_circuit_public_inputs.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,34 @@ | ||
import { PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH } from '../constants.gen.js'; | ||
import { makePrivateCircuitPublicInputs } from '../tests/factories.js'; | ||
import { PrivateCircuitPublicInputs } from './private_circuit_public_inputs.js'; | ||
|
||
describe('PrivateCircuitPublicInputs', () => { | ||
let inputs: PrivateCircuitPublicInputs; | ||
|
||
beforeAll(() => { | ||
const randomInt = Math.floor(Math.random() * 1000); | ||
inputs = makePrivateCircuitPublicInputs(randomInt); | ||
}); | ||
|
||
it('serializes to buffer and back', () => { | ||
const target = makePrivateCircuitPublicInputs(100); | ||
const buffer = target.toBuffer(); | ||
const buffer = inputs.toBuffer(); | ||
const result = PrivateCircuitPublicInputs.fromBuffer(buffer); | ||
expect(result).toEqual(target); | ||
expect(result).toEqual(inputs); | ||
}); | ||
|
||
it('serializes to fields and back', () => { | ||
const target = makePrivateCircuitPublicInputs(100); | ||
const fields = target.toFields(); | ||
const fields = inputs.toFields(); | ||
const result = PrivateCircuitPublicInputs.fromFields(fields); | ||
expect(result).toEqual(target); | ||
expect(result).toEqual(inputs); | ||
}); | ||
|
||
it(`initializes an empty PrivateCircuitPublicInputs`, () => { | ||
const target = PrivateCircuitPublicInputs.empty(); | ||
expect(target.isEmpty()).toBe(true); | ||
}); | ||
|
||
it('number of fields matches constant', () => { | ||
const fields = inputs.toFields(); | ||
expect(fields.length).toBe(PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters