Skip to content

Commit

Permalink
chore(xsnap): update tests to accommodate XS changes
Browse files Browse the repository at this point in the history
Use FinalizationRegistry alone instead of WeakRef to track gc
Property key no longer result in exhaustion
  • Loading branch information
mhofman committed Apr 26, 2023
1 parent 53ea100 commit 7b16392
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/xsnap/test/test-xs-limits.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test('heap exhaustion: orderly fail-stop', async t => {
}
});

test('property name space exhaustion: orderly fail-stop', async t => {
test.skip('property name space exhaustion: orderly fail-stop', async t => {
const grow = qty => `
const objmap = {};
try {
Expand Down
16 changes: 9 additions & 7 deletions packages/xsnap/test/test-xsnap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global setTimeout, WeakRef, setImmediate, process */
/* global setTimeout, FinalizationRegistry, setImmediate, process */
import '@endo/init/debug.js';

// eslint-disable-next-line import/no-extraneous-dependencies
Expand Down Expand Up @@ -348,16 +348,18 @@ test('normal close of pathological script', async t => {
});

async function runToGC() {
const trashCan = [{}];
const wr = new WeakRef(trashCan[0]);
// @ts-expect-error
trashCan[0] = undefined;
let collected = false;
const fr = new FinalizationRegistry(() => {
collected = true;
});
fr.register({}, undefined);
const trashCan = [];

let qty;
for (qty = 0; wr.deref(); qty += 1) {
for (qty = 0; !collected; qty += 1) {
// eslint-disable-next-line no-await-in-loop
await new Promise(setImmediate);
trashCan[1] = Array(10_000).map(() => ({}));
trashCan.push(Array(10_000).map(() => ({})));
}
return qty;
}
Expand Down

0 comments on commit 7b16392

Please sign in to comment.