From bdfaa792c938edb6250d58d7005d5c865932e7d0 Mon Sep 17 00:00:00 2001 From: anilhelvaci Date: Tue, 23 Jan 2024 11:35:21 +0300 Subject: [PATCH] chore(liquidationVisibility): #4 add marshaller for comparing data from the vstorage --- .../test/liquidationVisibility/assertions.js | 16 ++++++++++++++-- .../test-liquidationVisibility.js | 4 ++++ .../test/liquidationVisibility/tools.js | 6 +++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/inter-protocol/test/liquidationVisibility/assertions.js b/packages/inter-protocol/test/liquidationVisibility/assertions.js index 2102de65f18..e2014000ebb 100644 --- a/packages/inter-protocol/test/liquidationVisibility/assertions.js +++ b/packages/inter-protocol/test/liquidationVisibility/assertions.js @@ -9,6 +9,7 @@ import { import { TimeMath } from '@agoric/time'; import { headValue } from '../supports.js'; import { getDataFromVstorage } from './tools.js'; +import exp from "constants"; export const assertBidderPayout = async ( t, @@ -246,8 +247,19 @@ export const assertLiqNodeForAuctionCreated = async ({ }); }; -export const assertStorageData = async ({ t, path, storageRoot, expected }) => { +export const assertStorageData = async ({ + t, + path, + storageRoot, + board, + expected, +}) => { + /** @typedef {import('@endo/marshal').Marshal} Marshal */ + /** @type Marshal */ + const marshaller = await E(board).getReadonlyMarshaller(); + const expectedCapData = marshaller.toCapData(expected); + /** @type Array */ const [[, value]] = await getDataFromVstorage(storageRoot, path); - t.deepEqual(JSON.parse(value), expected); + t.deepEqual(value, JSON.stringify(expectedCapData)); }; diff --git a/packages/inter-protocol/test/liquidationVisibility/test-liquidationVisibility.js b/packages/inter-protocol/test/liquidationVisibility/test-liquidationVisibility.js index 97ed6885e9c..4d4c62791d7 100644 --- a/packages/inter-protocol/test/liquidationVisibility/test-liquidationVisibility.js +++ b/packages/inter-protocol/test/liquidationVisibility/test-liquidationVisibility.js @@ -232,6 +232,7 @@ test('liq-result-scenario-2', async t => { reserveKit: { reserveCreatorFacet, reservePublicFacet }, auctioneerKit, chainStorage, + board, } = services; await E(reserveCreatorFacet).addIssuer(aeth.issuer, 'Aeth'); @@ -361,6 +362,7 @@ test('liq-result-scenario-2', async t => { // await assertStorageData({ // t, // storageRoot: chainStorage, + // board, // path: `vaultFactory.managers.manager0.liquidations.${now1}.preAuction`, // now1 is the nominal start time // expected: [ // [ @@ -409,6 +411,7 @@ test('liq-result-scenario-2', async t => { // await assertStorageData({ // t, // storageRoot: chainStorage, + // board, // path: `vaultFactory.managers.manager0.liquidations.${now1}.postAuction`, // now1 is the nominal start time // expected: [ // [ @@ -426,6 +429,7 @@ test('liq-result-scenario-2', async t => { // await assertStorageData({ // t, // storageRoot: chainStorage, + // board, // path: `vaultFactory.managers.manager0.liquidations.${now1}.auctionResult`, // now1 is the nominal start time // expected: { // collateralForReserve: aeth.makeEmpty(), diff --git a/packages/inter-protocol/test/liquidationVisibility/tools.js b/packages/inter-protocol/test/liquidationVisibility/tools.js index 13d8f06bc3e..da576f86acc 100644 --- a/packages/inter-protocol/test/liquidationVisibility/tools.js +++ b/packages/inter-protocol/test/liquidationVisibility/tools.js @@ -152,6 +152,7 @@ export const setupServices = async ( * ManualPriceAuthority, * CollateralManager, * chainStorage, + * board, * ]} */ const [ @@ -163,6 +164,7 @@ export const setupServices = async ( priceAuthority, aethCollateralManager, chainStorage, + board, ] = await Promise.all([ E(consume.agoricNames).lookup('instance', 'VaultFactoryGovernor'), vaultFactoryCreatorFacetP, @@ -171,7 +173,8 @@ export const setupServices = async ( consume.auctioneerKit, /** @type {Promise} */ (consume.priceAuthority), E(aethVaultManagerP).getPublicFacet(), - space.consume.chainStorage, + consume.chainStorage, + consume.board, ]); trace(t, 'pa', { governorInstance, @@ -209,6 +212,7 @@ export const setupServices = async ( priceAuthorityAdmin, aethTestPriceAuthority, chainStorage, + board, }; };