Skip to content

Commit

Permalink
fix: use REMOTE_STYLE rather than 'presence' to prepare
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Aug 21, 2020
1 parent 53b3e2e commit 55b3acc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
5 changes: 3 additions & 2 deletions packages/SwingSet/test/test-exomessages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '@agoric/install-ses';
import { REMOTE_STYLE } from '@agoric/marshal';
import { test } from 'tape-promise/tape';
import { buildVatController } from '../src/index';

Expand Down Expand Up @@ -40,7 +41,7 @@ test('bootstrap returns presence', async t => {
// prettier-ignore
await bootstrapSuccessfully(
t,
'presence',
REMOTE_STYLE,
'{"@qclass":"slot",index:0}',
['ko25'],
);
Expand Down Expand Up @@ -106,7 +107,7 @@ test('extra message returns presence', async t => {
// prettier-ignore
await extraMessage(
t,
'presence',
REMOTE_STYLE,
'fulfilled',
'{"@qclass":"slot",index:0}',
['ko25'],
Expand Down
7 changes: 4 additions & 3 deletions packages/SwingSet/test/test-vpid-kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* global harden */

import '@agoric/install-ses';
import { REMOTE_STYLE } from '@agoric/marshal';
import { test } from 'tape-promise/tape';
import anylogger from 'anylogger';
import { initSwingStore } from '@agoric/swing-store-simple';
Expand Down Expand Up @@ -90,7 +91,7 @@ function buildRawVat(name, kernel, onDispatchCallback = undefined) {
// ways:
// prettier-ignore
const modes = [
'presence', // resolveToPresence: messages can be sent to resolution
REMOTE_STYLE, // resolveToPresence: messages can be sent to resolution
'local-object', // resolve to a local object: messages to resolution don't create syscalls
'data', // resolveToData: messages are rejected as DataIsNotCallable
'promise-data', // resolveToData that contains a promise ID
Expand All @@ -102,7 +103,7 @@ const slot0arg = { '@qclass': 'slot', index: 0 };

function doResolveSyscall(syscallA, vpid, mode, targets) {
switch (mode) {
case 'presence':
case REMOTE_STYLE:
syscallA.fulfillToPresence(vpid, targets.target2);
break;
case 'local-object':
Expand All @@ -127,7 +128,7 @@ function doResolveSyscall(syscallA, vpid, mode, targets) {

function resolutionOf(vpid, mode, targets) {
switch (mode) {
case 'presence':
case REMOTE_STYLE:
return {
type: 'notifyFulfillToPresence',
promiseID: vpid,
Expand Down
17 changes: 9 additions & 8 deletions packages/SwingSet/test/test-vpid-liveslots.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { test } from 'tape-promise/tape';

import { E } from '@agoric/eventual-send';
import { makePromiseKit } from '@agoric/promise-kit';
import { REMOTE_STYLE } from '@agoric/marshal';
import { makeLiveSlots } from '../src/kernel/liveSlots';

const RETIRE_VPIDS = true;
Expand Down Expand Up @@ -100,7 +101,7 @@ function hush(p) {
// In addition, we want to exercise the promises being resolved in various
// ways:
const modes = [
'presence', // resolveToPresence, messages can be sent to resolution
REMOTE_STYLE, // resolveToPresence, messages can be sent to resolution
'local-object', // resolve to a local object, messages can be sent but do
// // not create syscalls
'data', // resolveToData, messages are rejected as DataIsNotCallable
Expand All @@ -111,7 +112,7 @@ const modes = [

function resolvePR(pr, mode, targets) {
switch (mode) {
case 'presence':
case REMOTE_STYLE:
pr.resolve(targets.target2);
break;
case 'local-object':
Expand Down Expand Up @@ -148,7 +149,7 @@ const slot1arg = { '@qclass': 'slot', index: 1 };

function resolutionOf(vpid, mode, targets) {
switch (mode) {
case 'presence':
case REMOTE_STYLE:
return {
type: 'fulfillToPresence',
promiseID: vpid,
Expand Down Expand Up @@ -517,7 +518,7 @@ async function doVatResolveCase23(t, which, mode, stalls) {
// resolution target. If that target is a Presence, we'll see a syscall,
// otherwise the vat handles it internally.

if (mode === 'presence') {
if (mode === REMOTE_STYLE) {
t.deepEqual(log.shift(), {
type: 'send',
targetSlot: target2,
Expand All @@ -538,7 +539,7 @@ async function doVatResolveCase23(t, which, mode, stalls) {
t.deepEqual(log, []);

// assert that the vat saw the local promise being resolved too
if (mode === 'presence') {
if (mode === REMOTE_STYLE) {
t.equal(resolutionOfP1.toString(), `[Presence ${target2}]`);
} else if (mode === 'data') {
t.equal(resolutionOfP1, 4);
Expand All @@ -556,7 +557,7 @@ async function doVatResolveCase23(t, which, mode, stalls) {

// uncomment this when debugging specific problems
// test.only(`XX`, async t => {
// await doVatResolveCase23(t, 2, 'presence', 0);
// await doVatResolveCase23(t, 2, REMOTE_STYLE, 0);
// });

for (const caseNum of [2, 3]) {
Expand Down Expand Up @@ -642,7 +643,7 @@ async function doVatResolveCase4(t, mode) {
t.deepEqual(log.shift(), { type: 'subscribe', target: expectedP3 });
t.deepEqual(log, []);

if (mode === 'presence') {
if (mode === REMOTE_STYLE) {
dispatch.notifyFulfillToPresence(p1, target2);
} else if (mode === 'local-object') {
dispatch.notifyFulfillToPresence(p1, rootA);
Expand Down Expand Up @@ -686,7 +687,7 @@ async function doVatResolveCase4(t, mode) {
target: expectedResultOfThree,
});

if (mode === 'presence') {
if (mode === REMOTE_STYLE) {
const expectedP6 = nextP();
t.deepEqual(log.shift(), {
type: 'send',
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/test/vat-exomessages.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* global harden */

import { REMOTE_STYLE } from '@agoric/marshal';

export function buildRootObject(_vatPowers, vatParameters) {
const other = harden({
something(arg) {
Expand All @@ -10,7 +12,7 @@ export function buildRootObject(_vatPowers, vatParameters) {
function behave(mode) {
if (mode === 'data') {
return 'a big hello to all intelligent lifeforms everywhere';
} else if (mode === 'presence') {
} else if (mode === REMOTE_STYLE) {
return other;
} else if (mode === 'reject') {
throw new Error('gratuitous error');
Expand Down
2 changes: 1 addition & 1 deletion packages/marshal/marshal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Nat from '@agoric/nat';
import { isPromise } from '@agoric/promise-kit';

// TODO: Use just 'remote' when we're willing to make a breaking change.
const REMOTE_STYLE = 'presence';
export const REMOTE_STYLE = 'presence';

// TODO, remove the mustPassByPresence alias when we make a breaking change.
// eslint-disable-next-line no-use-before-define
Expand Down
8 changes: 4 additions & 4 deletions packages/same-structure/src/sameStructure.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global harden */

import { sameValueZero, passStyleOf } from '@agoric/marshal';
import { sameValueZero, passStyleOf, REMOTE_STYLE } from '@agoric/marshal';
import { assert, details, q } from '@agoric/assert';

// Shim of Object.fromEntries from
Expand Down Expand Up @@ -58,7 +58,7 @@ function allComparable(passable) {
case 'number':
case 'symbol':
case 'bigint':
case 'presence':
case REMOTE_STYLE:
case 'copyError': {
return passable;
}
Expand Down Expand Up @@ -114,7 +114,7 @@ function sameStructure(left, right) {
case 'number':
case 'symbol':
case 'bigint':
case 'presence': {
case REMOTE_STYLE: {
return sameValueZero(left, right);
}
case 'copyRecord':
Expand Down Expand Up @@ -193,7 +193,7 @@ function mustBeSameStructureInternal(left, right, message, path) {
case 'number':
case 'symbol':
case 'bigint':
case 'presence': {
case REMOTE_STYLE: {
if (!sameValueZero(left, right)) {
complain('different');
}
Expand Down

0 comments on commit 55b3acc

Please sign in to comment.