agoric 0.22.0-upgrade-14-dev-c8f9e7b.0 → 0.22.0-upgrade-16-dev-07b0130.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/start.js CHANGED
@@ -40,6 +40,7 @@ const DELEGATE0_COINS = `50000000${STAKING_DENOM}`;
40
40
  const SOLO_COINS = `13000000${STAKING_DENOM},500000000${CENTRAL_DENOM}`;
41
41
  const CHAIN_ID = 'agoriclocal';
42
42
 
43
+ const SERVERS_ROOT_DIR = '_agstate/agoric-servers';
43
44
  const FAKE_CHAIN_DELAY =
44
45
  process.env.FAKE_CHAIN_DELAY === undefined
45
46
  ? 0
@@ -69,10 +70,10 @@ export default async function startMain(progname, rawArgs, powers, opts) {
69
70
  const pspawnEnv = { ...process.env };
70
71
  if (opts.verbose > 1) {
71
72
  // Loudly verbose logs (nondeterministic).
72
- pspawnEnv.DEBUG = 'agoric,SwingSet:vat,SwingSet:ls';
73
+ pspawnEnv.DEBUG = 'agoric:debug,SwingSet:vat,SwingSet:ls';
73
74
  } else if (opts.verbose) {
74
75
  // Verbose vat logs (nondeterministic).
75
- pspawnEnv.DEBUG = 'SwingSet:vat,SwingSet:ls';
76
+ pspawnEnv.DEBUG = 'agoric:info,SwingSet:vat,SwingSet:ls';
76
77
  }
77
78
 
78
79
  const pspawn = makePspawn({ env: pspawnEnv, spawn, log, chalk });
@@ -151,6 +152,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
151
152
  ]);
152
153
 
153
154
  const exists = async file => {
155
+ await null;
154
156
  try {
155
157
  await fs.stat(file);
156
158
  return true;
@@ -159,6 +161,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
159
161
  }
160
162
  };
161
163
 
164
+ const rmVerbose = async filePath => {
165
+ log(chalk.green(`removing ${filePath}`));
166
+ // rm is available on all the unix-likes, so use it for speed.
167
+ await pspawn('rm', ['-rf', filePath]);
168
+ };
169
+
162
170
  let agSolo;
163
171
  let agSoloBuild;
164
172
  if (opts.dockerTag) {
@@ -171,12 +179,11 @@ export default async function startMain(progname, rawArgs, powers, opts) {
171
179
  const fakeDelay =
172
180
  popts.delay === undefined ? FAKE_CHAIN_DELAY : Number(popts.delay);
173
181
 
174
- const agServer = `_agstate/agoric-servers/${profileName}`;
182
+ const serverDir = `${SERVERS_ROOT_DIR}/${profileName}`;
175
183
 
184
+ await null;
176
185
  if (popts.reset) {
177
- log(chalk.green(`removing ${agServer}`));
178
- // rm is available on all the unix-likes, so use it for speed.
179
- await pspawn('rm', ['-rf', agServer]);
186
+ await rmVerbose(serverDir);
180
187
  }
181
188
 
182
189
  if (!opts.dockerTag) {
@@ -197,14 +204,14 @@ export default async function startMain(progname, rawArgs, powers, opts) {
197
204
  }
198
205
 
199
206
  const fakeGCI = 'sim-chain';
200
- const serverExists = await exists(agServer);
207
+ const serverExists = await exists(serverDir);
201
208
  if (!serverExists) {
202
209
  log(chalk.yellow(`initializing ${profileName}`));
203
210
  await pspawn(
204
211
  agSolo,
205
212
  ['init', profileName, '--egresses=fake', `--webport=${HOST_PORT}`],
206
213
  {
207
- cwd: '_agstate/agoric-servers',
214
+ cwd: SERVERS_ROOT_DIR,
208
215
  },
209
216
  );
210
217
  }
@@ -215,7 +222,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
215
222
  agSolo,
216
223
  ['set-fake-chain', `--delay=${fakeDelay}`, fakeGCI],
217
224
  {
218
- cwd: agServer,
225
+ cwd: serverDir,
219
226
  },
220
227
  );
221
228
  }
@@ -226,7 +233,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
226
233
  }
227
234
 
228
235
  const ps = pspawn(agSolo, [...debugOpts, 'start'], {
229
- cwd: agServer,
236
+ cwd: serverDir,
230
237
  env: nodeDebugEnv,
231
238
  });
