Skip to content

Commit

Permalink
1568 Make Zoe use AVA (#1588)
Browse files Browse the repository at this point in the history
* fix: ESM disable cache (Brian's work to fix mysterious failure in CI)

* fix: non-test changes to Zoe, notifier to prevent unhandled promise rejection

Removed unnecessary console.error(), cleaned up types

* fix: add AVA to Zoe, change tests (mostly Dean's work)

* chore: lockfile changes as a result of this PR

* chore: add TODOs for skipped tests to point to issue

Co-authored-by: Kate Sills <kate@agoric.com>
  • Loading branch information
dtribble and katelynsills authored Aug 27, 2020
1 parent bc765da commit d135893
Show file tree
Hide file tree
Showing 37 changed files with 3,493 additions and 4,742 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
branches: [master]
pull_request:

# set ESM_DISABLE_CACHE=true (will be JSON parsed)
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -110,64 +111,124 @@ jobs:
# run: yarn test
- name: yarn test (acorn-eventual-send)
run: cd packages/acorn-eventual-send && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (agoric-cli)
run: cd packages/agoric-cli && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (assert)
run: cd packages/assert && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (bundle-source)
run: cd packages/bundle-source && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (captp)
run: cd packages/captp && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (dapp-svelte-wallet/api)
run: cd packages/dapp-svelte-wallet/api && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (deployment)
run: cd packages/deployment && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (ERTP)
run: cd packages/ERTP && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (eventual-send)
run: cd packages/eventual-send && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (import-bundle)
run: cd packages/import-bundle && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (import-manager)
run: cd packages/import-manager && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (install-metering-and-ses)
run: cd packages/install-metering-and-ses && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (install-ses)
run: cd packages/install-ses && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (marshal)
run: cd packages/marshal && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (notifier)
run: cd packages/notifier && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (promise-kit)
run: cd packages/promise-kit && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (registrar)
run: cd packages/registrar && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (same-structure)
run: cd packages/same-structure && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (sharing-service)
run: cd packages/sharing-service && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (sparse-ints)
run: cd packages/sparse-ints && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (spawner)
run: cd packages/spawner && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (stat-logger)
run: cd packages/stat-logger && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (store)
run: cd packages/store && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (swing-store-lmdb)
run: cd packages/swing-store-lmdb && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (swing-store-simple)
run: cd packages/swing-store-simple && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (swingset-runner)
run: cd packages/swingset-runner && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (tame-metering)
run: cd packages/tame-metering && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (transform-eventual-send)
run: cd packages/transform-eventual-send && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (transform-metering)
run: cd packages/transform-metering && yarn test
env:
ESM_DISABLE_CACHE: true
- name: yarn test (weak-store)
run: cd packages/weak-store && yarn test
env:
ESM_DISABLE_CACHE: true

##############
# Long-running tests are executed individually.
Expand Down Expand Up @@ -212,6 +273,8 @@ jobs:
${{ runner.os }}-go-
- name: yarn test (cosmic-swingset)
run: cd packages/cosmic-swingset && yarn test
env:
ESM_DISABLE_CACHE: true

test-swingset:
# BEGIN-TEST-BOILERPLATE
Expand Down Expand Up @@ -243,6 +306,8 @@ jobs:
# END-RESTORE-BOILERPLATE
- name: yarn test (SwingSet)
run: cd packages/SwingSet && yarn test
env:
ESM_DISABLE_CACHE: true

test-zoe:
# BEGIN-TEST-BOILERPLATE
Expand Down Expand Up @@ -274,3 +339,5 @@ jobs:
# END-RESTORE-BOILERPLATE
- name: yarn test (zoe)
run: cd packages/zoe && yarn test
env:
ESM_DISABLE_CACHE: true
2 changes: 2 additions & 0 deletions packages/notifier/src/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export const makeNotifierKit = (...args) => {
assert(nextPromiseKit);
currentUpdateCount = undefined;
currentResponse = undefined;
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
nextPromiseKit.promise.catch(_ => {});
nextPromiseKit.reject(reason);
},
});
Expand Down
14 changes: 8 additions & 6 deletions packages/zoe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"build": "yarn build-zcfBundle",
"test": "yarn build && tap --no-coverage --jobs=1 --timeout 600 'test/**/test-*.js'",
"test": "ava --verbose",
"build-zcfBundle": "node -r esm scripts/build-zcfBundle.js",
"lint-fix": "yarn lint --fix",
"lint-check": "yarn lint",
Expand Down Expand Up @@ -53,16 +53,18 @@
"@agoric/install-metering-and-ses": "^0.1.1",
"@agoric/install-ses": "^0.2.0",
"@agoric/swingset-vat": "^0.6.0",
"esm": "^3.2.25",
"tap": "^14.10.5",
"tape": "^4.11.0",
"tape-promise": "^4.0.0"
"ava": "^3.11.1",
"esm": "^3.2.25"
},
"files": [
"src/",
"*.js",
"NEWS.md"
],
"ava": {
"files": ["test/**/test-*.js"],
"require": ["esm"],
"timeout": "10m"
},
"eslintConfig": {
"extends": [
"airbnb-base",
Expand Down
13 changes: 10 additions & 3 deletions packages/zoe/src/contractFacet/contractFacet.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ export function buildRootObject() {
const { notifier, updater } = makeNotifierKit();
/** @type {PromiseRecord<ZoeSeatAdmin>} */
const zoeSeatAdminPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
zoeSeatAdminPromiseKit.promise.catch(_ => {});
const userSeatPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
userSeatPromiseKit.promise.catch(_ => {});
const seatHandle = makeHandle('SeatHandle');

const seatData = harden({
Expand Down Expand Up @@ -363,7 +367,6 @@ export function buildRootObject() {
const offerHandler = invitationHandleToHandler.get(invitationHandle);
// @ts-ignore
const offerResultP = E(offerHandler)(zcfSeat).catch(reason => {
console.error(reason);
if (!zcfSeat.hasExited()) {
throw zcfSeat.kickOut(reason);
} else {
Expand All @@ -383,10 +386,12 @@ export function buildRootObject() {

// First, evaluate the contract code bundle.
const contractCode = evalContractBundle(bundle);
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
contractCode.catch(() => {});

// Next, execute the contract code, passing in zcf
/** @type {Promise<Invitation>} */
return E(contractCode)
/** @type {Promise<ExecuteContractResult>} */
const result = E(contractCode)
.start(zcf)
.then(({ creatorFacet, publicFacet, creatorInvitation }) => {
return harden({
Expand All @@ -396,6 +401,8 @@ export function buildRootObject() {
addSeatObj,
});
});
result.catch(() => {}); // Don't trigger Node.js's UnhandledPromiseRejectionWarning
return result;
};

return harden({ executeContract });
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/src/contractFacet/evalContractCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const evalContractBundle = (bundle, additionalEndowments = {}) => {

const installation = importBundle(bundle, {
endowments: fullEndowments,
});
}).catch(() => {}); // Don't trigger Node.js's UnhandledPromiseRejectionWarning
return installation;
};

Expand Down
1 change: 0 additions & 1 deletion packages/zoe/src/contractFacet/seat.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const makeZcfSeatAdminKit = (
assertExitedFalse();
zcfSeatAdmin.updateHasExited();
E(zoeSeatAdmin).kickOut(harden(reason));
console.error(reason);
throw reason;
},
getNotifier: () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/zoe/src/internal-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* @typedef {Object} ZoeSeatAdmin
* @property {(allocation: Allocation) => void} replaceAllocation
* @property {() => void} exit
* @property {(reason: any) => never} kickOut called with the reason this seat
* @property {(reason: any) => void} kickOut called with the reason this seat
* is being kicked out, where reason is normally an instanceof Error.
* @property {() => Allocation} getCurrentAllocation
*/
Expand Down Expand Up @@ -181,7 +181,7 @@
* @param {Issuer} invitationIssuer
* @param {ZoeInstanceAdmin} zoeInstanceAdmin
* @param {InstanceRecord} instanceRecord
* @returns {ExecuteContractResult}
* @returns {Promise<ExecuteContractResult>}
*
*/

Expand All @@ -190,6 +190,7 @@
* @param {ProposalRecord} proposal
* @param {ERef<ZoeSeatAdmin>} zoeSeatAdmin
* @param {ZCFSeatAdmin} zcfSeatAdmin
* @returns {ExitObj}
*/

/**
Expand Down
12 changes: 12 additions & 0 deletions packages/zoe/src/zoeService/zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,11 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) {

const bundle = installation.getBundle();
const addSeatObjPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
addSeatObjPromiseKit.promise.catch(_ => {});
const publicFacetPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
publicFacetPromiseKit.promise.catch(_ => {});

const makeInstanceAdmin = () => {
/** @type {Set<ZoeSeatAdmin>} */
Expand Down Expand Up @@ -391,7 +395,11 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) {
const initialAllocation = arrayToObj(amountsArray, proposalKeywords);

const offerResultPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
offerResultPromiseKit.promise.catch(_ => {});
const exitObjPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
exitObjPromiseKit.promise.catch(_ => {});
const instanceAdmin = instanceToInstanceAdmin.get(instance);
const seatHandle = makeHandle('SeatHandle');

Expand Down Expand Up @@ -419,6 +427,10 @@ function makeZoe(vatAdminSvc, zcfBundleName = undefined) {
.then(({ offerResultP, exitObj }) => {
offerResultPromiseKit.resolve(offerResultP);
exitObjPromiseKit.resolve(exitObj);
})
.catch(err => {
console.log(err);
console.log('right here');
});

return userSeat;
Expand Down
4 changes: 2 additions & 2 deletions packages/zoe/src/zoeService/zoeSeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const makeZoeSeatAdminKit = (
offerResult,
) => {
const payoutPromiseKit = makePromiseKit();
// Don't trigger Node.js's UnhandledPromiseRejectionWarning
payoutPromiseKit.promise.catch(_ => {});
const { notifier, updater } = makeNotifierKit();

let currentAllocation = initialAllocation;
Expand Down Expand Up @@ -75,8 +77,6 @@ export const makeZoeSeatAdminKit = (
);
updater.fail(reason);
doExit(zoeSeatAdmin);
console.log(reason);
throw reason;
},
getCurrentAllocation: () => currentAllocation,
});
Expand Down
Loading

0 comments on commit d135893

Please sign in to comment.