From 3135d9a14c0b9e773419c6882ad00fb285b27303 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Wed, 8 Apr 2020 18:21:15 -0600 Subject: [PATCH] fix: liveslots use the returned promise rather than our own --- packages/SwingSet/src/kernel/liveSlots.js | 14 +++++++------- packages/SwingSet/test/test-vpid-liveslots.js | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/SwingSet/src/kernel/liveSlots.js b/packages/SwingSet/src/kernel/liveSlots.js index 3454ea4f560..8d5491c7cc7 100644 --- a/packages/SwingSet/src/kernel/liveSlots.js +++ b/packages/SwingSet/src/kernel/liveSlots.js @@ -75,9 +75,9 @@ function build(syscall, _state, makeRoot, forVatID) { function makeQueued(slot) { /* eslint-disable no-use-before-define */ const handler = { - applyMethod(_o, prop, args) { + applyMethod(_o, prop, args, returnedP) { // Support: o~.[prop](...args) remote method invocation - return queueMessage(slot, prop, args); + return queueMessage(slot, prop, args, returnedP); }, }; /* eslint-enable no-use-before-define */ @@ -233,7 +233,7 @@ function build(syscall, _state, makeRoot, forVatID) { const m = makeMarshal(convertValToSlot, convertSlotToVal); - function queueMessage(targetSlot, prop, args) { + function queueMessage(targetSlot, prop, args, returnedP) { const serArgs = m.serialize(harden(args)); const result = allocatePromiseID(); const done = makeQueued(result); @@ -248,10 +248,10 @@ function build(syscall, _state, makeRoot, forVatID) { lsdebug(`ls[${forVatID}].queueMessage.importedPromiseThen ${result}`); importedPromiseThen(result); - // prepare the serializer to recognize it, if it's used as an argument or - // return value - valToSlot.set(done.p, result); - slotToVal.set(result, done.p); + // prepare the serializer to recognize the promise we will return, + // if it's used as an argument or return value + valToSlot.set(returnedP, result); + slotToVal.set(result, returnedP); return done.p; } diff --git a/packages/SwingSet/test/test-vpid-liveslots.js b/packages/SwingSet/test/test-vpid-liveslots.js index 7f20d1b5e43..10c572d5b92 100644 --- a/packages/SwingSet/test/test-vpid-liveslots.js +++ b/packages/SwingSet/test/test-vpid-liveslots.js @@ -151,10 +151,10 @@ async function doVatResolveCase1(t, mode) { async run(target1) { const p1 = pr.promise; E(target1).one(p1); + resolvePR(pr, mode); // TODO: this stall shouldn't be necessary, but if I omit it, the // fulfillToPresence happens *after* two() is sent await Promise.resolve(); - resolvePR(pr, mode); E(target1).two(p1); }, });