-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add serialisation methods (#5749)
Adds `toString`/`toBuffer`/`fromString`/`fromBuffer` to a couple of classes that didn't have them. Also adds tests for the new functions. This is needed for future work on proving where proving requests could be sent over the network.
- Loading branch information
Showing
21 changed files
with
428 additions
and
31 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
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
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,18 @@ | ||
import { makeProof } from '../tests/factories.js'; | ||
import { Proof } from './proof.js'; | ||
|
||
describe('Proof', () => { | ||
it('serializes to buffer and deserializes it back', () => { | ||
const expected = makeProof(); | ||
const buffer = expected.toBuffer(); | ||
const res = Proof.fromBuffer(buffer); | ||
expect(res).toEqual(expected); | ||
}); | ||
|
||
it('serializes to hex string and deserializes it back', () => { | ||
const expected = makeProof(); | ||
const str = expected.toString(); | ||
const res = Proof.fromString(str); | ||
expect(res).toEqual(expected); | ||
}); | ||
}); |
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
18 changes: 18 additions & 0 deletions
18
yarn-project/circuits.js/src/structs/rollup/base_rollup.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { makeBaseRollupInputs } from '../../tests/factories.js'; | ||
import { BaseRollupInputs } from './base_rollup.js'; | ||
|
||
describe('BaseRollupInputs', () => { | ||
it('serializes to buffer and deserializes it back', () => { | ||
const expected = makeBaseRollupInputs(); | ||
const buffer = expected.toBuffer(); | ||
const res = BaseRollupInputs.fromBuffer(buffer); | ||
expect(res).toEqual(expected); | ||
}); | ||
|
||
it('serializes to hex string and deserializes it back', () => { | ||
const expected = makeBaseRollupInputs(); | ||
const str = expected.toString(); | ||
const res = BaseRollupInputs.fromString(str); | ||
expect(res).toEqual(expected); | ||
}); | ||
}); |
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
18 changes: 18 additions & 0 deletions
18
yarn-project/circuits.js/src/structs/rollup/merge_rollup.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { makeMergeRollupInputs } from '../../tests/factories.js'; | ||
import { MergeRollupInputs } from './merge_rollup.js'; | ||
|
||
describe('MergeRollupInputs', () => { | ||
it('serializes to buffer and deserializes it back', () => { | ||
const expected = makeMergeRollupInputs(); | ||
const buffer = expected.toBuffer(); | ||
const res = MergeRollupInputs.fromBuffer(buffer); | ||
expect(res).toEqual(expected); | ||
}); | ||
|
||
it('serializes to hex string and deserializes it back', () => { | ||
const expected = makeMergeRollupInputs(); | ||
const str = expected.toString(); | ||
const res = MergeRollupInputs.fromString(str); | ||
expect(res).toEqual(expected); | ||
}); | ||
}); |
Oops, something went wrong.