Skip to content

Commit

Permalink
fix: bug in fake virtual stuff due to recent liveslots additions
Browse files Browse the repository at this point in the history
In support of #5283.

@erights and @Chris-Hibbert encountered this in the course of testing their
durabilization of ERTP.  Note that this bug only implicates tests and not the
actual underlying virtual objects implementation.
  • Loading branch information
FUDCo committed May 11, 2022
1 parent 0e79820 commit db71bd7
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions packages/SwingSet/tools/fakeVirtualSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,23 @@ export function makeFakeLiveSlotsStuff(options = {}) {
}

function convertSlotToVal(slot) {
const { type, virtual } = parseVatSlot(slot);
const { type, virtual, facet, baseRef } = parseVatSlot(slot);
assert.equal(type, 'object');
let val = getValForSlot(slot);
let val = getValForSlot(baseRef);
if (val) {
if (virtual) {
if (facet !== undefined) {
return val[facet];
}
}
return val;
}
if (virtual) {
if (vrm) {
val = vrm.reanimate(slot);
if (facet !== undefined) {
val = val[facet];
}
} else {
assert.fail('fake liveSlots stuff configured without vrm');
}
Expand All @@ -197,9 +205,15 @@ export function makeFakeLiveSlotsStuff(options = {}) {

const marshal = makeMarshal(convertValToSlot, convertSlotToVal);

function registerEntry(slot, val) {
setValForSlot(slot, val);
valToSlot.set(val, slot);
function registerEntry(baseRef, val, valIsCohort) {
setValForSlot(baseRef, val);
if (valIsCohort) {
for (let i = 0; i < val.length; i += 1) {
valToSlot.set(val[i], `${baseRef}:${i}`);
}
} else {
valToSlot.set(val, baseRef);
}
}

function deleteEntry(slot, val) {
Expand Down

0 comments on commit db71bd7

Please sign in to comment.