4
4
import childProcessAmbient from 'child_process' ;
5
5
import { promises as fsAmbientPromises } from 'fs' ;
6
6
import { resolve as importMetaResolve } from 'import-meta-resolve' ;
7
+ import { createRequire } from 'node:module' ;
7
8
import { basename , join } from 'path' ;
8
9
import { inspect } from 'util' ;
9
10
@@ -52,14 +53,11 @@ import type { BridgeHandler, IBCDowncallMethod, IBCMethod } from '@agoric/vats';
52
53
import type { BootstrapRootObject } from '@agoric/vats/src/core/lib-boot.js' ;
53
54
import type { EProxy } from '@endo/eventual-send' ;
54
55
import { tmpdir } from 'node:os' ;
56
+ import { create } from 'node:domain' ;
55
57
import { icaMocks , protoMsgMockMap , protoMsgMocks } from './ibc/mocks.js' ;
56
58
57
59
const trace = makeTracer ( 'BSTSupport' , false ) ;
58
60
59
- /** @param {string } spec package resource specifier */
60
- const importSpec = spec =>
61
- new URL ( importMetaResolve ( spec , import . meta. url ) ) . pathname ;
62
-
63
61
type ConsumeBootrapItem = < N extends string > (
64
62
name : N ,
65
63
) => N extends keyof FastUSDCCorePowers [ 'consume' ]
@@ -190,7 +188,11 @@ interface Powers {
190
188
* @param powers.fs - Node fs/promises module for file operations
191
189
* @returns A function that builds and extracts proposal data
192
190
*/
193
- export const makeProposalExtractor = ( { childProcess, fs } : Powers ) => {
191
+ export const makeProposalExtractor = (
192
+ { childProcess, fs } : Powers ,
193
+ resolveBase = import . meta. url ,
194
+ ) => {
195
+ const importSpec = createRequire ( resolveBase ) . resolve ;
194
196
const runPackageScript = (
195
197
outputDir : string ,
196
198
scriptPath : string ,
@@ -400,6 +402,7 @@ type AckBehaviorType = (typeof AckBehavior)[keyof typeof AckBehavior];
400
402
* @param options.debugVats - Array of vat names to debug
401
403
* @param options.defaultManagerType - SwingSet manager type to use
402
404
* @param options.harness - Optional run harness
405
+ * @param options.resolveBase - Base URL or path for resolving module paths
403
406
* @returns A test kit with various utilities for interacting with the SwingSet
404
407
*/
405
408
export const makeSwingsetTestKit = async (
@@ -415,8 +418,10 @@ export const makeSwingsetTestKit = async (
415
418
debugVats = [ ] as string [ ] ,
416
419
defaultManagerType = 'local' as ManagerType ,
417
420
harness = undefined as RunHarness | undefined ,
421
+ resolveBase = import . meta. url ,
418
422
} = { } ,
419
423
) => {
424
+ const importSpec = createRequire ( resolveBase ) . resolve ;
420
425
console . time ( 'makeBaseSwingsetTestKit' ) ;
421
426
const configPath = await getNodeTestVaultsConfig ( {
422
427
bundleDir,
0 commit comments