Skip to content

Commit

Permalink
feat: getValues for sequence nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Dec 17, 2024
1 parent 3c63de2 commit b5698ce
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/internal/src/storage-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import { Fail } from '@endo/errors';
import { Far } from '@endo/far';
import { makeMarshal, Remotable } from '@endo/marshal';
import { unmarshalFromVstorage } from './marshal.js';
import { makeTracer } from './debug.js';
import { NonNullish } from './errors.js';
import { isStreamCell, makeChainStorageRoot } from './lib-chainStorage.js';
import { unmarshalFromVstorage } from './marshal.js';
import { bindAllMethods } from './method-tools.js';
import { eventLoopIteration } from './testing-utils.js';
import { NonNullish } from './errors.js';

/**
* @import {TotalMap} from './types.js';
Expand Down Expand Up @@ -190,10 +190,24 @@ export const makeFakeStorageKit = (rootPath, rootOptions) => {
},
);
const rootNode = makeChainStorageRoot(toStorage, rootPath, resolvedOptions);

/**
* Get the values at a sequence node
*
* @param {string} path
* @returns {unknown[]}
*/
const getValues = path => {
assert(resolvedOptions.sequence);
const wrapper = JSON.parse(data.get(path));
return wrapper.values;
};

return {
rootNode,
// eslint-disable-next-line object-shorthand
data: /** @type {Map<string, string>} */ (data),
getValues,
messages,
toStorage,
};
Expand Down

0 comments on commit b5698ce

Please sign in to comment.