diff --git a/packages/swingset-liveslots/src/collectionManager.js b/packages/swingset-liveslots/src/collectionManager.js index 8ee66541b48..9b8b6d4ff2e 100644 --- a/packages/swingset-liveslots/src/collectionManager.js +++ b/packages/swingset-liveslots/src/collectionManager.js @@ -616,16 +616,21 @@ export function makeCollectionManager( function clearInternal(isDeleting, keyPatt, valuePatt) { let doMoreGC = false; - if (isDeleting || (matchAny(keyPatt) && matchAny(valuePatt))) { + if (isDeleting) { doMoreGC = clearInternalFull(); + // |entryCount will be deleted along with metadata keys + } else if (matchAny(keyPatt) && matchAny(valuePatt)) { + doMoreGC = clearInternalFull(); + if (!hasWeakKeys) { + syscall.vatstoreSet(prefix('|entryCount'), '0'); + } } else { + let numDeleted = 0; for (const k of keys(keyPatt, valuePatt)) { + numDeleted += 1; doMoreGC = deleteInternal(k) || doMoreGC; } - } - if (!hasWeakKeys && !isDeleting) { - // TODO: broken, see #10007 - syscall.vatstoreSet(prefix('|entryCount'), '0'); + updateEntryCount(-numDeleted); } return doMoreGC; } diff --git a/packages/swingset-liveslots/test/collections.test.js b/packages/swingset-liveslots/test/collections.test.js index d63192b025c..f4cc62bfbb9 100644 --- a/packages/swingset-liveslots/test/collections.test.js +++ b/packages/swingset-liveslots/test/collections.test.js @@ -503,8 +503,7 @@ test('map clear', t => { t.is(testStore.getSize(), 0); }); -// see #10007 -test.failing('map clear with pattern', t => { +test('map clear with pattern', t => { const testStore = makeScalarBigMapStore('cmap', { keyShape: M.any() }); testStore.init('a', 'ax'); testStore.init('b', 'bx'); @@ -529,8 +528,7 @@ test('set clear', t => { t.is(testStore.getSize(), 0); }); -// see #10007 -test.failing('set clear with pattern', t => { +test('set clear with pattern', t => { const testStore = makeScalarBigSetStore('cset', { keyShape: M.any() }); testStore.add('a'); testStore.add('b');