Skip to content

Commit

Permalink
chore(liquidationVisibility): make sure assertStorageData works
Browse files Browse the repository at this point in the history
  • Loading branch information
anilhelvaci committed Jan 24, 2024
1 parent 59e155b commit 1a17dd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,9 @@ 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(value, JSON.stringify(expectedCapData));
t.deepEqual(value, expected);
};
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import { E, Far } from '@endo/far';
import { makeImportContext } from '@agoric/smart-wallet/src/marshal-contexts.js';
import { makeScalarBigMapStore } from '@agoric/vat-data';
import { defaultMarshaller } from '@agoric/internal/src/storage-test-utils.js';
import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js';
import { AmountMath, makeIssuerKit } from '@agoric/ertp';
import { makeMockChainStorageRoot } from '../supports.js';
import { assertNodeInStorage, assertStorageData } from './assertions.js';

const {
fromBoard: { toCapData },
} = makeImportContext();

const writeToStorage = async (storageNode, data) => {
await E(storageNode).setValue(
JSON.stringify(toCapData(JSON.stringify(data))),
JSON.stringify(defaultMarshaller.toCapData(harden(data))),
);
};

Expand All @@ -38,15 +36,18 @@ test('storage-node-created', async t => {

test('storage-assert-data', async t => {
const storageRoot = makeMockChainStorageRoot();
const moolaKit = makeIssuerKit('Moola');

const testNode = await E(storageRoot).makeChildNode('dummyNode');
await writeToStorage(testNode, { dummy: 'foo' });
await writeToStorage(testNode, {
moolaForReserve: AmountMath.make(moolaKit.brand, 100n),
});

await assertStorageData({
t,
path: 'dummyNode',
storageRoot,
board: {},
expected: { dummy: 'foo' },
expected: { moolaForReserve: AmountMath.make(moolaKit.brand, 100n) },
});
});

Expand Down Expand Up @@ -84,7 +85,7 @@ test('map-test-auction', async t => {

const preAuction = [...vaultData.entries()].map(([vault, data]) => [
vault.getId(),
{ ...data, phase: vault.getPhase() }
{ ...data, phase: vault.getPhase() },
]);
t.log(preAuction);

Expand Down

0 comments on commit 1a17dd4

Please sign in to comment.