-
Notifications
You must be signed in to change notification settings - Fork 207
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
Impedence mismatch between swingset-runner and Zoe tests #1194
Comments
@warner @katelynsills @Chris-Hibbert -- A note on the contortions I went through to run the Zoe test code outside the test framework. Nothing actionable for you here, but if you have thoughts or reactions I wouldn't mind hearing them. |
@FUDCo thanks so much for writing this up. It was a good guide for upgrading to newer versions of |
Thanks for the write-up. In general, I'm supportive of changes to the source code that makes them more testable. If we can move in the direction of Dependency Injection, that makes the code be better factored in general, and is also a huge win for testing. I think it would be good if we generally wrote our imports to rely more on package paths rather than relative location of source code. This makes more code more independent of refactorings in distant places. Most of the time references from the test code to source files would be improved by making this kind of change. Driving the tests from config files rather than passing parameter through a circuitous vat-creation path would have a similar effect. Changing the way logs are created so the tests are written with the same invocation and can be re-used for performance tests or other things is all to the good. It would be fine to change the test code once so people who want to re-use it don't have to make distinct changes multiple times. |
* refactor: refactor Zoe to use seat objects rather than offerHandles * refactor: update seat namings, add seats.md to docs with diagrams * refactor: move up init of instance, instanceAdmin * fix: minting allocations in zcf (#1382) * refactor: tests for sellItems and mintAndSellNFT pass - need to be reworked for new synchronous mint still * refactor: fix jsdoc to recognize makeZCFMint as property * fix: register the new minty issuer on zcf side (#1392) * refactor: redirect main in package.json * refactor: apply zoe renames - `getInviteIssuer` to `getInvitationIssuer` - `inviteDesc` to `description` * fix: solve some easy types * fix: use local amountMath (#1408) * fix(swingset): check promise resolution table during comms.inbound refs #1400 * refactor: multipoolAutoswap * refactor: remove BrandName parameter from ERTP types * feat: add the ability for a contract to get a synchronous seat zcf.addEmptySeat() would return a zcfSeat that the contract could use to hold allocations. untested * refactor: cleanup synchronous ZCF seat creation drop keyword parameter in addEmptySeat() extract makeZoeSeatAdminKit, use it for emptySeat, too. rename zcf seat construction to use 'Kit' * refactor: use updateFromNotifier from library * refactor: add types to reveal the wallet changes needed for Zoe * refactor: post review cleanups; mostly type info improved type annotations rename makeEmptySeat to makeOfferlessSeat don't return the zcfSeatAdmin to the contract * fix: make Zoe typesafe again * refactor: bring autoswap up to date on the new Zoe spike branch Based on the synchronous seat work. The unit tests for autoswap pass. I haven't yet done the swingset tests. * fix: update autoswap from addEmptySeat() to makeEmptySeatKit() * chore: add publicFacet and instance to MakeInstanceResult (#1418) * chore: fix typing of MakeInstanceResult * chore: add hasExited, getNotifier to UserSeat * Update more unit tests (#1422) * chore: update tests * chore: finish automaticRefund tests * chore: update barterExchange and brokenContract tests. Small changes to Zoe and types (#1427) * fix: make the wallet pass unit tests * refactor: clear up some more types * fix(dapp-svelte-wallet): minor cleanups * fix: always use the published wallet payment facet * test: invite -> creatorInvitation * fix: noticed bug in exit code while doing (chore: update coveredCall tests) (#1428) * chore: update tests for escrowToVote, grifter, multipoolAutoswap, publicAuction, sellTickets, simpleExchange * chore: make more unit tests pass, linting * chore: update tests for escrowToVote, grifter, multipoolAutoswap, publicAuction, sellTickets, simpleExchange (#1430) * fix: minor wallet cleanup * test: fix all the zoe swingSet tests * chore: find usages of .getBrand() and make sure that brand and issuer match (#1443) * refactor: rename makeInstance to startInstance (#1444) * test(dapp-svelte-wallet): fix test log for determinism The prior golden test log relied on a race between deposit and the new purse values. Correct that ambiguity. * fix: generate unique petnames, and use them * fix: only uniquify suffixes for petnames that are actually paths * chore: fix brokenContracts tests, zoe-metering tests, skip ZoeHelpers tests for now (need to be rewritten entirely, I think using the real ZCF, not a mock) (#1435) * fix: minor typing issue * chore: clean up vestiges of encouragement dapp * chore: remove contract/deploy.js from the wallet spec * refactor: prevent the same seat being an argument multiple times in reallocate (#1452) * refactor: remove makeEmptyOffer from zoeHelpers, use zcf.makeEmptySeatKit instead (#1451) * refactor: move issuerKeywordRecord and brandKeywordRecord to terms (#1459) * refactor: add issuers, brands, maths to terms * refactor: rename NonCustomTerms in types * chore: address PR comments * refactor: move AmountMath from names to Kinds; easier local creation Issuer no longer has getAmountMath(), instead exports makeLocalAmountMath(); added an enum for the three kinds of AmountMath getAmountMathHelpersName replaced with getAmountMathKind Add MathKind as an enum containing the legal values of AmountKind Made progress on correct typing * fix: review suggestions and merge conflicts. * fix: clear up the types * chore: export all of ERTP from index.js. Update all imports. A few other review-suggested cleanups * refactor: add Zoe methods for getting assured invitation values The type declarations seem to work. * refactor: drop unnecessary invitations in the metering tests. * refactor: review of the following files in the form of code changes (#1475) * refactor: review of: packages/zoe/src/contracts/autoswap.js packages/zoe/src/contracts/barterExchange.js packages/zoe/src/contracts/simpleExchange.js packages/zoe/test/swingsetTests/zoe/test-zoe.js packages/zoe/test/swingsetTests/zoe/vat-alice.js packages/zoe/test/swingsetTests/zoe/vat-bob.js packages/zoe/test/swingsetTests/zoe/vat-carol.js packages/zoe/test/swingsetTests/zoe/vat-dave.js packages/zoe/test/swingsetTests/zoe/vat-zoe.js packages/zoe/test/unitTests/contracts/test-autoswap.js packages/zoe/test/unitTests/contracts/test-barter.js packages/zoe/test/unitTests/contracts/test-simpleExchange.js packages/zoe/test/unitTests/installFromSource.js packages/zoe/test/unitTests/setupBasicMints.js packages/zoe/test/unitTests/setupMixedMints.js packages/zoe/test/unitTests/setupNonFungibleMints.js packages/zoe/test/unitTests/test-cleanProposal.js packages/zoe/test/unitTests/test-offerSafety.js packages/zoe/test/unitTests/test-rightsConservation.js packages/zoe/test/zoeTestHelpers.js in PR form rather than comments * fix: fix dapp-svelte-wallet issues * fix: lint-fix * fix: fix errors * chore: review in the form of PR w/ changes (#1484) * fix: resolve semantic merge conflict The `@agoric/zoe/src/contractFacet` moved to: `@agoric/zoe/src/contractFacet/contractFacet.js`. * refactor: add typings for some sample Zoe contracts * refactor: loosen unknown typings * chore: expose '@agoric/zoe/contractFacet' * docs: address review comments * test(swingset-runner): update demo/exchangeBenchmark for new Zoe * chore: follow #1194: take fresh copy of zoeTests from zoe * fix: don't use monorepo-relative paths to @agoric/zoe * chore: complete #1194 Problem 1 * fix: zcf is unused, so prepend an underscore lint fix * chore: complete #1194 Problem 2b * chore: complete #1194 Problem 2c * chore: move global harden declaration to package.json * fix: undo invalid Zoe change * fix: minor cleanups * chore: rename userSeat.exit() to tryExit() (#1493) * chore: rename userSeat.exit() to tryExit() * Update packages/zoe/src/objArrayConversion.js Co-authored-by: Mark S. Miller <erights@users.noreply.github.com> * chore: address small PR comments * chore: remove objToArray because unused * chore: move cleanProposal.js (#1495) * chore: remove more unused functions * chore: remove escrowAndAllocateTo * chore: remove unused type * chore: rename invite to invitation, forever more. begone! * Use flatMap Co-authored-by: Mark S. Miller <erights@users.noreply.github.com> * chore: change areRightsConserved to assertRightsConserved * chore: address PR comments * fix: reintroduce makeZoe's zcfBundleName argument; lost in merge * Update packages/zoe/src/zoeService/zoeSeat.js Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com> * chore: address PR comments * chore: fix the lint * chore: address PR comments about kick out messages (#1529) * chore: address PR comments about exit behavior (#1527) * chore: address PR comments about exit behavior * Update packages/zoe/src/zoeService/zoeSeat.js Co-authored-by: Mark S. Miller <erights@users.noreply.github.com> * chore: fix lint, slight errors from merge Co-authored-by: Mark S. Miller <erights@users.noreply.github.com> Co-authored-by: Mark S. Miller <erights@users.noreply.github.com> Co-authored-by: Dean Tribble <tribble@agoric.com> Co-authored-by: Michael FIG <mfig@agoric.com> Co-authored-by: Brian Warner <warner@lothar.com> Co-authored-by: Chris Hibbert <hibbert@agoric.com> Co-authored-by: Chris Hibbert <Chris-Hibbert@users.noreply.github.com>
A note on adapting Zoe tests in
agoric-sdk/zoe/tests/swingsetTests/zoe
to run underswingset-runner
:Broadly speaking, there were two kinds of issues that needed to be addressed to be able to do this:
1: Different import contexts
The various Zoe test vats' source files assume they are located in particular locations inside the
zoe
project tree and do imports using relative paths based on that assumption. If we could load those files directly from their native location, this would not be an issue, but unfortunately they have to be tweaked slightly to work inswingset-runner
.2: No test driver
We're not running inside the unit test framework, and thus we don't have it to
kick around any more(a) set things up, (b) parameterize what is to happen, and (c) provide an execution context. Each of those unpacks into a separate problem. These problems are all minor, but the changes to address them are the reason we can't just use the vat files directly.What was needed
Since the changes required were modest, it would be nice to consider if the two versions of the vat definitions could be unified to use a single common code base. Until then, the necessary adaptions were as follows:
I copied the vat source files (
bootstrap.js
and the variousvat-*.js
files) into a new directory,agoric-sdk/swingset-runner/demo/zoeTests
and then modified as follows.Problem 1
Dealing with this varied a little depending on the import dependency in question. I decided it was OK to use import paths that reached into the Zoe
src
directory, on the theory that these files were part of the published package, but not files from elsewhere in the Zoe tree (such as the test directories).agoric-sdk/zoe/tools/manualTimer.js
andagoric-sdk/zoe/tests/swingsetTests/helpers.js
could be copied into theswingset-runner
zoeTests
directory and used without modification. The vats then had to be changed to import./manualTimer
and./helpers
instead of../../../tools/manualTimer
and../helpers
respectively.The client support library was pulled in by importing
@agoric/zoe/src/clientSupport
instead of../../../src/clientSupport
and the Zoe library from@agoric/zoe
instead of../../../src/zoe
.Problem 2a
The issue here was the need to generate the bundles for the contracts. The
test-zoe.js
script did this prior to running the tests, but the only code thatswingset-runner
will be running will be inside vats. In principle the bundling could be done by the bootstrap vat, but a simpler approach was to extract the relevant code fragment fromtest-zoe.js
into a standalone executable I calledprepareContracts.js
, which needs to be executed once prior to trying to run things inswingset-runner
(and rerun any time the contract code changes, which introduces another manifestation of theyarn build
problem, but since this is POC code I chose the simpler expedient).Problem 2b
The problem here is that the extent argument that gets passed to the bootstrap vat is generated by the test script prior to the vat existing. Instead of being given to the bootstrap vat directly it is handed to
buildVatController
as a parameter to swingset creation, which means we must know which test is being run before we create the bootstrap vat. Butswingset-runner
can't do that since it has no varies-per-swingset configuration. Also, the argument is an array of arrays of numbers, whereasswingset-runner
is passing command line arguments which are always strings. The solution was to pass the extent as a command line parameter string, which required changing the relevant line of the bootstrap vat fromto
And then (and this is the really ugly part) providing the extents array as a stringified command line parameter when you want to execute a test.
A long term solution would be to get this data from a file that, say, both the Zoe tests and the
swingset-runner
version could import, but I don't know that there is a long term that needs to be satisfied here so just living with the ugliness may be more pragmatic.Problem 2c
The test harness extracts the run log from the kernel state after test execution and compares it to a reference sample, whereas what we want to do is print it to the console as the test is running. This requires providing an alternative log function to wrap
helpers.log
with a version that also echoes to the console. This in turn means that every vat setup function that has:must instead have
where
makePrintLog
is the wrapper function of my own that then needs to also get imported into each of the vats. As Brian points out, this opens a whole can of worms about what logging is for and how it should work and what we really want in that arena; the questions raised there are important but not on the critical path for this particular bit of work.The text was updated successfully, but these errors were encountered: