Skip to content

test coverage over bundles#11100

Merged
mergify[bot] merged 5 commits into
masterfrom
1817-bundle-coverage
Apr 4, 2025
Merged

test coverage over bundles#11100
mergify[bot] merged 5 commits into
masterfrom
1817-bundle-coverage

Conversation

@turadg

@turadg turadg commented Mar 10, 2025

Copy link
Copy Markdown
Member

closes: #1817

Description

Code coverage for bundles in unit tests!

Security Considerations

none

Scaling Considerations

none

Documentation Considerations

none

Testing Considerations

per se

Upgrade Considerations

none

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 10, 2025

Copy link
Copy Markdown

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: ea9dcce
Status: ✅  Deploy successful!
Preview URL: https://fe9fd11d.agoric-sdk.pages.dev
Branch Preview URL: https://1817-bundle-coverage.agoric-sdk.pages.dev

View logs

@turadg turadg force-pushed the 1817-bundle-coverage branch from 608f963 to 6f954ac Compare March 10, 2025 23:58
Comment thread packages/zoe/tools/setup-zoe.js Outdated
Comment thread packages/zoe/tools/setup-zoe.js
Comment thread packages/zoe/tools/setup-zoe.js Outdated
Comment thread packages/zoe/tools/setup-zoe.js Outdated
moduleFormat: 'test',
[Symbol.for('exports')]: exports,
});
id = `b1-test-exports-${Math.random()}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, this will also ensure that bundleAndInstall is only used from the privileged start compartment.

@mhofman

mhofman commented Mar 11, 2025

Copy link
Copy Markdown
Member

Draft until this doesn't have to patch Endo (next Endo rev )

I'd like to emphasize this one. The next Endo version introduces a revamped bundler, and maintaining coverage through the endo sync will be invaluable for @kriskowal

Comment on lines +79 to +81
// Copy all the properties so this object can be hardened.
const exports = { ...pathOrExports };
return bundleTestExports(exports);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone harden the returned bundle?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my question is can we get away with dropping the spread if no code would harden the bundle.

If there is such code, then my question for @kriskowal is whether bundleTestExports should create a getter for the Symbol.for('exports') property instead of a data property so that it's compatible with hardening? That should be a compatible change. It will not make the bundle passable but that is just not possible with this design.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this doesn't hurt, and is probably helpful (no-one should expect a live binding here), I'm ok with keeping the spread here.

Comment thread patches/@endo+import-bundle+1.3.3.patch Outdated
@turadg turadg force-pushed the 1817-bundle-coverage branch 2 times, most recently from addd80a to 64eb491 Compare April 2, 2025 23:02
@turadg turadg marked this pull request as ready for review April 3, 2025 14:39
@turadg turadg requested a review from a team as a code owner April 3, 2025 14:39
@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label Apr 3, 2025
@turadg turadg force-pushed the 1817-bundle-coverage branch from 64eb491 to 65c6cf4 Compare April 3, 2025 17:47
@turadg turadg requested review from Chris-Hibbert and mhofman April 3, 2025 17:47
@turadg turadg force-pushed the 1817-bundle-coverage branch from 65c6cf4 to 6487f51 Compare April 3, 2025 17:51

@kriskowal kriskowal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turadg It’s fantastic we can get coverage analysis for contracts this way. Do you feel that, after this change, we still have an adequate canary for changes the contract that will only be evident if it’s bundled, like runtime censorship errors?

I’ve filed a work item for Endo, to make the bundler do a SES censorship simulation after transforms, such that the act of bundling in CI would detect that failure mode without having to execute the bundle.
endojs/endo#2756

That might be enough.

@turadg

turadg commented Apr 3, 2025

Copy link
Copy Markdown
Member Author

Do you feel that, after this change, we still have an adequate canary for changes the contract that will only be evident if it’s bundled, like runtime censorship errors?

Yes, this is just letting us integrate with a fake Zoe and we have a more integration levels above this.

  1. Boostrap/RunUtils with a testing SwingSet, but all the vats and real bundles
  2. a3p-integration with a real agoric chain

@turadg turadg requested a review from kriskowal April 3, 2025 22:15
@turadg turadg marked this pull request as draft April 4, 2025 00:13
@mhofman

mhofman commented Apr 4, 2025

Copy link
Copy Markdown
Member

Do you feel that, after this change, we still have an adequate canary for changes the contract that will only be evident if it’s bundled, like runtime censorship errors?

Yes, this is just letting us integrate with a fake Zoe and we have a more integration levels above this.

Catching early would still be better, so endojs/endo#2756 would be a nice to have

Comment thread packages/swing-store/src/bundleStore.js Outdated
Comment thread packages/swing-store/test/bundles.test.js Outdated
Comment thread packages/swing-store/test/bundles.test.js Outdated
Comment thread packages/zoe/tools/fakeVatAdmin.js Outdated
Comment on lines +79 to +81
// Copy all the properties so this object can be hardened.
const exports = { ...pathOrExports };
return bundleTestExports(exports);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my question is can we get away with dropping the spread if no code would harden the bundle.

If there is such code, then my question for @kriskowal is whether bundleTestExports should create a getter for the Symbol.for('exports') property instead of a data property so that it's compatible with hardening? That should be a compatible change. It will not make the bundle passable but that is just not possible with this design.

@turadg turadg force-pushed the 1817-bundle-coverage branch from 6487f51 to ea9dcce Compare April 4, 2025 16:37
@turadg turadg marked this pull request as ready for review April 4, 2025 17:18
@turadg turadg requested a review from mhofman April 4, 2025 17:18

@mhofman mhofman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for getting us this coverage!

Comment on lines +79 to +81
// Copy all the properties so this object can be hardened.
const exports = { ...pathOrExports };
return bundleTestExports(exports);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this doesn't hurt, and is probably helpful (no-one should expect a live binding here), I'm ok with keeping the spread here.

@mergify

mergify Bot commented Apr 4, 2025

Copy link
Copy Markdown
Contributor

This pull request has been removed from the queue for the following reason: checks failed.

The merge conditions cannot be satisfied due to failing checks:

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

import { commonSetup } from '../supports.js';

const dirname = path.dirname(new URL(import.meta.url).pathname);
import * as contractExports from '../../src/examples/stake-ica.contract.js';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't import path from 'path'; get dropped here and in most, if not all of these files?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because unused imports aren't automatically cleaned up. It's passing CI because there's no lint rule for it.

I would expect no-unused-vars to but it's not. typescript-eslint/no-unused-vars works but isn't worth the effort to adopt rn, imo. Maybe updating eslint will fix the built in one.

noUsedLocals in tsconfig would catch it but make it harder to work with jsdoc @import.

@mergify mergify Bot merged commit 3190128 into master Apr 4, 2025
@mergify mergify Bot deleted the 1817-bundle-coverage branch April 4, 2025 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge:rebase Automatically rebase updates, then merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

coverage analysis of bundled code

4 participants