Skip to content

Commit

Permalink
refactor(swingset-runner): Convert RESM to NESM
Browse files Browse the repository at this point in the history
Refs #527
  • Loading branch information
kriskowal committed Aug 12, 2021
1 parent c74b42d commit 7d2a9bf
Show file tree
Hide file tree
Showing 37 changed files with 155 additions and 141 deletions.
6 changes: 3 additions & 3 deletions packages/swingset-runner/autobench
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for (const suite of SUITES) {
console.log(`Autobenching suite=${suite} ...`);
const prep = `demo/${suite}/prepareContracts.js`;
if (existsSync(prep)) {
spawnNodeSync(['-r', 'esm', prep]);
spawnNodeSync([prep]);
}
const benchstats = `benchstats-${suite}.json`;
try {
Expand All @@ -35,11 +35,11 @@ for (const suite of SUITES) {
}
}
spawnNodeSync([
'-r', 'esm', 'bin/runner', '--init',
'bin/runner', '--init',
'--benchmark', brounds, '--statsfile', benchstats, ...configFlags,
'run', `demo/${suite}`, '--quiet', '--prime',
]);
spawnNodeSync(['-r', 'esm', 'src/push-metrics.js', suite, benchstats]);
spawnNodeSync(['src/push-metrics.js', suite, benchstats]);
}

console.log(`Done!`);
15 changes: 0 additions & 15 deletions packages/swingset-runner/bin/kerneldump

This file was deleted.

1 change: 1 addition & 0 deletions packages/swingset-runner/bin/kerneldump
21 changes: 0 additions & 21 deletions packages/swingset-runner/bin/runner

This file was deleted.

1 change: 1 addition & 0 deletions packages/swingset-runner/bin/runner
14 changes: 0 additions & 14 deletions packages/swingset-runner/bin/runner-debug

This file was deleted.

1 change: 1 addition & 0 deletions packages/swingset-runner/bin/runner-debug
9 changes: 0 additions & 9 deletions packages/swingset-runner/bin/slogulator

This file was deleted.

1 change: 1 addition & 0 deletions packages/swingset-runner/bin/slogulator
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import buildCommsDispatch from '@agoric/swingset-vat/src/vats/comms';
import buildCommsDispatch from '@agoric/swingset-vat/src/vats/comms/index.js';

