Skip to content

Commit

Permalink
fix(bundle-source): Recognize default metadata (#2379)
Browse files Browse the repository at this point in the history
Refs: Agoric/agoric-sdk#9735

## Description

Agoric SDK integration revealed a regression in the
`bundle-source/cache.js` implementation, where the validator didn’t
recognize default metadata.

### Security Considerations

None.

### Scaling Considerations

None.

### Documentation Considerations

None.

### Testing Considerations

This change includes a regression test.

### Compatibility Considerations

Restores backward compatibility.

### Upgrade Considerations

None.
  • Loading branch information
kriskowal authored Jul 24, 2024
2 parents 655a74c + 5ee3a9b commit d8ffbfc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/bundle-source/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { makePromiseKit } from '@endo/promise-kit';
import { makeReadPowers } from '@endo/compartment-mapper/node-powers.js';

import bundleSource from './src/index.js';
import bundleSource, { DEFAULT_MODULE_FORMAT } from './src/bundle-source.js';
import { makeFileReader, makeAtomicFileWriter } from './src/fs.js';

const { Fail, quote: q } = assert;
Expand Down Expand Up @@ -167,8 +167,8 @@ export const makeBundleCache = (wr, cwd, readPowers, opts) => {
) => {
await null;
const {
noTransforms: expectedNoTransforms,
format: expectedFormat,
noTransforms: expectedNoTransforms = false,
format: expectedFormat = DEFAULT_MODULE_FORMAT,
conditions: expectedConditions = [],
} = options;
expectedConditions.sort();
Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-source/src/bundle-source.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-check
const DEFAULT_MODULE_FORMAT = 'endoZipBase64';
export const DEFAULT_MODULE_FORMAT = 'endoZipBase64';
export const SUPPORTED_FORMATS = [
'getExport',
'nestedEvaluate',
Expand Down
18 changes: 18 additions & 0 deletions packages/bundle-source/test/cache.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import url from 'url';
import test from '@endo/ses-ava/prepare-endo.js';
import { makeNodeBundleCache } from '../cache.js';

test('cache can capture and verify metadata', async t => {
const dest = url.fileURLToPath(new URL('../bundles/', import.meta.url));
const entry = url.fileURLToPath(
new URL('../demo/meaning.js', import.meta.url),
);
const cache = await makeNodeBundleCache(
dest,
{},
specifier => import(specifier),
);
await cache.validateOrAdd(entry, 'cache-test-meaning', t.log);
await cache.validate('cache-test-meaning', undefined, t.log);
t.pass();
});

0 comments on commit d8ffbfc

Please sign in to comment.