-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move benchmarkerator and some test support code out of the boot
package
#8421
Conversation
73ed138
to
57a8ba1
Compare
packages/test-support/package.json
Outdated
{ | ||
"name": "@agoric/test-support", | ||
"version": "0.1.0", | ||
"description": "Support libraries for testing on chain", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name test-support
sounds much broader than that.
these also don't test on a chain, right? Just a swingset.
I request that you leave these in boot
and export them under its tools
. @agoric/benchmark
can import them from there. I believe that's what you proposed and I supported in #8312 (comment)
If that complicates some other plans, let's chat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this would complicate other plans. There's little in those files that specifically pertains to the bootstrap tests, but they do contain the current best versions of some bits that are widely replicated throughout our suite of tests in a copy-paste-edit reuse with minor changes pattern. It's our hope to start cleaning that stuff up using common implementations of commonly used test boilerplate, which will want to draw on a common package for that stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@turadg and I had a long chat about this. He feels quite strongly that the stuff about setting up a mock chain really belongs in the boot
package since that's really what that package is all about. I'm not 100% sure I agree, but on the other hand I don't really have a very good counterargument either. We did agree that if the stuff is being used from the outside the package it does not belong buried layers down in the test
directory. Instead, we're putting the support infra into the tools
directory. The pieces of support code that I had flagged as being much more widely useful beyond just the bootstrap tests pertain to convenience sugaring for tests invoking the controller. This stuff has been broken out into a separate run-utils
module and placed into SwingSet/tools
, where it will be available to tests that are using SwingSet but not entraining the rest of the chain machinery. The test-support
package is now gone. I will revise the PR title and descriptive commentary to match this resolution.
I think we still have some confusion to sort out with respect to the somewhat conflicted meaning of the tools
directory, as we have used it to hold both "ancillary executables that are useful in a standalone mode" as well as "utility code that is outside the supported package APIs", sometimes even within the scope of a single package. However, this PR is not the place to resolve that.
boot
package
boot
packageboot
package
46093ff
to
e19d95f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting aside benchmarkerator interface questions for now, I still have some suggestions.
EV.get = presence => | ||
new Proxy(harden({}), { | ||
get: (_t, pathElement, _rx) => | ||
queueAndRun(() => | ||
controller.queueToVatRoot('bootstrap', 'awaitVatObject', [ | ||
presence, | ||
[pathElement], | ||
]), | ||
), | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumption of a bootstrap-vat awaitVatObject
method is giving off some bad vibes; is there a way to do it with just the controller? Untested idea:
EV.get = presence => | |
new Proxy(harden({}), { | |
get: (_t, pathElement, _rx) => | |
queueAndRun(() => | |
controller.queueToVatRoot('bootstrap', 'awaitVatObject', [ | |
presence, | |
[pathElement], | |
]), | |
), | |
}); | |
/** | |
* Derives a value suitable for immediate interaction from a vat-originating value: | |
* the fulfillment value of a fulfilled promise, or | |
* the rejection value of a rejected promise, or | |
* a non-promise value itself. | |
* If `value` is an unsettled promise, a synchronous error will be thrown. | |
* | |
* @param {any} presence | |
* @returns {{status: 'fulfilled' | 'rejected' | undefined, value: any}} | |
*/ | |
const presenceSettlement = (presence, errPrefix = '') => { | |
if (passStyleOf(presence) === 'promise') { | |
const kpid = krefOf(presence); | |
const status = controller.kpStatus(kpid); | |
switch (status) { | |
case 'fulfilled': | |
// falls through | |
case 'rejected': | |
return { status, value: kunser(controller.kpResolution(kpid)) }; | |
case 'unresolved': | |
throw Fail(`${b(errPrefix)}unsettled value for ${q(kpid)}`; | |
default: | |
throw Fail`${b(errPrefix)}unknown promise status ${q(kpid)} ${q(status)}`; | |
} | |
} | |
return { status: undefined, value: presence }; | |
}; | |
EV.get = presence => | |
new Proxy(harden({}), { | |
get: async (_t, key, _rx) => { | |
await queueAndRun(() => {}, true); | |
const errPrefix = '[EV.get] '; | |
const { status, value: obj } = presenceSettlement(presence, errPrefix); | |
if (status === 'rejected') { | |
throw obj; | |
} else if (passStyleOf(obj) === 'remotable') { | |
throw Fail`${b(errPrefix)}Cannot read properties from remotable ${q(krefOf(obj))}`); | |
} | |
const { status: propStatus, value } = presenceSettlement(obj[key], errPrefix); | |
if (propStatus === 'rejected') { | |
throw value; | |
} | |
return value; | |
}, | |
}); |
e19d95f
to
20f587d
Compare
df4e1de
to
21249ad
Compare
172a839
to
0fa53ac
Compare
db1849c
to
21b185f
Compare
984c49b
to
ac08b3e
Compare
bb821bf
to
1995bde
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.. my humblest apologies for taking so long. One question about the dependency changes in boot
.. if those aren't necessary, I'd like to remove them (and of course if they are necessary, I just want to understand why).
Lemme know if I can help with rebasing this to bring it up-to-date and fix the bitrot-induced merge conflicts.
@@ -19,9 +18,17 @@ | |||
"author": "Agoric", | |||
"license": "Apache-2.0", | |||
"dependencies": { | |||
"@agoric/assert": "^0.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these need promotion to full dependencies, given that the benchmark (bench-vaults-performance
) was moved out of this package? I kind of expect they'd be dependencies of the new packages/benchmark
, but not this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alas, a bunch of stuff that I wanted to move into packages/benchmark
(and which were so relocated in the original version of this PR) are just moved to the tools
directory of this package. There was some controversy about where various things belong, and the easiest immediate resolution was to leave them here. I would like to revisit this in a future PR, but I don't want to hold up landing this functionality for the resolution of this matter.
1995bde
to
3f9f8ba
Compare
This moves files around, creating two new packages:
benchmark
, containing the Benchmarkerator benchmarking framework, andtest-support
, containing support code that is used by both tests (mostly inboot
) and Benchmarkerator. Code which uses the code that was moved has had the relevantimport
statements updated accordingly.This completes work that was suggested by reviews to #8312 but which we chose to defer to its own separate PR for reasons of clarity and smoothness of transition to the new code state.
All of this is in support of #8327