Skip to content

Commit aa9922d

Browse files
authored
Merge pull request #6796 from Agoric/move-dumpstreams
fix(swing-store): replace getAllState/etc with a debug facet
2 parents bdf9cc9 + c6ecf28 commit aa9922d

16 files changed

+274
-294
lines changed

packages/SwingSet/test/change-parameters/test-change-parameters.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,14 @@ import { test } from '../../tools/prepare-test-env-ava.js';
33

44
// eslint-disable-next-line import/order
55
import { assert } from '@agoric/assert';
6-
import { initSwingStore, getAllState } from '@agoric/swing-store';
6+
import { initSwingStore } from '@agoric/swing-store';
77
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
88
import { kunser } from '../../src/lib/kmarshal.js';
99

1010
function bfile(name) {
1111
return new URL(name, import.meta.url).pathname;
1212
}
1313

14-
// eslint-disable-next-line no-unused-vars
15-
function dumpState(kernelStorage, vatID) {
16-
const s = getAllState(kernelStorage).kvStuff;
17-
const keys = Array.from(Object.keys(s)).sort();
18-
for (const k of keys) {
19-
if (k.startsWith(`${vatID}.vs.`)) {
20-
console.log(k, s[k]);
21-
}
22-
}
23-
}
24-
2514
async function testChangeParameters(t) {
2615
const config = {
2716
bootstrap: 'bootstrap',

packages/SwingSet/test/devices/test-devices.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { test } from '../../tools/prepare-test-env-ava.js';
33

44
import bundleSource from '@endo/bundle-source';
5-
import { initSwingStore, getAllState } from '@agoric/swing-store';
5+
import { initSwingStore } from '@agoric/swing-store';
66
import { parse } from '@endo/marshal';
77

88
import {
@@ -211,7 +211,7 @@ test.serial('d2.5', async t => {
211211
});
212212

213213
test.serial('device state', async t => {
214-
const kernelStorage = initSwingStore().kernelStorage;
214+
const { kernelStorage, debug } = initSwingStore();
215215
const config = {
216216
bootstrap: 'bootstrap',
217217
vats: {
@@ -236,7 +236,7 @@ test.serial('device state', async t => {
236236
const d3 = c1.deviceNameToID('d3');
237237
await c1.run();
238238
t.deepEqual(c1.dump().log, ['undefined', 'w+r', 'called', 'got {"s":"new"}']);
239-
const s = getAllState(kernelStorage).kvStuff;
239+
const s = debug.dump().kvEntries;
240240
t.deepEqual(JSON.parse(s[`${d3}.deviceState`]), kser({ s: 'new' }));
241241
t.deepEqual(JSON.parse(s[`${d3}.o.nextID`]), 10);
242242
});

packages/SwingSet/test/promise-watcher/test-promise-watcher.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,13 @@ import { test } from '../../tools/prepare-test-env-ava.js';
88
// eslint-disable-next-line import/order
99
import { assert } from '@agoric/assert';
1010
// eslint-disable-next-line import/order
11-
import { initSwingStore, getAllState } from '@agoric/swing-store';
11+
import { initSwingStore } from '@agoric/swing-store';
1212
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
1313

1414
function bfile(name) {
1515
return new URL(name, import.meta.url).pathname;
1616
}
1717

18-
// eslint-disable-next-line no-unused-vars
19-
function dumpState(kernelStorage, vatID) {
20-
const s = getAllState(kernelStorage).kvStuff;
21-
const keys = Array.from(Object.keys(s)).sort();
22-
for (const k of keys) {
23-
if (k.startsWith(`${vatID}.vs.`)) {
24-
console.log(k, s[k]);
25-
}
26-
}
27-
}
28-
2918
async function testPromiseWatcher(t) {
3019
const config = {
3120
includeDevDependencies: true, // for vat-data

packages/SwingSet/test/test-activityhash-vs-start.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { test } from '../tools/prepare-test-env-ava.js';
33

44
// eslint-disable-next-line import/order
5-
import { initSwingStore, getAllState, setAllState } from '@agoric/swing-store';
5+
import { initSwingStore } from '@agoric/swing-store';
66
import { initializeSwingset, makeSwingsetController } from '../src/index.js';
77
import { buildTimer } from '../src/devices/timer/timer.js';
88

@@ -11,14 +11,16 @@ const TimerSrc = new URL(
1111
import.meta.url,
1212
).pathname;
1313

14-
// all tests that are sensitive to GC timing (which means anything that
15-
// exercises transcript replay or looks at activityHash) need to use
16-
// test.serial or config.defaultManagerType='xsnap', until we figure out why
17-
// gcAndFinalize sometimes doesn't work (details in #3240 and #4617)
14+
// all tests that are sensitive to GC timing (which means anything
15+
// that exercises transcript replay or looks at activityHash) need to
16+
// use test.serial or config.defaultManagerType='xs-worker', until we
17+
// figure out why gcAndFinalize sometimes doesn't work (details in
18+
// #3240 and #4617). And even test.serial doesn't seem to be enough.
1819

19-
test.serial('restarting kernel does not change activityhash', async t => {
20+
test('restarting kernel does not change activityhash', async t => {
2021
const sourceSpec = new URL('vat-empty-setup.js', import.meta.url).pathname;
2122
const config = {
23+
defaultManagerType: 'xs-worker',
2224
bootstrap: 'bootstrap',
2325
vats: {
2426
bootstrap: {
@@ -38,7 +40,7 @@ test.serial('restarting kernel does not change activityhash', async t => {
3840
const deviceEndowments1 = {
3941
timer: { ...timer1.endowments },
4042
};
41-
const ks1 = initSwingStore().kernelStorage;
43+
const { kernelStorage: ks1, debug: debug1 } = initSwingStore();
4244
// console.log(`--c1 build`);
4345
await initializeSwingset(config, [], ks1);
4446
const c1 = await makeSwingsetController(ks1, deviceEndowments1);
@@ -48,8 +50,8 @@ test.serial('restarting kernel does not change activityhash', async t => {
4850
// console.log(`--c1 run1`);
4951
await c1.run();
5052

51-
// console.log(`--c1 getAllState`);
52-
const state = getAllState(ks1);
53+
// console.log(`--c1 serialize`);
54+
const serialized = debug1.serialize();
5355
// console.log(`ah: ${c1.getActivityhash()}`);
5456

5557
// console.log(`--c1 poll1`);
@@ -70,8 +72,7 @@ test.serial('restarting kernel does not change activityhash', async t => {
7072
const deviceEndowments2 = {
7173
timer: { ...timer2.endowments },
7274
};
73-
const ks2 = initSwingStore().kernelStorage;
74-
setAllState(ks2, state);
75+
const { kernelStorage: ks2 } = initSwingStore(null, { serialized });
7576
// console.log(`--c2 build`);
7677
const c2 = await makeSwingsetController(ks2, deviceEndowments2);
7778
// console.log(`ah: ${c2.getActivityhash()}`);
@@ -92,24 +93,24 @@ test.serial('restarting kernel does not change activityhash', async t => {
9293
t.is(c1ah, c2ah);
9394
});
9495

95-
test.serial('comms initialize is deterministic', async t => {
96+
test('comms initialize is deterministic', async t => {
9697
// bug #3726: comms was calling vatstoreGet('initialize') and
9798
// vatstoreSet('meta.o+0') during the first message after process restart,
9899
// which makes it a nondeterministic function of the input events.
99100

100101
const sourceSpec = new URL('vat-activityhash-comms.js', import.meta.url)
101102
.pathname;
102-
const config = {};
103+
const config = { defaultManagerType: 'xs-worker' };
103104
config.bootstrap = 'bootstrap';
104105
config.vats = { bootstrap: { sourceSpec } };
105-
const ks1 = initSwingStore().kernelStorage;
106+
const { kernelStorage: ks1, debug: debug1 } = initSwingStore();
106107
await initializeSwingset(config, [], ks1);
107108
const c1 = await makeSwingsetController(ks1, {});
108109
c1.pinVatRoot('bootstrap');
109110
// the bootstrap message will cause comms to initialize itself
110111
await c1.run();
111112

112-
const state = getAllState(ks1);
113+
const serialized = debug1.serialize();
113114

114115
// but the second message should not
115116
c1.queueToVatRoot('bootstrap', 'addRemote', ['remote2']);
@@ -118,8 +119,7 @@ test.serial('comms initialize is deterministic', async t => {
118119
await c1.shutdown();
119120

120121
// a kernel restart is loading a new kernel from the same state
121-
const ks2 = initSwingStore().kernelStorage;
122-
setAllState(ks2, state);
122+
const { kernelStorage: ks2 } = initSwingStore(null, { serialized });
123123
const c2 = await makeSwingsetController(ks2, {});
124124

125125
// the "am I already initialized?" check must be identical to the

0 commit comments

Comments
 (0)