232
239
  process.on('SIGINT', () => ps.childProcess.kill('SIGINT'));
@@ -246,6 +253,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
246
253
  }
247
254
 
248
255
  const { cosmosChain, cosmosChainBuild } = getSDKBinaries(sdkPrefixes);
256
+ await null;
249
257
  if (popts.pull || popts.rebuild) {
250
258
  if (popts.dockerTag) {
251
259
  const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]);
@@ -263,17 +271,15 @@ export default async function startMain(progname, rawArgs, powers, opts) {
263
271
  }
264
272
  }
265
273
 
266
- const agServer = `_agstate/agoric-servers/${profileName}-${portNum}`;
274
+ const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${portNum}`;
267
275
  if (popts.reset) {
268
- log(chalk.green(`removing ${agServer}`));
269
- // rm is available on all the unix-likes, so use it for speed.
270
- await pspawn('rm', ['-rf', agServer]);
276
+ await rmVerbose(serverDir);
271
277
  }
272
278
 
273
279
  let chainSpawn;
274
280
  if (!popts.dockerTag) {
275
281
  chainSpawn = (args, spawnOpts = undefined) => {
276
- return pspawn(cosmosChain, [...args, `--home=${agServer}`], spawnOpts);
282
+ return pspawn(cosmosChain, [...args, `--home=${serverDir}`], spawnOpts);
277
283
  };
278
284
  } else {
279
285
  chainSpawn = (args, spawnOpts = undefined, dockerArgs = []) =>
@@ -287,13 +293,13 @@ export default async function startMain(progname, rawArgs, powers, opts) {
287
293
  ...terminalOnlyFlags(`-it`),
288
294
  SDK_IMAGE,
289
295
  ...args,
290
- `--home=/usr/src/dapp/${agServer}`,
296
+ `--home=/usr/src/dapp/${serverDir}`,
291
297
  ],
292
298
  spawnOpts,
293
299
  );
294
300
  }
295
301
 
296
- const serverExists = await exists(agServer);
302
+ const serverExists = await exists(serverDir);
297
303
  if (!serverExists) {
298
304
  const exitStatus = await chainSpawn([
299
305
  'init',
@@ -308,7 +314,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
308
314
  // Get or create the essential addresses.
309
315
  const addrs = {};
310
316
  for (const keyName of ['provision', 'delegate0']) {
311
- /* eslint-disable no-await-in-loop */
312
317
  let statusOut = showKey(keyName);
313
318
  const exitStatusOut = await statusOut[0];
314
319
  if (exitStatusOut) {
@@ -328,10 +333,9 @@ export default async function startMain(progname, rawArgs, powers, opts) {
328
333
  }
329
334
  }
330
335
  addrs[keyName] = statusOut[1].trimRight();
331
- /* eslint-enable no-await-in-loop */
332
336
  }
333
337
 
334
- const genesisFile = `${agServer}/config/genesis.json`;
338
+ const genesisFile = `${serverDir}/config/genesis.json`;
335
339
  const stampExists = await exists(`${genesisFile}.stamp`);
336
340
  if (!stampExists) {
337
341
  let exitStatus;
@@ -361,7 +365,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
361
365
  `--keyring-dir=${keysHome}`,
362
366
  '--keyring-backend=test',
363
367
  `--chain-id=${CHAIN_ID}`,
364
- `${DELEGATE0_COINS}`,
368
+ DELEGATE0_COINS,
365
369
  ]);
366
370
  if (exitStatus) {
367
371
  return exitStatus;
@@ -382,8 +386,8 @@ export default async function startMain(progname, rawArgs, powers, opts) {
382
386
 
383
387
  // Complete the genesis file and launch the chain.
384
388
  log('read ag-chain-cosmos config');
385
- const configFile = `${agServer}/config/config.toml`;
386
- const appFile = `${agServer}/config/app.toml`;
389
+ const configFile = `${serverDir}/config/config.toml`;
390
+ const appFile = `${serverDir}/config/app.toml`;
387
391
  const [genesisJson, configToml, appToml] = await Promise.all([
388
392
  fs.readFile(genesisFile, 'utf-8'),
389
393
  fs.readFile(configFile, 'utf-8'),
@@ -446,9 +450,10 @@ export default async function startMain(progname, rawArgs, powers, opts) {
446
450
  return 1;
447
451
  }
448
452
 
449
- const agServer = `_agstate/agoric-servers/${profileName}-${portNum}`;
453
+ const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${portNum}`;
450
454
 
