Skip to content

Commit

Permalink
fix: pass testLog to all vatWorkers
Browse files Browse the repository at this point in the history
This adds a new message to the vat-to-kernel protocol, `['testLog',
...args]`, to deliver the strings from the vat to the kernel. They get added
to the same `c.dump().log` array that local workers can write to. This is
solely for the benefit of unit tests.

refs #1776 (closing the `testLog` part, but not the other vatPowers)
  • Loading branch information
warner committed Sep 21, 2020
1 parent 1edd620 commit 29bc81a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/SwingSet/src/kernel/vatManager/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ export function makeVatManagerFactory({
const nodeWorkerFactory = makeNodeWorkerVatManagerFactory({
makeNodeWorker,
kernelKeeper,
testLog: allVatPowers.testLog,
});

const nodeSubprocessFactory = makeNodeSubprocessFactory({
startSubprocessWorker: startSubprocessWorkerNode,
kernelKeeper,
testLog: allVatPowers.testLog,
});

const xsWorkerFactory = makeNodeSubprocessFactory({
startSubprocessWorker: startSubprocessWorkerXS,
kernelKeeper,
testLog: allVatPowers.testLog,
});

function validateManagerOptions(managerOptions) {
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/src/kernel/vatManager/nodeWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function parentLog(first, ...args) {
}

export function makeNodeWorkerVatManagerFactory(tools) {
const { makeNodeWorker, kernelKeeper } = tools;
const { makeNodeWorker, kernelKeeper, testLog } = tools;

function createFromBundle(vatID, bundle, managerOptions) {
const { vatParameters } = managerOptions;
Expand Down Expand Up @@ -97,6 +97,8 @@ export function makeNodeWorkerVatManagerFactory(tools) {
parentLog(`syscall`, args);
const vatSyscallObject = args;
handleSyscall(vatSyscallObject);
} else if (type === 'testLog') {
testLog(...args);
} else if (type === 'deliverDone') {
parentLog(`deliverDone`);
if (waiting) {
Expand Down
11 changes: 10 additions & 1 deletion packages/SwingSet/src/kernel/vatManager/nodeWorkerSupervisor.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,22 @@ parentPort.on('message', ([type, ...margs]) => {
reject: (...args) => doSyscall(['reject', ...args]),
});

function testLog(...args) {
sendUplink(['testLog', ...args]);
}

const state = null;
const vatID = 'demo-vatID';
// todo: maybe add transformTildot, makeGetMeter/transformMetering to
// vatPowers, but only if options tell us they're wanted. Maybe
// transformTildot should be async and outsourced to the kernel
// process/thread.
const vatPowers = { Remotable, getInterfaceOf, makeMarshal };
const vatPowers = {
Remotable,
getInterfaceOf,
makeMarshal,
testLog,
};
dispatch = makeLiveSlots(
syscall,
state,
Expand Down
11 changes: 10 additions & 1 deletion packages/SwingSet/src/kernel/vatManager/subprocessSupervisor.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,22 @@ fromParent.on('data', data => {
reject: (...args) => doSyscall(['reject', ...args]),
});

function testLog(...args) {
sendUplink(['testLog', ...args]);
}

const state = null;
const vatID = 'demo-vatID';
// todo: maybe add transformTildot, makeGetMeter/transformMetering to
// vatPowers, but only if options tell us they're wanted. Maybe
// transformTildot should be async and outsourced to the kernel
// process/thread.
const vatPowers = { Remotable, getInterfaceOf, makeMarshal };
const vatPowers = {
Remotable,
getInterfaceOf,
makeMarshal,
testLog,
};
dispatch = makeLiveSlots(
syscall,
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function parentLog(first, ...args) {
}

export function makeNodeSubprocessFactory(tools) {
const { startSubprocessWorker, kernelKeeper } = tools;
const { startSubprocessWorker, kernelKeeper, testLog } = tools;

function createFromBundle(vatID, bundle, managerOptions) {
const { vatParameters } = managerOptions;
Expand Down Expand Up @@ -99,6 +99,8 @@ export function makeNodeSubprocessFactory(tools) {
parentLog(`syscall`, args);
const vatSyscallObject = args;
handleSyscall(vatSyscallObject);
} else if (type === 'testLog') {
testLog(...args);
} else if (type === 'deliverDone') {
parentLog(`deliverDone`);
if (waiting) {
Expand Down
4 changes: 4 additions & 0 deletions packages/xs-vat-worker/src/vatWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ function makeWorker(io, setImmediate) {
reject: (...args) => doSyscall(['reject', ...args]),
});

function testLog(...args) {
sendUplink(['testLog', ...args]);
}
const state = null;
const vatID = 'demo-vatID';
// todo: maybe add transformTildot, makeGetMeter/transformMetering to
Expand All @@ -137,6 +140,7 @@ function makeWorker(io, setImmediate) {
Remotable,
getInterfaceOf,
makeMarshal,
testLog,
};
dispatch = makeLiveSlots(
syscall,
Expand Down

0 comments on commit 29bc81a

Please sign in to comment.