-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ee3eff
commit 342eaec
Showing
8 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const start = zcf => { | ||
console.log('makeKind in contract', makeKind()); | ||
console.log('makeWeakStore in contract', makeWeakStore()); | ||
|
||
makeKind(); | ||
makeWeakStore(); | ||
|
||
return harden({}); | ||
}; | ||
harden(start); | ||
export { start }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { E } from '@agoric/eventual-send'; | ||
import { Far } from '@agoric/marshal'; | ||
|
||
export function buildRootObject(vatPowers, vatParameters) { | ||
const { contractBundles: cb } = vatParameters; | ||
return Far('root', { | ||
async bootstrap(vats, devices) { | ||
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService( | ||
devices.vatAdmin, | ||
); | ||
const zoe = await E(vats.zoe).buildZoe(vatAdminSvc); | ||
const installations = { | ||
minimalMakeKind: await E(zoe).install(cb.minimalMakeKindContract), | ||
}; | ||
|
||
const aliceP = E(vats.alice).build(zoe, installations); | ||
await E(aliceP).minimalMakeKindTest(); | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import '@agoric/install-metering-and-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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { E } from '@agoric/eventual-send'; | ||
import { Far } from '@agoric/marshal'; | ||
|
||
const build = async (log, zoe, installations) => { | ||
return Far('build', { | ||
minimalMakeKindTest: async () => { | ||
const result = await E(zoe).startInstance(installations.minimalMakeKind); | ||
log(result); | ||
}, | ||
}); | ||
}; | ||
|
||
export function buildRootObject(vatPowers) { | ||
return Far('root', { | ||
build: (...args) => build(vatPowers.testLog, ...args), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Far } from '@agoric/marshal'; | ||
|
||
// noinspection ES6PreferShortImport | ||
import { makeZoe } from '../../../src/zoeService/zoe'; | ||
|
||
export function buildRootObject(_vatPowers) { | ||
return Far('root', { | ||
buildZoe: vatAdminSvc => makeZoe(vatAdminSvc), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* globals makeKind makeWeakStore */ | ||
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import '@agoric/zoe/tools/prepare-test-env'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import test from 'ava'; | ||
import bundleSource from '@agoric/bundle-source'; | ||
|
||
import { E } from '@agoric/eventual-send'; | ||
import { makeZoe } from '../../src/zoeService/zoe'; | ||
import fakeVatAdmin from '../../src/contractFacet/fakeVatAdmin'; | ||
|
||
const root = `${__dirname}/../minimalMakeKindContract`; | ||
|
||
test('makeKind non-swingset', async t => { | ||
const bundle = await bundleSource(root); | ||
const zoe = makeZoe(fakeVatAdmin); | ||
const installation = await E(zoe).install(bundle); | ||
console.log('makeKind in test file', makeKind()); | ||
console.log('makeWeakStore in test file', makeWeakStore()); | ||
t.notThrows(() => makeKind()); | ||
t.notThrows(() => makeWeakStore()); | ||
await t.notThrowsAsync(() => zoe.startInstance(installation)); | ||
}); |