451
455
  const { cosmosClientBuild } = getSDKBinaries(sdkPrefixes);
456
+ await null;
452
457
  if (popts.pull || popts.rebuild) {
453
458
  if (popts.dockerTag) {
454
459
  const exitStatus = await pspawn('docker', ['pull', SDK_IMAGE]);
@@ -474,9 +479,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
474
479
  }
475
480
 
476
481
  if (popts.reset) {
477
- log(chalk.green(`removing ${agServer}`));
478
- // rm is available on all the unix-likes, so use it for speed.
479
- await pspawn('rm', ['-rf', agServer]);
482
+ await rmVerbose(serverDir);
480
483
  }
481
484
 
482
485
  let soloSpawn;
@@ -491,7 +494,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
491
494
  'run',
492
495
  `--volume=${process.cwd()}:/usr/src/dapp`,
493
496
  `--volume=${process.env.HOME}/.agoric:/root/.agoric`,
494
- `-eAG_SOLO_BASEDIR=/usr/src/dapp/${agServer}`,
497
+ `-eAG_SOLO_BASEDIR=/usr/src/dapp/${serverDir}`,
495
498
  `--rm`,
496
499
  ...terminalOnlyFlags(`-it`),
497
500
  `--entrypoint=ag-solo`,
@@ -503,7 +506,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
503
506
  );
504
507
  }
505
508
 
506
- const serverExists = await exists(agServer);
509
+ const serverExists = await exists(serverDir);
507
510
  // Initialise the solo directory and key.
508
511
  if (!serverExists) {
509
512
  const initArgs = [`--webport=${portNum}`];
@@ -511,7 +514,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
511
514
  initArgs.push(`--webhost=0.0.0.0`);
512
515
  }
513
516
  const exitStatus = await soloSpawn(
514
- ['init', agServer, ...initArgs],
517
+ ['init', serverDir, ...initArgs],
515
518
  undefined,
516
519
  [`--workdir=/usr/src/dapp`],
517
520
  );
