Skip to content

Commit

Permalink
Fix size from bytes instead of string. Need for serder with special c…
Browse files Browse the repository at this point in the history
…haracters (#253)

* fix size from bytes

* unit test

* prettier
  • Loading branch information
rodolfomiranda committed May 5, 2024
1 parent fddaff2 commit 651bad6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/keri/core/serder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function sizeify(
}

let raw = dumps(ked, kind);
const size = raw.length;
const size = new TextEncoder().encode(raw).length;

ked['v'] = versify(ident, version, kind, size);

Expand Down
5 changes: 5 additions & 0 deletions test/core/serder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,10 @@ describe('Serder', () => {

aid0 = new Prefixer({ code: MtrDex.Blake3_256 }, ked0);
assert.equal(aid0.qb64, 'ECHOi6qRaswNpvytpCtpvEh2cB2aLAwVHBLFinno3YVW');

const ked1 = ked0;
ked1.a = { n: 'Lenksjö' };
const serder1 = new Serder(ked1);
assert.equal(serder1.ked.v, 'KERI10JSON000139_');
});
});

0 comments on commit 651bad6

Please sign in to comment.