2
2
import { test } from '../tools/prepare-test-env-ava.js' ;
3
3
4
4
// eslint-disable-next-line import/order
5
- import { initSwingStore , getAllState , setAllState } from '@agoric/swing-store' ;
5
+ import { initSwingStore } from '@agoric/swing-store' ;
6
6
import { initializeSwingset , makeSwingsetController } from '../src/index.js' ;
7
7
import { buildTimer } from '../src/devices/timer/timer.js' ;
8
8
@@ -11,14 +11,16 @@ const TimerSrc = new URL(
11
11
import . meta. url ,
12
12
) . pathname ;
13
13
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.
18
19
19
- test . serial ( 'restarting kernel does not change activityhash' , async t => {
20
+ test ( 'restarting kernel does not change activityhash' , async t => {
20
21
const sourceSpec = new URL ( 'vat-empty-setup.js' , import . meta. url ) . pathname ;
21
22
const config = {
23
+ defaultManagerType : 'xs-worker' ,
22
24
bootstrap : 'bootstrap' ,
23
25
vats : {
24
26
bootstrap : {
@@ -38,7 +40,7 @@ test.serial('restarting kernel does not change activityhash', async t => {
38
40
const deviceEndowments1 = {
39
41
timer : { ...timer1 . endowments } ,
40
42
} ;
41
- const ks1 = initSwingStore ( ) . kernelStorage ;
43
+ const { kernelStorage : ks1 , debug : debug1 } = initSwingStore ( ) ;
42
44
// console.log(`--c1 build`);
43
45
await initializeSwingset ( config , [ ] , ks1 ) ;
44
46
const c1 = await makeSwingsetController ( ks1 , deviceEndowments1 ) ;
@@ -48,8 +50,8 @@ test.serial('restarting kernel does not change activityhash', async t => {
48
50
// console.log(`--c1 run1`);
49
51
await c1 . run ( ) ;
50
52
51
- // console.log(`--c1 getAllState `);
52
- const state = getAllState ( ks1 ) ;
53
+ // console.log(`--c1 serialize `);
54
+ const serialized = debug1 . serialize ( ) ;
53
55
// console.log(`ah: ${c1.getActivityhash()}`);
54
56
55
57
// console.log(`--c1 poll1`);
@@ -70,8 +72,7 @@ test.serial('restarting kernel does not change activityhash', async t => {
70
72
const deviceEndowments2 = {
71
73
timer : { ...timer2 . endowments } ,
72
74
} ;
73
- const ks2 = initSwingStore ( ) . kernelStorage ;
74
- setAllState ( ks2 , state ) ;
75
+ const { kernelStorage : ks2 } = initSwingStore ( null , { serialized } ) ;
75
76
// console.log(`--c2 build`);
76
77
const c2 = await makeSwingsetController ( ks2 , deviceEndowments2 ) ;
77
78
// console.log(`ah: ${c2.getActivityhash()}`);
@@ -92,24 +93,24 @@ test.serial('restarting kernel does not change activityhash', async t => {
92
93
t . is ( c1ah , c2ah ) ;
93
94
} ) ;
94
95
95
- test . serial ( 'comms initialize is deterministic' , async t => {
96
+ test ( 'comms initialize is deterministic' , async t => {
96
97
// bug #3726: comms was calling vatstoreGet('initialize') and
97
98
// vatstoreSet('meta.o+0') during the first message after process restart,
98
99
// which makes it a nondeterministic function of the input events.
99
100
100
101
const sourceSpec = new URL ( 'vat-activityhash-comms.js' , import . meta. url )
101
102
. pathname ;
102
- const config = { } ;
103
+ const config = { defaultManagerType : 'xs-worker' } ;
103
104
config . bootstrap = 'bootstrap' ;
104
105
config . vats = { bootstrap : { sourceSpec } } ;
105
- const ks1 = initSwingStore ( ) . kernelStorage ;
106
+ const { kernelStorage : ks1 , debug : debug1 } = initSwingStore ( ) ;
106
107
await initializeSwingset ( config , [ ] , ks1 ) ;
107
108
const c1 = await makeSwingsetController ( ks1 , { } ) ;
108
109
c1 . pinVatRoot ( 'bootstrap' ) ;
109
110
// the bootstrap message will cause comms to initialize itself
110
111
await c1 . run ( ) ;
111
112
112
- const state = getAllState ( ks1 ) ;
113
+ const serialized = debug1 . serialize ( ) ;
113
114
114
115
// but the second message should not
115
116
c1 . queueToVatRoot ( 'bootstrap' , 'addRemote' , [ 'remote2' ] ) ;
@@ -118,8 +119,7 @@ test.serial('comms initialize is deterministic', async t => {
118
119
await c1 . shutdown ( ) ;
119
120
120
121
// 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 } ) ;
123
123
const c2 = await makeSwingsetController ( ks2 , { } ) ;
124
124
125
125
// the "am I already initialized?" check must be identical to the
0 commit comments