Skip to content

Commit

Permalink
harden the return value of m.serialize()
Browse files Browse the repository at this point in the history
closes Agoric#11
  • Loading branch information
warner committed Sep 12, 2019
1 parent c1860bc commit 34adf05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,10 @@ export function makeMarshal(serializeSlot, unserializeSlot) {
const slots = [];
const slotMap = new Map(); // maps val (proxy or presence) to
// index of slots[]
return {
return harden({
body: JSON.stringify(val, makeReplacer(slots, slotMap)),
slots,
};
});
}

function makeFullRevive(slots, cyclePolicy) {
Expand Down
4 changes: 4 additions & 0 deletions test/test-marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ test('serialize static data', t => {
slots: [],
});

const cd = ser(harden([1, 2]));
t.equal(Object.isFrozen(cd), true);
t.equal(Object.isFrozen(cd.slots), true);

t.end();
});

Expand Down

0 comments on commit 34adf05

Please sign in to comment.