Skip to content

Commit aa72c90

Browse files
committed
chore: Swingset-runner test to validate vat process failure behavior
Closes #2958
1 parent 15234fa commit aa72c90

File tree

5 files changed

+65
-4
lines changed

5 files changed

+65
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { E } from '@endo/eventual-send';
2+
import { Far } from '@endo/marshal';
3+
4+
export function buildRootObject() {
5+
console.log(`bootstrap vat initializing`);
6+
return Far('root', {
7+
async bootstrap(vats) {
8+
const howMuch = 100_000_000;
9+
console.log(`bootstrap vat invokes busy vat for ${howMuch} steps`);
10+
await E(vats.busy).doStuff(howMuch);
11+
await E(vats.idle).doNothing();
12+
},
13+
});
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"bootstrap": "bootstrap",
3+
"defaultManagerType": "xs-worker",
4+
"vats": {
5+
"bootstrap": {
6+
"sourceSpec": "bootstrap.js"
7+
},
8+
"busy": {
9+
"sourceSpec": "vat-busy.js"
10+
},
11+
"idle": {
12+
"sourceSpec": "vat-idle.js"
13+
}
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Far } from '@endo/marshal';
2+
3+
export function buildRootObject(_vatPowers, _vatParameters, baggage) {
4+
console.log(`busy vat initializing`);
5+
baggage.init('someKey', 'hello');
6+
return Far('root', {
7+
doStuff(howMuch) {
8+
let n = 2.0;
9+
for (let i = 0; i <= howMuch; i += 1) {
10+
n = Math.sqrt(n) * Math.sqrt(n); // introduce some computational drag
11+
if (i % 10_000_000 === 0) {
12+
let bv = 'no baggage';
13+
if (baggage) {
14+
bv = baggage.get('someKey');
15+
}
16+
console.log(`busy vat doing step ${i} of ${howMuch}, bv=${bv}`);
17+
}
18+
}
19+
console.log(`busy vat finished ${howMuch} steps`);
20+
},
21+
});
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Far } from '@endo/marshal';
2+
3+
export function buildRootObject() {
4+
console.log(`idle vat initializing`);
5+
return Far('root', {
6+
doNothing() {},
7+
});
8+
}

packages/swingset-runner/src/main.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,12 @@ export async function main() {
339339
delete config.loopboxSenders;
340340
deviceEndowments.loopbox = { ...loopboxEndowments };
341341
}
342-
if (useXS) {
343-
config.defaultManagerType = 'xs-worker';
344-
} else {
345-
config.defaultManagerType = 'local';
342+
if (!config.defaultManagerType) {
343+
if (useXS) {
344+
config.defaultManagerType = 'xs-worker';
345+
} else {
346+
config.defaultManagerType = 'local';
347+
}
346348
}
347349
if (launchIndirectly) {
348350
config = generateIndirectConfig(config);

0 commit comments

Comments
 (0)