Skip to content

Commit

Permalink
fix: represent promise resolution just like message delivery
Browse files Browse the repository at this point in the history
 - don't add { text} on .Got so that vat,turn is shown
 - add ko, kp, body.length detail to .Send
  • Loading branch information
dckc committed Oct 26, 2021
1 parent 5cff624 commit 564cbf7
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions packages/SwingSet/tools/slog-to-causeway.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const makeCausewayFormatter = () => {
class: [LogClass.Got, LogClass.Event],
anchor,
message,
text,
trace: { calls: [{ name: text, source: '@@' }] },
}),
/**
Expand Down Expand Up @@ -182,7 +181,7 @@ async function* slogToCauseway(entries) {
const got = new Map();
/** @type { Map<string, SlogVatEntry & { rejected: boolean }> } */
const resolved = new Map();
/** @type { Map<string, SlogVatEntry> } */
/** @type { Map<string, SlogDeliveryEntry> } */
const notified = new Map();

for await (const entry of entries) {
Expand Down Expand Up @@ -282,22 +281,23 @@ async function* slogToCauseway(entries) {
// send / sent
const { ksc } = src;
if (ksc[0] !== 'send') throw TypeError();
const [_, _t, { method }] = ksc;
yield dest.makeSent(anchor(src), kp, method);
const [
_,
ko,
{
method,
args: { body },
},
] = ksc;
const label = `${kp} <- ${ko}.${method}(${body.length})`;
yield dest.makeSent(anchor(src), kp, label);

// message / got
if (got.has(kp)) {
const target = got.get(kp);
if (target.kd[0] !== 'message') throw TypeError();
const [
_0,
_1,
{
args: { body },
method: m,
},
] = target.kd;
yield dest.makeGot(anchor(target), kp, `${m}(${body.length})`);
const [_0, t, { method: m }] = target.kd;
yield dest.makeGot(anchor(target), kp, `${t}.${m}(${body.length})`);
} else {
console.warn('no Got for', kp);
// TODO: check for missing data in the other direction?
Expand All @@ -306,13 +306,12 @@ async function* slogToCauseway(entries) {

for (const [rkp, src] of resolved) {
// resolve / resolved
yield src.rejected
? dest.makeRejected(anchor(src), rkp)
: dest.makeFulfilled(anchor(src), rkp);
const status = src.rejected ? 'rejected' : 'resolved';
yield dest.makeSent(anchor(src), rkp, `${status} ${rkp}`);
// deliver / returned
if (notified.has(rkp)) {
const target = notified.get(rkp);
yield dest.makeSentIf(anchor(target), rkp, rkp);
yield dest.makeGot(anchor(target), rkp, rkp);
} else {
console.warn('no notified for', rkp);
// TODO: check for missing data in the other direction?
Expand Down

0 comments on commit 564cbf7

Please sign in to comment.