Skip to content

Commit

Permalink
chore(liquidationVisibility): #4 add marshaller for comparing data fr…
Browse files Browse the repository at this point in the history
…om the vstorage
  • Loading branch information
anilhelvaci committed Feb 16, 2024
1 parent b441bff commit bdfaa79
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions packages/inter-protocol/test/liquidationVisibility/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<any>} 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));
};
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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: [
// [
Expand Down Expand Up @@ -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: [
// [
Expand All @@ -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(),
Expand Down
6 changes: 5 additions & 1 deletion packages/inter-protocol/test/liquidationVisibility/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const setupServices = async (
* ManualPriceAuthority,
* CollateralManager,
* chainStorage,
* board,
* ]}
*/
const [
Expand All @@ -163,6 +164,7 @@ export const setupServices = async (
priceAuthority,
aethCollateralManager,
chainStorage,
board,
] = await Promise.all([
E(consume.agoricNames).lookup('instance', 'VaultFactoryGovernor'),
vaultFactoryCreatorFacetP,
Expand All @@ -171,7 +173,8 @@ export const setupServices = async (
consume.auctioneerKit,
/** @type {Promise<ManualPriceAuthority>} */ (consume.priceAuthority),
E(aethVaultManagerP).getPublicFacet(),
space.consume.chainStorage,
consume.chainStorage,
consume.board,
]);
trace(t, 'pa', {
governorInstance,
Expand Down Expand Up @@ -209,6 +212,7 @@ export const setupServices = async (
priceAuthorityAdmin,
aethTestPriceAuthority,
chainStorage,
board,
};
};

Expand Down

0 comments on commit bdfaa79

Please sign in to comment.