File tree Expand file tree Collapse file tree
yarn-project/stdlib/src/note Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ describe('NoteDao', () => {
77 expect ( NoteDao . fromBuffer ( buf ) ) . toEqual ( note ) ;
88 } ) ;
99
10+ it ( 'reports the serialized size' , async ( ) => {
11+ const note = await NoteDao . random ( ) ;
12+
13+ expect ( note . getSize ( ) ) . toBe ( note . toBuffer ( ) . length ) ;
14+ } ) ;
15+
1016 describe ( 'equals' , ( ) => {
1117 it ( 'returns true for identical NoteDao instances' , async ( ) => {
1218 const note1 = await NoteDao . random ( ) ;
Original file line number Diff line number Diff line change 11import { BlockNumber } from '@aztec/foundation/branded-types' ;
22import { Fr } from '@aztec/foundation/curves/bn254' ;
3- import { Point } from '@aztec/foundation/curves/grumpkin' ;
43import { BufferReader , serializeToBuffer } from '@aztec/foundation/serialize' ;
54import { AztecAddress } from '@aztec/stdlib/aztec-address' ;
65import { Note } from '@aztec/stdlib/note' ;
@@ -148,9 +147,7 @@ export class NoteDao {
148147 * @returns - Its size in bytes.
149148 */
150149 public getSize ( ) {
151- const noteSize = 4 + this . note . items . length * Fr . SIZE_IN_BYTES ;
152- // 2 numbers for txIndexInBlock and noteIndexInTx (4 bytes each)
153- return noteSize + AztecAddress . SIZE_IN_BYTES * 2 + Fr . SIZE_IN_BYTES * 4 + TxHash . SIZE + Point . SIZE_IN_BYTES + 8 ;
150+ return this . toBuffer ( ) . length ;
154151 }
155152
156153 static async random ( {
You can’t perform that action at this time.
0 commit comments