-
Notifications
You must be signed in to change notification settings - Fork 237
/
Copy pathtest-makeKind.js
77 lines (68 loc) · 2.43 KB
/
test-makeKind.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
76
77
/* global __dirname */
// TODO Remove babel-standalone preinitialization
// https://github.com/endojs/endo/issues/768
import '@agoric/babel-standalone';
// eslint-disable-next-line import/no-extraneous-dependencies
import '@agoric/install-ses';
// eslint-disable-next-line import/no-extraneous-dependencies
import test from 'ava';
// eslint-disable-next-line import/no-extraneous-dependencies
import { buildVatController, buildKernelBundles } from '@agoric/swingset-vat';
import bundleSource from '@agoric/bundle-source';
const CONTRACT_FILES = ['minimalMakeKindContract'];
test.before(async t => {
const start = Date.now();
const kernelBundles = await buildKernelBundles();
const step2 = Date.now();
const contractBundles = {};
await Promise.all(
CONTRACT_FILES.map(async settings => {
let bundleName;
let contractPath;
if (typeof settings === 'string') {
bundleName = settings;
contractPath = settings;
} else {
({ bundleName, contractPath } = settings);
}
const source = `${__dirname}/../../${contractPath}`;
const bundle = await bundleSource(source);
contractBundles[bundleName] = bundle;
}),
);
const step3 = Date.now();
const vats = {};
await Promise.all(
['alice', 'zoe'].map(async name => {
const source = `${__dirname}/vat-${name}.js`;
const bundle = await bundleSource(source);
vats[name] = { bundle };
}),
);
const bootstrapSource = `${__dirname}/bootstrap.js`;
vats.bootstrap = {
bundle: await bundleSource(bootstrapSource),
parameters: { contractBundles }, // argv will be added to this
};
const config = { bootstrap: 'bootstrap', vats };
const step4 = Date.now();
const ktime = `${(step2 - start) / 1000}s kernel`;
const ctime = `${(step3 - step2) / 1000}s contracts`;
const vtime = `${(step4 - step3) / 1000}s vats`;
const ttime = `${(step4 - start) / 1000}s total`;
console.log(`bundling: ${ktime}, ${ctime}, ${vtime}, ${ttime}`);
t.context.data = { kernelBundles, config };
});
async function main(t, argv) {
const { kernelBundles, config } = t.context.data;
const controller = await buildVatController(config, argv, { kernelBundles });
await controller.run();
return controller.dump();
}
const expected = [
'{"adminFacet":{},"creatorFacet":{},"instance":{},"publicFacet":{}}',
];
test.serial('makeKind swingset', async t => {
const dump = await main(t);
t.deepEqual(dump.log, expected);
});