export default function setup(syscall, _state, _helpers, _vatPowers) {
return buildCommsDispatch(syscall);
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { buildRootObject } from '@agoric/swingset-vat/src/vats/vat-tp';
export { buildRootObject } from '@agoric/swingset-vat/src/vats/vat-tp.js';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';

/* eslint-disable-next-line import/no-unresolved, import/extensions */
import exchangeBundle from './bundle-simpleExchange';
import exchangeBundle from './bundle-simpleExchange.js';

export function buildRootObject(_vatPowers, vatParameters) {
let alice;
Expand Down
6 changes: 3 additions & 3 deletions packages/swingset-runner/demo/exchangeBenchmark/exchanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { showPurseBalance, setupPurses } from './helpers';
import { makePrintLog } from './printLog';
import { showPurseBalance, setupPurses } from './helpers.js';
import { makePrintLog } from './printLog.js';

import '@agoric/zoe/exported';
import '@agoric/zoe/exported.js';

const log = makePrintLog();

Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-runner/demo/exchangeBenchmark/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E } from '@agoric/eventual-send';
import { AmountMath } from '@agoric/ertp';

import '@agoric/zoe/exported';
import '@agoric/zoe/exported.js';

export async function showPurseBalance(purseP, name, log) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/* global require __dirname */
// TODO Remove babel-standalone preinitialization
// https://github.com/endojs/endo/issues/768
import '@agoric/babel-standalone';
import '@agoric/install-ses';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';

import fs from 'fs';

const CONTRACT_FILES = ['simpleExchange'];

const generateBundlesP = Promise.all(
CONTRACT_FILES.map(async contract => {
const contractPath = require.resolve(
`@agoric/zoe/src/contracts/${contract}`,
);
const contractPath = new URL(
await importMetaResolve(
`@agoric/zoe/src/contracts/${contract}`,
import.meta.url,
),
).pathname;
const bundle = await bundleSource(contractPath);
const obj = { bundle, contract };
fs.writeFileSync(
`${__dirname}/bundle-${contract}.js`,
new URL(`bundle-${contract}.js`, import.meta.url).pathname,
`export default ${JSON.stringify(obj)};`,
);
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/swingset-runner/demo/swapBenchmark/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { makePrintLog } from './printLog';
import { makePrintLog } from './printLog.js';

/* eslint-disable-next-line import/no-unresolved, import/extensions */
import atomicSwapBundle from './bundle-atomicSwap';
import atomicSwapBundle from './bundle-atomicSwap.js';

const log = makePrintLog();

Expand Down
6 changes: 3 additions & 3 deletions packages/swingset-runner/demo/swapBenchmark/exchanger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { showPurseBalance, setupPurses } from './helpers';
import { makePrintLog } from './printLog';
import { showPurseBalance, setupPurses } from './helpers.js';
import { makePrintLog } from './printLog.js';

import '@agoric/zoe/exported';
import '@agoric/zoe/exported.js';

const log = makePrintLog();

Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-runner/demo/swapBenchmark/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E } from '@agoric/eventual-send';
import { AmountMath } from '@agoric/ertp';

import '@agoric/zoe/exported';
import '@agoric/zoe/exported.js';

export async function showPurseBalance(purseP, name, log) {
try {
Expand Down
13 changes: 8 additions & 5 deletions packages/swingset-runner/demo/swapBenchmark/prepareContracts.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/* global require __dirname */
// TODO Remove babel-standalone preinitialization
// https://github.com/endojs/endo/issues/768
import '@agoric/babel-standalone';
import '@agoric/install-ses';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';

import fs from 'fs';

const CONTRACT_FILES = ['atomicSwap'];

const generateBundlesP = Promise.all(
CONTRACT_FILES.map(async contract => {
const contractPath = require.resolve(
`@agoric/zoe/src/contracts/${contract}`,
);
const contractPath = new URL(
await importMetaResolve(
`@agoric/zoe/src/contracts/${contract}`,
import.meta.url,
),
).pathname;
const bundle = await bundleSource(contractPath);
const obj = { bundle, contract };
fs.writeFileSync(
`${__dirname}/bundle-${contract}.js`,
new URL(`bundle-${contract}.js`, import.meta.url).pathname,
`export default ${JSON.stringify(obj)};`,
);
}),
Expand Down
2 changes: 1 addition & 1 deletion packages/swingset-runner/demo/vatStore2/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { assert, details as X } from '@agoric/assert';
import { makeXorShift128 } from './xorshift128';
import { makeXorShift128 } from './xorshift128.js';

const p = console.log;

Expand Down
22 changes: 11 additions & 11 deletions packages/swingset-runner/demo/zoeTests/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { E } from '@agoric/eventual-send';
import { Far } from '@agoric/marshal';
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
import buildManualTimer from './manualTimer';
import buildManualTimer from './manualTimer.js';

import { makePrintLog } from './printLog';
import { makePrintLog } from './printLog.js';

/* eslint-disable import/no-unresolved, import/extensions */
import automaticRefundBundle from './bundle-automaticRefund';
import coveredCallBundle from './bundle-coveredCall';
import secondPriceAuctionBundle from './bundle-secondPriceAuction';
import atomicSwapBundle from './bundle-atomicSwap';
import simpleExchangeBundle from './bundle-simpleExchange';
import autoswapBundle from './bundle-autoswap';
import sellItemsBundle from './bundle-sellItems';
import mintAndSellNFTBundle from './bundle-mintAndSellNFT';
import otcDeskBundle from './bundle-otcDesk';
import automaticRefundBundle from './bundle-automaticRefund.js';
import coveredCallBundle from './bundle-coveredCall.js';
import secondPriceAuctionBundle from './bundle-secondPriceAuction.js';
import atomicSwapBundle from './bundle-atomicSwap.js';
import simpleExchangeBundle from './bundle-simpleExchange.js';
import autoswapBundle from './bundle-autoswap.js';
import sellItemsBundle from './bundle-sellItems.js';
import mintAndSellNFTBundle from './bundle-mintAndSellNFT.js';
import otcDeskBundle from './bundle-otcDesk.js';
/* eslint-enable import/no-unresolved, import/extensions */

const setupBasicMints = () => {
Expand Down
11 changes: 8 additions & 3 deletions packages/swingset-runner/demo/zoeTests/prepareContracts.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* global require __dirname */
// TODO Remove babel-standalone preinitialization
// https://github.com/endojs/endo/issues/768
import '@agoric/babel-standalone';
import '@agoric/install-ses';
import bundleSource from '@agoric/bundle-source';
import { resolve as importMetaResolve } from 'import-meta-resolve';

import fs from 'fs';

Expand Down Expand Up @@ -32,11 +32,16 @@ const generateBundlesP = Promise.all(
} else {
({ bundleName, contractPath } = settings);
}
const source = require.resolve(`@agoric/zoe/src/contracts/${contractPath}`);
const source = new URL(
await importMetaResolve(
`@agoric/zoe/src/contracts/${contractPath}`,
import.meta.url,
),
).pathname;
const bundle = await bundleSource(source);
const obj = { bundle, bundleName };
fs.writeFileSync(
`${__dirname}/bundle-${bundleName}.js`,
new URL(`bundle-${bundleName}.js`, import.meta.url).pathname,
`export default ${JSON.stringify(obj)};`,
);
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/swingset-runner/demo/zoeTests/vat-alice.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { E } from '@agoric/eventual-send';
import { AmountMath } from '@agoric/ertp';
import { assert, details as X } from '@agoric/assert';
import { Far } from '@agoric/marshal';
import { showPurseBalance, setupIssuers } from './helpers';
import { showPurseBalance, setupIssuers } from './helpers.js';

import { makePrintLog } from './printLog';
import { makePrintLog } from './printLog.js';

const build = async (log, zoe, issuers, payments, installations, timer) => {
const { moola, simoleans, bucks, purses } = await setupIssuers(zoe, issuers);
Expand Down
4 changes: 2 additions & 2 deletions packages/swingset-runner/demo/zoeTests/vat-bob.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { assert, details as X } from '@agoric/assert';
import { sameStructure } from '@agoric/same-structure';
import { AmountMath } from '@agoric/ertp';
import { Far } from '@agoric/marshal';
import { showPurseBalance, setupIssuers } from './helpers';
import { showPurseBalance, setupIssuers } from './helpers.js';

import { makePrintLog } from './printLog';
import { makePrintLog } from './printLog.js';

const build = async (log, zoe, issuers, payments, installations, timer) => {
const { moola, simoleans, bucks, purses } = await setupIssuers(zoe, issuers);
Expand Down
4 changes: 2 additions & 2 deletions packages/swingset-runner/demo/zoeTests/vat-carol.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { E } from '@agoric/eventual-send';
import { assert, details as X } from '@agoric/assert';
import { sameStructure } from '@agoric/same-structure';
import { Far } from '@agoric/marshal';
import { showPurseBalance, setupIssuers } from './helpers';
import { showPurseBalance, setupIssuers } from './helpers.js';

import { makePrintLog } from './printLog';
import { makePrintLog } from './printLog.js';

const build = async (log, zoe, issuers, payments, installations) => {
const { moola, simoleans, purses } = await setupIssuers(zoe, issuers);
Expand Down
4 changes: 2 additions & 2 deletions packages/swingset-runner/demo/zoeTests/vat-dave.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { assert, details as X } from '@agoric/assert';
import { sameStructure } from '@agoric/same-structure';
import { AmountMath } from '@agoric/ertp';
import { Far } from '@agoric/marshal';
import { showPurseBalance, setupIssuers } from './helpers';
import { showPurseBalance, setupIssuers } from './helpers.js';

import { makePrintLog } from './printLog';
import { makePrintLog } from './printLog.js';

const build = async (log, zoe, issuers, payments, installations, timer) => {
const { moola, simoleans, bucks, purses } = await setupIssuers(zoe, issuers);
Expand Down
11 changes: 3 additions & 8 deletions packages/swingset-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
"version": "0.13.11",
"private": true,
"description": "Application to launch SwingSet instances for development and testing",
"parsers": {
"js": "mjs"
},
"main": "src/main.js",
"type": "module",
"main": "./src/main.js",
"repository": "https://github.com/Agoric/agoric-sdk",
"author": "Agoric",
"license": "Apache-2.0",
Expand Down Expand Up @@ -41,7 +39,7 @@
},
"devDependencies": {
"ava": "^3.12.1",
"esm": "agoric-labs/esm#Agoric-built"
"import-meta-resolve": "^1.1.1"
},
"eslintConfig": {
"extends": [
Expand All @@ -62,9 +60,6 @@
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
],
"timeout": "2m"
}
}
4 changes: 2 additions & 2 deletions packages/swingset-runner/src/auditstore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, details as X } from '@agoric/assert';
import { parseReachableAndVatSlot } from '@agoric/swingset-vat/src/kernel/state/reachable';
import { parseVatSlot } from '@agoric/swingset-vat/src/parseVatSlots';
import { parseReachableAndVatSlot } from '@agoric/swingset-vat/src/kernel/state/reachable.js';
import { parseVatSlot } from '@agoric/swingset-vat/src/parseVatSlots.js';

/* eslint-disable no-use-before-define */
export function auditRefCounts(store, doDump, printPrefix) {
Expand Down
Loading

0 comments on commit 7d2a9bf

Please sign in to comment.