Skip to content

Commit

Permalink
Use Nat(Number()) when retrieving IDs. Test vat with activity.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Jan 27, 2020
1 parent e285f94 commit 9dab5a6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
16 changes: 10 additions & 6 deletions packages/SwingSet/src/kernel/state/vatKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,19 @@ export function makeVatKeeper(
}

function vatStats() {
const objectCount = storage.get(`${vatID}.o.nextID`) - FIRST_OBJECT_ID;
const promiseCount = storage.get(`${vatID}.p.nextID`) - FIRST_PROMISE_ID;
const deviceCount = storage.get(`${vatID}.d.nextID`) - FIRST_DEVICE_ID;
function getStringAsNat(ostr) {
return Nat(Number(storage.get(ostr)));
}

const objectCount = getStringAsNat(`${vatID}.o.nextID`) - FIRST_OBJECT_ID;
const promiseCount = getStringAsNat(`${vatID}.p.nextID`) - FIRST_PROMISE_ID;
const deviceCount = getStringAsNat(`${vatID}.d.nextID`) - FIRST_DEVICE_ID;
const transcriptCount =
storage.get(`${vatID}.t.nextID`) - FIRST_TRANSCRIPT_ID;
return harden({
objectCount: Nat(Number(objectCount)),
promiseCount: Nat(Number(promiseCount)),
deviceCount: Nat(Number(deviceCount)),
objectCount: Nat(objectCount),
promiseCount: Nat(promiseCount),
deviceCount: Nat(deviceCount),
transcriptCount: Nat(Number(transcriptCount)),
});
}
Expand Down
5 changes: 4 additions & 1 deletion packages/SwingSet/test/vat-admin/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export default function setup(syscall, state, helpers) {
const vatAdminSvc = await E(vats.vatAdmin).createVatAdminService(
devices.vatAdmin,
);
const { adminNode } = await E(vatAdminSvc).createVat(src);
const { root, adminNode } = await E(vatAdminSvc).createVat(src);
log(await E(adminNode).adminData());
const c = E(root).createRcvr(1);
log(await E(c).increment(3));
log(await E(adminNode).adminData());
return;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/SwingSet/test/vat-admin/test-innerVat.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ async function testGetVatStats(t, withSES) {
t.deepEqual(c.dump().log, [
'starting stats test',
'{"objectCount":0,"promiseCount":0,"deviceCount":0,"transcriptCount":0}',
'4',
'{"objectCount":0,"promiseCount":2,"deviceCount":0,"transcriptCount":2}',
]);
await c.run();
t.end();
}

Expand Down

0 comments on commit 9dab5a6

Please sign in to comment.