@@ -522,15 +525,15 @@ export default async function startMain(progname, rawArgs, powers, opts) {
522
525
 
523
526
  // Create the full economy chain config.
524
527
  const agServerResolve = spec =>
525
- require.resolve(spec, { paths: [agServer] });
528
+ require.resolve(spec, { paths: [serverDir] });
526
529
  const coreConfigPath = agServerResolve(
527
- '@agoric/vats/decentral-core-config.json',
530
+ '@agoric/vm-config/decentral-core-config.json',
528
531
  );
529
532
  const economyTemplPath = agServerResolve(
530
533
  '@agoric/cosmic-swingset/economy-template.json',
531
534
  );
532
535
  const [rawSoloAddr, coreConfigJson, economyTemplJson] = await Promise.all([
533
- fs.readFile(`${agServer}/ag-cosmos-helper-address`, 'utf-8'),
536
+ fs.readFile(`${serverDir}/ag-cosmos-helper-address`, 'utf-8'),
534
537
  fs.readFile(coreConfigPath, 'utf-8'),
535
538
  fs.readFile(economyTemplPath, 'utf-8'),
536
539
  ]);
@@ -541,7 +544,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
541
544
  const economyConfig = JSON.parse(coreConfigJson);
542
545
  economyConfig.coreProposals = economyProposals;
543
546
  await fs.writeFile(
544
- `${agServer}/decentral-economy-config.json`,
547
+ `${serverDir}/decentral-economy-config.json`,
545
548
  JSON.stringify(economyConfig, null, 2),
546
549
  );
547
550
 
@@ -549,13 +552,12 @@ export default async function startMain(progname, rawArgs, powers, opts) {
549
552
  return 0;
550
553
  }
551
554
 
552
- const gciFile = `_agstate/agoric-servers/local-chain-${CHAIN_PORT}/config/genesis.json.sha256`;
555
+ const gciFile = `${SERVERS_ROOT_DIR}/local-chain-${CHAIN_PORT}/config/genesis.json.sha256`;
553
556
  process.stdout.write(`Waiting for local-chain-${CHAIN_PORT} to start...`);
554
557
  let hasGci = false;
555
558
  for await (const _ of untilTrue(() => hasGci)) {
556
559
  process.stdout.write('.');
557
560
 
558
- // eslint-disable-next-line no-await-in-loop
559
561
  await new Promise((resolve, reject) => {
560
562
  fs.stat(gciFile).then(
561
563
  _2 => {
@@ -576,7 +578,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
576
578
 
577
579
  const spawnOpts = {};
578
580
  if (!popts.dockerTag) {
579
- spawnOpts.cwd = agServer;
581
+ spawnOpts.cwd = serverDir;
580
582
  }
581
583
 
582
584
  const rpcAddrs = [`localhost:${CHAIN_PORT}`];
@@ -590,7 +592,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
590
592
  let bestRpcAddr;
591
593
  for await (const _ of untilTrue(() => bestRpcAddr)) {
592
594
  for await (const rpcAddr of rpcAddrs) {
593
- // eslint-disable-next-line no-await-in-loop
594
595
  exitStatus = await keysSpawn([
595
596
  'query',
596
597
  'swingset',
@@ -639,7 +640,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
639
640
  ];
640
641
  for (/* await */ const cmd of provCmds) {
641
642
  const statusOut = capture(keysSpawn, cmd, true);
642
- // eslint-disable-next-line no-await-in-loop
643
643
  exitStatus = await statusOut[0];
644
644
  if (!exitStatus) {
645
645
  const json = statusOut[1].replace(/^gas estimate: \d+$/m, '');
@@ -664,7 +664,6 @@ export default async function startMain(progname, rawArgs, powers, opts) {
664
664
  }
665
665
  }
666
666
  if (!bestRpcAddr) {
667
- // eslint-disable-next-line no-await-in-loop
668
667
  await delay(2000);
669
668
  }
670
669
  }
@@ -690,6 +689,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
690
689
  }
691
690
 
692
691
  async function startTestnetDocker(profileName, startArgs, popts) {
692
+ await null;
693
693
  if (popts.dockerTag && popts.pull) {
694
694
  const exitStatus = await pspawn('docker', ['pull', SOLO_IMAGE]);
695
695
  if (exitStatus) {
@@ -699,12 +699,10 @@ export default async function startMain(progname, rawArgs, powers, opts) {
699
699
 
700
700
  const port = startArgs[0] || PORT;
701
701
  const netconfig = startArgs[1] || DEFAULT_NETCONFIG;
702
- const agServer = `_agstate/agoric-servers/${profileName}-${port}`;
702
+ const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${port}`;
703
703
 
704
704
  if (popts.reset) {
705
- log(chalk.green(`removing ${agServer}`));
706
- // rm is available on all the unix-likes, so use it for speed.
707
- await pspawn('rm', ['-rf', agServer]);
705
+ await rmVerbose(serverDir);
708
706
  }
709
707
 
710
708
  const setupRun = (...bonusArgs) =>
@@ -712,7 +710,7 @@ export default async function startMain(progname, rawArgs, powers, opts) {
712
710
  'run',
713
711
  `-p127.0.0.1:${HOST_PORT}:${port}`,
714
712
  `--volume=${process.cwd()}:/usr/src/dapp`,
715
- `-eAG_SOLO_BASEDIR=/usr/src/dapp/${agServer}`,
713
+ `-eAG_SOLO_BASEDIR=/usr/src/dapp/${serverDir}`,
716
714
  `--rm`,
717
715
  ...terminalOnlyFlags(`-it`),
718
716
  SOLO_IMAGE,
@@ -727,44 +725,38 @@ export default async function startMain(progname, rawArgs, powers, opts) {
727
725
  async function startTestnetSdk(profileName, startArgs, popts) {
728
726
  const port = startArgs[0] || PORT;
729
727
  const netconfig = startArgs[1] || DEFAULT_NETCONFIG;
730
- const agServer = `_agstate/agoric-servers/${profileName}-${port}`;
728
+ const serverDir = `${SERVERS_ROOT_DIR}/${profileName}-${port}`;
731
729
 
730
+ await null;
732
731
  if (popts.reset) {
733
- log(chalk.green(`removing ${agServer}`));
734
- // rm is available on all the unix-likes, so use it for speed.
735
- await pspawn('rm', ['-rf', agServer]);
732
+ await rmVerbose(serverDir);
736
733
  }
737
734
 
738
735
  const setupRun = (...bonusArgs) =>
739
736
  pspawn(agSolo, [`--webport=${port}`, ...bonusArgs], {
740
- env: { ...pspawnEnv, AG_SOLO_BASEDIR: agServer },
737
+ env: { ...pspawnEnv, AG_SOLO_BASEDIR: serverDir },
741
738
  });
742
739
 
743
740
  return setupRun('setup', `--netconfig=${netconfig}`);
744
741
  }
745
742
 
746
743
  const profiles = {
744
+ __proto__: null,
747
745
  dev: startFakeChain,
748
746
  'local-chain': startLocalChain,
749
747
  'local-solo': startLocalSolo,
750
748
  testnet: opts.dockerTag ? startTestnetDocker : startTestnetSdk,
751
749
  };
752
750
 
753
- const popts = opts;
754
-
755
- const args = rawArgs.slice(1);
756
- const profileName = args[0] || 'dev';
751
+ const [_command = 'start', profileName = 'dev', ...args] = rawArgs;
757
752
  const startFn = profiles[profileName];
758
753
  if (!startFn) {
754
+ const profileNames = Object.keys(profiles).join(', ');
759
755
  log.error(
760
- `unrecognized profile name ${profileName}; use one of: ${Object.keys(
761
- profiles,
762
- )
763
- .sort()
764
- .join(', ')}`,
756
+ `unrecognized profile name ${profileName}; use one of: ${profileNames}`,
765
757
  );
766
758
  return 1;
767
759
  }
768
760
 
769
- return startFn(profileName, args[0] ? args.slice(1) : args, popts);
761
+ return startFn(profileName, args, opts);
770
762
  }
@@ -1,8 +1,7 @@
1
- /* global process setTimeout clearTimeout setInterval clearInterval */
1
+ /* global process setTimeout setInterval clearInterval */
2
2
 
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
- // eslint-disable-next-line import/no-extraneous-dependencies
6
5
  import tmp from 'tmp';
7
6
  import { makePromiseKit } from '@endo/promise-kit';
8
7
  import { request } from 'http';
@@ -11,32 +10,21 @@ import { spawn } from 'child_process';
11
10
 
12
11
  import { makePspawn } from '../src/helpers.js';
13
12
 
14
- const TIMEOUT_SECONDS = 20 * 60;
13
+ const TIMEOUT_SECONDS = 3 * 60;
15
14
 
16
15
  const dirname = new URL('./', import.meta.url).pathname;
17
16
 
18
- // To keep in sync with https://agoric.com/documentation/getting-started/
17
+ // To keep in sync with https://docs.agoric.com/guides/getting-started/
19
18
 
20
19
  // Note that we currently only test:
21
20
  // agoric init dapp-foo
22
- // agoric install
23
- // agoric start --reset
24
- // agoric deploy ./contract/deploy.js ./api/deploy.js
25
- // (For simple-exchange and autoswap, the above also makes and accepts offers)
26
- // cd ui && yarn install
27
- // cd ui && yarn start
21
+ // yarn install
22
+ // yarn start:docker
23
+ // yarn start:contract
24
+ // yarn start:ui
28
25
 
29
26
  export const gettingStartedWorkflowTest = async (t, options = {}) => {
30
- const {
31
- init: initOptions = [],
32
- install: installOptions = [],
33
- start: startOptions = [],
34
- testUnsafePlugins = false,
35
- } = options;
36
- // FIXME: Do a search for an unused port or allow specification.
37
- const PORT = '7999';
38
- process.env.PORT = PORT;
39
-
27
+ const { init: initOptions = [] } = options;
40
28
  const pspawn = makePspawn({ spawn });
41
29
 
42
30
  // Kill an entire process group.
@@ -62,15 +50,22 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
62
50
  const { AGORIC_CMD = JSON.stringify(defaultAgoricCmd()) } = process.env;
63
51
  const agoricCmd = JSON.parse(AGORIC_CMD);
64
52
  function myMain(args, opts = {}) {
65
- // console.error('running agoric-cli', ...extraArgs, ...args);
66
53
  return pspawnStdout(agoricCmd[0], [...agoricCmd.slice(1), ...args], {
67
54
  stdio: ['ignore', 'pipe', 'inherit'],
68
- env: { ...process.env, DEBUG: 'agoric' },
55
+ env: { ...process.env, DEBUG: 'agoric:debug' },
69
56
  detached: true,
70
57
  ...opts,
71
58
  });
72
59
  }
73
60
 
61
+ function yarn(args) {
62
+ return pspawnStdout('yarn', args, {
63
+ stdio: ['ignore', 'pipe', 'inherit'],
64
+ env: { ...process.env },
65
+ detached: true,
66
+ });
67
+ }
68
+
74
69
  const olddir = process.cwd();
75
70
  const { name } = tmp.dirSync({
76
71
  unsafeCleanup: true,
@@ -84,7 +79,7 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
84
79
  try {
85
80
  f();
86
81
  } catch (e) {
87
- // console.log(e);
82
+ console.log(e);
88
83
  }
89
84
  }
90
85
  if (sig) {
@@ -93,6 +88,7 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
93
88
  }
94
89
  };
95
90
 
91
+ await null;
96
92
  try {
97
93
  process.on('SIGINT', runFinalizers);
98
94
  process.on('exit', runFinalizers);
@@ -105,118 +101,32 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
105
101
  initOptions.push(...opts);
106
102
  }
107
103
  t.is(
108
- await myMain([
109
- 'init',
110
- '--dapp-template',
111
- 'dapp-fungible-faucet',
112
- ...initOptions,
113
- 'dapp-foo',
114
- ]),
104
+ await myMain(['init', ...initOptions, 'dapp-foo']),
115
105
  0,
116
106
  'init dapp-foo works',
117
107
  );
118
108
  process.chdir('dapp-foo');
119
109
 
120
110
  // ==============
121
- // agoric install
122
- if (process.env.AGORIC_INSTALL_OPTIONS) {
123
- const opts = JSON.parse(process.env.AGORIC_INSTALL_OPTIONS);
124
- installOptions.push(...opts);
125
- }
126
- t.is(await myMain(['install', ...installOptions]), 0, 'install works');
111
+ // yarn install
112
+ t.is(await yarn(['install']), 0, 'yarn install works');
127
113
 
128
114
  // ==============
129
- // agoric start --reset
130
- const startResult = makePromiseKit();
115
+ // yarn start:docker
116
+ t.is(await yarn(['start:docker']), 0, 'yarn start:docker works');
131
117
 
132
- if (process.env.AGORIC_START_OPTIONS) {
133
- const opts = JSON.parse(process.env.AGORIC_START_OPTIONS);
134
- startOptions.push(...opts);
135
- }
136
-
137
- // TODO: Allow this to work even if the port is already used.
138
- const startP = myMain(['start', '--reset', ...startOptions]);
139
- finalizers.push(() => pkill(startP.childProcess, 'SIGINT'));
140
-
141
- let stdoutStr = '';
142
- if (startP.childProcess.stdout) {
143
- startP.childProcess.stdout.on('data', chunk => {
144
- // console.log('stdout:', chunk.toString());
145
- stdoutStr += chunk.toString();
146
- if (stdoutStr.match(/(^|:\s+)swingset running$/m)) {
147
- startResult.resolve(true);
148
- }
149
- });
150
- }
151
- startP.childProcess.on('close', code =>
152
- startResult.reject(Error(`early termination: ${code}`)),
153
- );
154
-
155
- const timeout = setTimeout(
156
- startResult.reject,
157
- TIMEOUT_SECONDS * 1000,
158
- 'timeout',
159
- );
160
- t.is(await startResult.promise, true, `swingset running before timeout`);
161
- clearTimeout(timeout);
162
-
163
- const testDeploy = async (deployCmd, opts = {}) => {
164
- const deployResult = makePromiseKit();
165
- const deployP = myMain(
166
- ['deploy', `--hostport=127.0.0.1:${PORT}`, ...deployCmd],
167
- {
168
- stdio: [opts.stdin ? 'pipe' : 'ignore', 'pipe', 'inherit'],
169
- },
170
- );
171
-
172
- if (opts.stdin) {
173
- // Write the input to stdin.
174
- deployP.childProcess.stdin.write(opts.stdin);
175
- deployP.childProcess.stdin.end();
176
- }
177
-
178
- finalizers.push(() => pkill(deployP.childProcess, 'SIGINT'));
179
- const to = setTimeout(
180
- deployResult.resolve,
181
- TIMEOUT_SECONDS * 1000,
182
- 'timeout',
183
- );
184
- const done = await Promise.race([deployResult.promise, deployP]);
185
- t.is(done, 0, `deploy ${deployCmd.join(' ')} successful before timeout`);
186
- clearTimeout(to);
187
- };
118
+ // XXX: use abci_info endpoint to get block height
119
+ // sleep to let contract start
120
+ await new Promise(resolve => setTimeout(resolve, TIMEOUT_SECONDS));
188
121
 
189
122
  // ==============
190
- // agoric deploy ./contract/deploy.js ./api/deploy.js
191
- await testDeploy(['./contract/deploy.js', './api/deploy.js']);
192
-
193
- for (const [suffix, code] of [
194
- ['/notthere', 404],
195
- ['', 200],
196
- ]) {
197
- let urlResolve;
198
- const url = `http://127.0.0.1:${PORT}${suffix}`;
199
- const urlP = new Promise(resolve => (urlResolve = resolve));
200
- const urlReq = request(url, res => urlResolve(res.statusCode));
201
- urlReq.setTimeout(2000);
202
- urlReq.on('error', err => urlResolve(`Cannot connect to ${url}: ${err}`));
203
- urlReq.end();
204
- const urlTimeout = setTimeout(urlResolve, 3000, 'timeout');
205
- // eslint-disable-next-line no-await-in-loop
206
- const urlDone = await urlP;
207
- clearTimeout(urlTimeout);
208
- t.is(urlDone, code, `${url} gave status ${code}`);
209
- }
123
+ // yarn start:contract
124
+ t.is(await yarn(['start:contract']), 0, 'yarn start:contract works');
210
125
 
211
126
  // ==============
212
- // cd ui && yarn start
213
- const uiStartP = pspawn(`yarn`, ['start'], {
214
- stdio: ['ignore', 'inherit', 'inherit'],
215
- cwd: 'ui',
216
- env: { ...process.env, PORT: '3000' },
217
- detached: true,
218
- });
219
- finalizers.push(() => pkill(uiStartP.childProcess, 'SIGINT'));
127
+ // yarn start:ui
128
+ const startUiP = yarn(['start:ui']);
129
+ finalizers.push(() => pkill(startUiP.childProcess, 'SIGINT'));
220
130
  const uiListening = makePromiseKit();
221
131
  let retries = 0;
222
132
  const ival = setInterval(() => {
@@ -232,7 +142,7 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
232
142
  return;
233
143
  }
234
144
 
235
- const req = request('http://localhost:3000/', _res => {
145
+ const req = request('http://localhost:5173/', _res => {
236
146
  resolve('listening');
237
147
  });
238
148
  req.setTimeout(2000);
@@ -247,20 +157,11 @@ export const gettingStartedWorkflowTest = async (t, options = {}) => {
247
157
  }
248
158
  }, 3000);
249
159
  t.is(
250
- await Promise.race([uiStartP, uiListening.promise]),
160
+ await Promise.race([startUiP, uiListening.promise]),
251
161
  'listening',
252
- `cd ui && yarn start succeeded`,
162
+ `yarn start:ui succeeded`,
253
163
  );
254
164
  clearInterval(ival);
255
-
256
- // Test that the Node.js `-r esm`-dependent plugin works.
257
- await (testUnsafePlugins &&
258
- testDeploy(
259
- ['--allow-unsafe-plugins', `${dirname}/resm-plugin/deploy.js`],
260
- { stdin: 'yes\n' },
261
- ));
262
-
263
- // TODO: When it exists, Test that the Node.js native ESM plugin works.
264
165
  } finally {
265
166
  runFinalizers();
266
167
  process.off('SIGINT', runFinalizers);
@@ -1,5 +1,4 @@
1
1
  /* globals setTimeout */
2
- // eslint-disable-next-line import/no-extraneous-dependencies
3
2
  import { E } from '@endo/eventual-send';
4
3
 
5
4
  const PONG_TIMEOUT = 10_000;
@@ -1,5 +1,12 @@
1
1
  {
2
2
  "name": "@agoric/test-resm-plugin",
3
3
  "version": "1.0.0",
4
- "type": "commonjs"
4
+ "type": "commonjs",
5
+ "dependencies": {
6
+ "@endo/eventual-send": "^0.17.2",
7
+ "@endo/marshal": "^0.8.5"
8
+ },
9
+ "typeCoverage": {
10
+ "atLeast": 0
11
+ }
5
12
  }
@@ -1,6 +1,5 @@
1
1
  // @jessie-check
2
2
 
3
- // eslint-disable-next-line import/no-extraneous-dependencies
4
3
  import { Far } from '@endo/marshal';
5
4
  import { start } from './output.js';
6
5