Skip to content

Commit

Permalink
Merge branch 'markm-fix-async-flow-endowment-bug-2' into 9303-orchest…
Browse files Browse the repository at this point in the history
…rate-upgrade
  • Loading branch information
mhofman committed Sep 23, 2024
2 parents f2aacc4 + 5d5fc81 commit 0c0078d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
24 changes: 16 additions & 8 deletions packages/async-flow/src/equate.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ export const makeEquate = bijection => {
Fail`unequal ${g} vs ${h}`;
return;
}
if (bijection.has(g, h)) {
if (bijection.hasGuest(g) && bijection.guestToHost(g) === h) {
// Note that this can be true even when
// `bijection.hostToGuest(h) !== g`
// but only when the two guests represent the same host, as
// happens with unwrapping. That why we do this one-way test
// rather than the two way `bijection.has` test.
// Even in this one-way case, we have still satisfied
// the equate, so return.
return;
}
const gPassStyle = passStyleOf(g);
Expand All @@ -41,7 +48,8 @@ export const makeEquate = bijection => {
// TODO when we do, delete the `throw Fail` line and uncomment
// the two lines below it.
// We *do* support passing a guest wrapper of a hostVow back
// to the host, but that would be cause by `bijection.has` above.
// to the host, but that would be caught by `bijection.guestToHost`
// test above.
throw Fail`guest promises not yet passable`;
// `init` does not yet do enough checking anyway. For this case,
// we should ensure that h is a host wrapper of a guest promise,
Expand Down Expand Up @@ -92,10 +100,10 @@ export const makeEquate = bijection => {
case 'remotable': {
// Note that we can send a guest wrapping of a host remotable
// back to the host,
// but that should have already been taken care of by the
// `bijection.has` above.
// but that should have already been caught by the
// `bijection.guestToHost` above.
throw Fail`cannot yet send guest remotables to host ${g} vs ${h}`;
// `init` does not yet do enough checking anyway. For this case,
// `unwrapInit` does not yet do enough checking anyway. For this case,
// we should ensure that h is a host wrapper of a guest remotable,
// which is a wrapping we don't yet support.
// bijection.unwrapInit(g, h);
Expand All @@ -104,10 +112,10 @@ export const makeEquate = bijection => {
case 'promise': {
// Note that we can send a guest wrapping of a host promise
// (or vow) back to the host,
// but that should have already been taken care of by the
// `bijection.has` above.
// but that should have already been caught by the
// `bijection.guestToHost` above.
throw Fail`cannot yet send guest promises to host ${g} vs ${h}`;
// `init` does not yet do enough checking anyway. For this case,
// `unwrapInit` does not yet do enough checking anyway. For this case,
// we should ensure that h is a host wrapper of a guest promise,
// which is a wrapping we don't yet support.
// bijection.unwrapInit(g, h);
Expand Down
10 changes: 5 additions & 5 deletions packages/async-flow/test/equate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ const testEquate = (t, zone, showOnConsole = false) => {
bij.unwrapInit(g1, h1);
t.notThrows(() => equate(g1, h1));
t.throws(() => equate(g1, h2), {
message: 'internal: g->h "[Alleged: g1]" -> "[Vow]" vs "[Alleged: h1]"',
message: 'unequal passStyles "remotable" vs "tagged"',
});
t.throws(() => equate(g2, h1), {
message: 'internal: unexpected h->g "[Alleged: h1]" -> "[Alleged: g1]"',
message: 'unequal passStyles "promise" vs "remotable"',
});
bij.unwrapInit(g2, h2);
equate(g2, h2);

t.throws(() => equate(g1, h2), {
message: 'internal: g->h "[Alleged: g1]" -> "[Vow]" vs "[Alleged: h1]"',
message: 'unequal passStyles "remotable" vs "tagged"',
});
t.throws(() => equate(g2, h1), {
message: 'internal: g->h "[Promise]" -> "[Alleged: h1]" vs "[Vow]"',
message: 'unequal passStyles "promise" vs "remotable"',
});

equate(harden([g1, g2]), harden([h1, h2]));
t.throws(() => equate(harden([g1, g2]), harden([h1, h1])), {
message: '[1]: internal: g->h "[Promise]" -> "[Alleged: h1]" vs "[Vow]"',
message: '[1]: unequal passStyles "promise" vs "remotable"',
});

const gErr1 = harden(makeError(X`error ${'redacted message'}`, URIError));
Expand Down

0 comments on commit 0c0078d

Please sign in to comment.