-
Notifications
You must be signed in to change notification settings - Fork 226
/
Copy pathtest-innerVat.js
75 lines (68 loc) · 2.22 KB
/
test-innerVat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import '@agoric/install-metering-and-ses';
import path from 'path';
import { test } from 'tape';
import { initSwingStore } from '@agoric/swing-store-simple';
import bundleSource from '@agoric/bundle-source';
import { buildVatController, loadBasedir } from '../../src';
function nonBundleFunction(_E) {
return {};
}
async function doTestSetup(mode) {
const config = await loadBasedir(__dirname);
config.hostStorage = initSwingStore().storage;
const newVatBundle = await bundleSource(path.join(__dirname, 'new-vat.js'));
const brokenVatBundle = await bundleSource(
path.join(__dirname, 'broken-vat.js'),
);
const nonBundle = `${nonBundleFunction}`;
const bundles = { newVatBundle, brokenVatBundle, nonBundle };
const c = await buildVatController(config, [mode, bundles]);
return c;
}
test('VatAdmin inner vat creation', async t => {
const c = await doTestSetup('newVat');
for (let i = 0; i < 9; i += 1) {
// eslint-disable-next-line no-await-in-loop
await c.step();
}
t.deepEqual(c.dump().log, ['starting newVat test', '13']);
t.end();
});
test('VatAdmin counter test', async t => {
const c = await doTestSetup('counters');
await c.run();
await c.run();
t.deepEqual(c.dump().log, ['starting counter test', '4', '9', '2']);
t.end();
});
test('VatAdmin broken vat creation', async t => {
const c = await doTestSetup('brokenVat');
await c.run();
t.deepEqual(c.dump().log, [
'starting brokenVat test',
'yay, rejected: Error: Vat Creation Error: ReferenceError: missing is not defined',
]);
t.end();
});
test('error creating vat from non-bundle', async t => {
const c = await doTestSetup('non-bundle');
await c.run();
t.deepEqual(c.dump().log, [
'starting non-bundle test',
'yay, rejected: Error: Vat Creation Error: Error: createVatDynamically() requires bundle, not a plain string',
]);
await c.run();
t.end();
});
test('VatAdmin get vat stats', async t => {
const c = await doTestSetup('vatStats');
await c.run();
t.deepEqual(c.dump().log, [
'starting stats test',
'{"objectCount":0,"promiseCount":0,"deviceCount":0,"transcriptCount":0}',
'4',
'{"objectCount":0,"promiseCount":2,"deviceCount":0,"transcriptCount":2}',
]);
await c.run();
t.end();
});