prool 0.0.25 → 0.1.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.
Files changed (114) hide show
  1. package/{LICENSE → LICENSE.md} +1 -1
  2. package/README.md +46 -163
  3. package/{_lib/instance.d.ts → dist/Instance.d.ts} +28 -25
  4. package/dist/Instance.d.ts.map +1 -0
  5. package/{_lib/instance.js → dist/Instance.js} +9 -4
  6. package/dist/Instance.js.map +1 -0
  7. package/{_lib/pool.d.ts → dist/Pool.d.ts} +15 -13
  8. package/dist/Pool.d.ts.map +1 -0
  9. package/{_lib/pool.js → dist/Pool.js} +3 -3
  10. package/dist/Pool.js.map +1 -0
  11. package/{_lib/server.d.ts → dist/Server.d.ts} +7 -10
  12. package/dist/Server.d.ts.map +1 -0
  13. package/{_lib/server.js → dist/Server.js} +8 -9
  14. package/dist/Server.js.map +1 -0
  15. package/dist/index.d.ts +4 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +4 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/instances/alto.d.ts +452 -0
  20. package/dist/instances/alto.d.ts.map +1 -0
  21. package/{_lib → dist}/instances/alto.js +4 -4
  22. package/dist/instances/alto.js.map +1 -0
  23. package/dist/instances/anvil.d.ts +458 -0
  24. package/dist/instances/anvil.d.ts.map +1 -0
  25. package/{_lib → dist}/instances/anvil.js +4 -4
  26. package/dist/instances/anvil.js.map +1 -0
  27. package/dist/instances/tempo.d.ts +157 -0
  28. package/dist/instances/tempo.d.ts.map +1 -0
  29. package/dist/instances/tempo.js +187 -0
  30. package/dist/instances/tempo.js.map +1 -0
  31. package/dist/internal/utils.d.ts.map +1 -0
  32. package/{_lib → dist/internal}/utils.js +1 -1
  33. package/dist/internal/utils.js.map +1 -0
  34. package/{_lib → dist}/processes/execa.d.ts +11 -10
  35. package/dist/processes/execa.d.ts.map +1 -0
  36. package/{_lib → dist}/processes/execa.js +1 -1
  37. package/dist/processes/execa.js.map +1 -0
  38. package/package.json +17 -16
  39. package/{instance.test.ts → src/Instance.test.ts} +12 -12
  40. package/{instance.ts → src/Instance.ts} +51 -42
  41. package/{pool.test.ts → src/Pool.test.ts} +41 -55
  42. package/{pool.ts → src/Pool.ts} +21 -19
  43. package/{server.test.ts → src/Server.test.ts} +26 -149
  44. package/{server.ts → src/Server.ts} +9 -11
  45. package/src/index.ts +3 -0
  46. package/{instances → src/instances}/alto.test.ts +8 -11
  47. package/src/instances/alto.ts +289 -0
  48. package/{instances → src/instances}/anvil.test.ts +5 -6
  49. package/src/instances/anvil.ts +306 -0
  50. package/{instances/silius.test.ts → src/instances/tempo.test.ts} +20 -44
  51. package/src/instances/tempo.ts +278 -0
  52. package/{utils.test.ts → src/internal/utils.test.ts} +6 -6
  53. package/{utils.ts → src/internal/utils.ts} +1 -1
  54. package/{processes → src/processes}/execa.test.ts +6 -11
  55. package/{processes → src/processes}/execa.ts +19 -15
  56. package/src/processes/index.ts +1 -0
  57. package/CHANGELOG.md +0 -154
  58. package/_lib/exports/index.d.ts +0 -5
  59. package/_lib/exports/index.d.ts.map +0 -1
  60. package/_lib/exports/index.js +0 -5
  61. package/_lib/exports/index.js.map +0 -1
  62. package/_lib/exports/instances.d.ts +0 -7
  63. package/_lib/exports/instances.d.ts.map +0 -1
  64. package/_lib/exports/instances.js +0 -7
  65. package/_lib/exports/instances.js.map +0 -1
  66. package/_lib/exports/processes.d.ts +0 -2
  67. package/_lib/exports/processes.d.ts.map +0 -1
  68. package/_lib/exports/processes.js +0 -2
  69. package/_lib/exports/processes.js.map +0 -1
  70. package/_lib/instance.d.ts.map +0 -1
  71. package/_lib/instance.js.map +0 -1
  72. package/_lib/instances/alto.d.ts +0 -449
  73. package/_lib/instances/alto.d.ts.map +0 -1
  74. package/_lib/instances/alto.js.map +0 -1
  75. package/_lib/instances/anvil.d.ts +0 -455
  76. package/_lib/instances/anvil.d.ts.map +0 -1
  77. package/_lib/instances/anvil.js.map +0 -1
  78. package/_lib/instances/rundler.d.ts +0 -604
  79. package/_lib/instances/rundler.d.ts.map +0 -1
  80. package/_lib/instances/rundler.js +0 -86
  81. package/_lib/instances/rundler.js.map +0 -1
  82. package/_lib/instances/silius.d.ts +0 -224
  83. package/_lib/instances/silius.d.ts.map +0 -1
  84. package/_lib/instances/silius.js +0 -117
  85. package/_lib/instances/silius.js.map +0 -1
  86. package/_lib/instances/stackup.d.ts +0 -86
  87. package/_lib/instances/stackup.d.ts.map +0 -1
  88. package/_lib/instances/stackup.js +0 -89
  89. package/_lib/instances/stackup.js.map +0 -1
  90. package/_lib/pool.d.ts.map +0 -1
  91. package/_lib/pool.js.map +0 -1
  92. package/_lib/processes/execa.d.ts.map +0 -1
  93. package/_lib/processes/execa.js.map +0 -1
  94. package/_lib/server.d.ts.map +0 -1
  95. package/_lib/server.js.map +0 -1
  96. package/_lib/utils.d.ts.map +0 -1
  97. package/_lib/utils.js.map +0 -1
  98. package/exports/index.test.ts +0 -16
  99. package/exports/index.ts +0 -29
  100. package/exports/instances.test.ts +0 -15
  101. package/exports/instances.ts +0 -13
  102. package/exports/processes.test.ts +0 -10
  103. package/exports/processes.ts +0 -8
  104. package/instances/alto.ts +0 -280
  105. package/instances/anvil.ts +0 -304
  106. package/instances/package.json +0 -5
  107. package/instances/rundler.test.ts +0 -111
  108. package/instances/rundler.ts +0 -451
  109. package/instances/silius.ts +0 -347
  110. package/instances/stackup.test.ts +0 -106
  111. package/instances/stackup.ts +0 -162
  112. package/processes/package.json +0 -5
  113. package/tsconfig.build.tsbuildinfo +0 -1
  114. /package/{_lib → dist/internal}/utils.d.ts +0 -0
@@ -1,22 +1,17 @@
1
1
  import getPort from 'get-port'
2
+ import { Instance, Pool, Server } from 'prool'
2
3
  import { afterEach, beforeAll, describe, expect, test } from 'vitest'
3
4
 
4
- import { altoOptions, rundlerOptions, stackupOptions } from '../test/utils.js'
5
- import { rundler } from './exports/instances.js'
6
- import { alto } from './instances/alto.js'
7
- import { anvil } from './instances/anvil.js'
8
- import { stackup } from './instances/stackup.js'
9
- import { definePool } from './pool.js'
10
- import { createServer } from './server.js'
5
+ import { altoOptions } from '../test/utils.js'
11
6
 
12
- let pool: ReturnType<typeof definePool>
7
+ let pool: ReturnType<typeof Pool.define>
13
8
  const port = await getPort()
14
9
 
15
10
  beforeAll(() =>
16
- createServer({
17
- instance: anvil({
11
+ Server.create({
12
+ instance: Instance.anvil({
18
13
  chainId: 1,
19
- forkUrl: process.env.VITE_FORK_URL ?? 'https://eth.merkle.io',
14
+ forkUrl: process.env['VITE_FORK_URL'] ?? 'https://eth.merkle.io',
20
15
  }),
21
16
  port,
22
17
  }).start(),
@@ -31,19 +26,14 @@ afterEach(async () => {
31
26
  })
32
27
 
33
28
  describe.each([
34
- { instance: anvil({ port: await getPort() }) },
29
+ { instance: Instance.anvil({ port: await getPort() }) },
30
+ { instance: Instance.tempo({ port: await getPort() }) },
35
31
  {
36
- instance: alto(altoOptions({ port, pool: true })),
37
- },
38
- {
39
- instance: stackup(stackupOptions({ port, pool: true })),
40
- },
41
- {
42
- instance: rundler(rundlerOptions({ port, pool: true })),
32
+ instance: Instance.alto(altoOptions({ port, pool: true })),
43
33
  },
44
34
  ])('instance: $instance.name', ({ instance }) => {
45
35
  test('default', async () => {
46
- pool = definePool({
36
+ pool = Pool.define({
47
37
  instance,
48
38
  })
49
39
 
@@ -51,7 +41,7 @@ describe.each([
51
41
  })
52
42
 
53
43
  test('start', async () => {
54
- pool = definePool({
44
+ pool = Pool.define({
55
45
  instance,
56
46
  })
57
47
 
@@ -72,7 +62,7 @@ describe.each([
72
62
 
73
63
  test('callback instance', async () => {
74
64
  const keys: (number | string)[] = []
75
- pool = definePool({
65
+ pool = Pool.define({
76
66
  instance(key) {
77
67
  keys.push(key)
78
68
  return instance
@@ -87,7 +77,7 @@ describe.each([
87
77
  })
88
78
 
89
79
  test('stop / destroy', async () => {
90
- pool = definePool({
80
+ pool = Pool.define({
91
81
  instance,
92
82
  })
93
83
 
@@ -124,32 +114,28 @@ describe.each([
124
114
  expect(pool.size).toEqual(0)
125
115
  })
126
116
 
127
- test(
128
- 'restart',
129
- async () => {
130
- pool = definePool({
131
- instance,
132
- })
133
-
134
- const instance_1 = await pool.start(1)
135
- const instance_2 = await pool.start(2)
136
- const instance_3 = await pool.start(3)
137
-
138
- expect(instance_1.status).toBe('started')
139
- expect(instance_2.status).toBe('started')
140
- expect(instance_3.status).toBe('started')
141
- expect(pool.size).toEqual(3)
142
-
143
- const promise_1 = pool.restart(1)
144
- expect(instance_1.status).toBe('restarting')
145
- await promise_1
146
- expect(instance_1.status).toBe('started')
147
- },
148
- { timeout: 10_000 },
149
- )
117
+ test('restart', { timeout: 10_000 }, async () => {
118
+ pool = Pool.define({
119
+ instance,
120
+ })
121
+
122
+ const instance_1 = await pool.start(1)
123
+ const instance_2 = await pool.start(2)
124
+ const instance_3 = await pool.start(3)
125
+
126
+ expect(instance_1.status).toBe('started')
127
+ expect(instance_2.status).toBe('started')
128
+ expect(instance_3.status).toBe('started')
129
+ expect(pool.size).toEqual(3)
130
+
131
+ const promise_1 = pool.restart(1)
132
+ expect(instance_1.status).toBe('restarting')
133
+ await promise_1
134
+ expect(instance_1.status).toBe('started')
135
+ })
150
136
 
151
137
  test('start > stop > start', async () => {
152
- pool = definePool({
138
+ pool = Pool.define({
153
139
  instance,
154
140
  })
155
141
 
@@ -164,7 +150,7 @@ describe.each([
164
150
  })
165
151
 
166
152
  test('stopAll / destroyAll', async () => {
167
- pool = definePool({
153
+ pool = Pool.define({
168
154
  instance,
169
155
  })
170
156
 
@@ -182,7 +168,7 @@ describe.each([
182
168
  })
183
169
 
184
170
  test('get', async () => {
185
- pool = definePool({
171
+ pool = Pool.define({
186
172
  instance,
187
173
  })
188
174
 
@@ -196,7 +182,7 @@ describe.each([
196
182
  })
197
183
 
198
184
  test('behavior: start more than once', async () => {
199
- pool = definePool({
185
+ pool = Pool.define({
200
186
  instance,
201
187
  })
202
188
 
@@ -210,7 +196,7 @@ describe.each([
210
196
  })
211
197
 
212
198
  test('behavior: clear more than once', async () => {
213
- pool = definePool({
199
+ pool = Pool.define({
214
200
  instance,
215
201
  })
216
202
 
@@ -227,7 +213,7 @@ describe.each([
227
213
  })
228
214
 
229
215
  test('behavior: restart more than once', async () => {
230
- pool = definePool({
216
+ pool = Pool.define({
231
217
  instance,
232
218
  })
233
219
 
@@ -248,7 +234,7 @@ describe.each([
248
234
  })
249
235
 
250
236
  test('behavior: stop more than once', async () => {
251
- pool = definePool({
237
+ pool = Pool.define({
252
238
  instance,
253
239
  })
254
240
 
@@ -265,7 +251,7 @@ describe.each([
265
251
  test('error: start more than once on same port', async () => {
266
252
  const port = await getPort()
267
253
 
268
- pool = definePool({
254
+ pool = Pool.define({
269
255
  instance,
270
256
  })
271
257
 
@@ -280,7 +266,7 @@ describe.each([
280
266
  })
281
267
 
282
268
  test('error: instance limit reached', async () => {
283
- pool = definePool({
269
+ pool = Pool.define({
284
270
  instance,
285
271
  limit: 2,
286
272
  })
@@ -1,6 +1,6 @@
1
1
  import getPort from 'get-port'
2
2
 
3
- import type { Instance } from './instance.js'
3
+ import type { Instance } from './Instance.js'
4
4
 
5
5
  type Instance_ = Omit<Instance, 'create'>
6
6
 
@@ -14,30 +14,20 @@ export type Pool<key extends number | string = number | string> = Pick<
14
14
  destroy(key: key): Promise<void>
15
15
  destroyAll(): Promise<void>
16
16
  restart(key: key): Promise<void>
17
- start(key: key, options?: { port?: number }): Promise<Instance_>
17
+ start(
18
+ key: key,
19
+ options?: { port?: number | undefined } | undefined,
20
+ ): Promise<Instance_>
18
21
  stop(key: key): Promise<void>
19
22
  stopAll(): Promise<void>
20
23
  }
21
24
 
22
- export type DefinePoolParameters<
23
- key extends number | string = number | string,
24
- > = {
25
- /** Instance for the pool. */
26
- instance: Instance | ((key: key) => Instance)
27
- /** The maximum number of instances that can be started. */
28
- limit?: number | number
29
- }
30
-
31
- export type DefinePoolReturnType<
32
- key extends number | string = number | string,
33
- > = Pool<key>
34
-
35
25
  /**
36
26
  * Defines an instance pool. Instances can be started, cached, and stopped against an identifier.
37
27
  *
38
28
  * @example
39
29
  * ```
40
- * const pool = definePool({
30
+ * const pool = Pool.define({
41
31
  * instance: anvil(),
42
32
  * })
43
33
  *
@@ -46,9 +36,9 @@ export type DefinePoolReturnType<
46
36
  * const instance_3 = await pool.start(3)
47
37
  * ```
48
38
  */
49
- export function definePool<key extends number | string = number>(
50
- parameters: DefinePoolParameters<key>,
51
- ): DefinePoolReturnType<key> {
39
+ export function define<key extends number | string = number>(
40
+ parameters: define.Parameters<key>,
41
+ ): define.ReturnType<key> {
52
42
  const { limit } = parameters
53
43
 
54
44
  type Instance_ = Omit<Instance, 'create'>
@@ -198,3 +188,15 @@ export function definePool<key extends number | string = number>(
198
188
  values: instances.values.bind(instances),
199
189
  }
200
190
  }
191
+
192
+ export declare namespace define {
193
+ export type Parameters<key extends number | string = number | string> = {
194
+ /** Instance for the pool. */
195
+ instance: Instance | ((key: key) => Instance)
196
+ /** The maximum number of instances that can be started. */
197
+ limit?: number | undefined
198
+ }
199
+
200
+ export type ReturnType<key extends number | string = number | string> =
201
+ Pool<key>
202
+ }
@@ -1,44 +1,30 @@
1
1
  import getPort from 'get-port'
2
+ import { Instance, Server } from 'prool'
2
3
  import { beforeAll, describe, expect, test } from 'vitest'
3
4
  import { type MessageEvent, WebSocket } from 'ws'
4
- import {
5
- altoOptions,
6
- rundlerOptions,
7
- siliusOptions,
8
- stackupOptions,
9
- } from '../test/utils.js'
10
- import { rundler, silius } from './exports/instances.js'
11
- import { alto } from './instances/alto.js'
12
- import { anvil } from './instances/anvil.js'
13
- import { stackup } from './instances/stackup.js'
14
- import { createServer } from './server.js'
5
+ import { altoOptions } from '../test/utils.js'
15
6
 
16
7
  const port = await getPort()
17
8
 
18
9
  beforeAll(async () => {
19
- await createServer({
20
- instance: anvil({
10
+ await Server.create({
11
+ instance: Instance.anvil({
21
12
  chainId: 1,
22
- forkUrl: process.env.VITE_FORK_URL ?? 'https://eth.merkle.io',
13
+ forkUrl: process.env['VITE_FORK_URL'] ?? 'https://eth.merkle.io',
23
14
  }),
24
15
  port,
25
16
  }).start()
26
17
  })
27
18
 
28
19
  describe.each([
29
- { instance: anvil() },
20
+ { instance: Instance.anvil({ port: await getPort() }) },
21
+ { instance: Instance.tempo({ port: await getPort() }) },
30
22
  {
31
- instance: alto(altoOptions({ port, pool: true })),
32
- },
33
- {
34
- instance: stackup(stackupOptions({ port, pool: true })),
35
- },
36
- {
37
- instance: rundler(rundlerOptions({ port, pool: true })),
23
+ instance: Instance.alto(altoOptions({ port, pool: true })),
38
24
  },
39
25
  ])('instance: $instance.name', ({ instance }) => {
40
26
  test('default', async () => {
41
- const server = createServer({
27
+ const server = Server.create({
42
28
  instance,
43
29
  })
44
30
  expect(server).toBeDefined()
@@ -59,7 +45,7 @@ describe.each([
59
45
  })
60
46
 
61
47
  test('args: port', async () => {
62
- const server = createServer({
48
+ const server = Server.create({
63
49
  instance,
64
50
  port: 3000,
65
51
  })
@@ -71,7 +57,7 @@ describe.each([
71
57
  })
72
58
 
73
59
  test('args: host', async () => {
74
- const server = createServer({
60
+ const server = Server.create({
75
61
  instance,
76
62
  host: 'localhost',
77
63
  port: 3000,
@@ -85,7 +71,7 @@ describe.each([
85
71
  })
86
72
 
87
73
  test('request: /healthcheck', async () => {
88
- const server = createServer({
74
+ const server = Server.create({
89
75
  instance,
90
76
  })
91
77
 
@@ -98,7 +84,7 @@ describe.each([
98
84
  })
99
85
 
100
86
  test('request: /start + /stop', async () => {
101
- const server = createServer({
87
+ const server = Server.create({
102
88
  instance,
103
89
  })
104
90
 
@@ -127,7 +113,7 @@ describe.each([
127
113
  })
128
114
 
129
115
  test('request: /restart', async () => {
130
- const server = createServer({
116
+ const server = Server.create({
131
117
  instance,
132
118
  })
133
119
 
@@ -142,8 +128,8 @@ describe.each([
142
128
 
143
129
  describe("instance: 'anvil'", () => {
144
130
  test('request: /{id}', async () => {
145
- const server = createServer({
146
- instance: anvil(),
131
+ const server = Server.create({
132
+ instance: Instance.anvil(),
147
133
  })
148
134
 
149
135
  const stop = await server.start()
@@ -253,8 +239,8 @@ describe("instance: 'anvil'", () => {
253
239
  })
254
240
 
255
241
  test('request: /restart', async () => {
256
- const server = createServer({
257
- instance: anvil(),
242
+ const server = Server.create({
243
+ instance: Instance.anvil(),
258
244
  })
259
245
 
260
246
  const stop = await server.start()
@@ -323,8 +309,8 @@ describe("instance: 'anvil'", () => {
323
309
  })
324
310
 
325
311
  test('request: /messages', async () => {
326
- const server = createServer({
327
- instance: anvil(),
312
+ const server = Server.create({
313
+ instance: Instance.anvil(),
328
314
  })
329
315
 
330
316
  const stop = await server.start()
@@ -352,8 +338,8 @@ describe("instance: 'anvil'", () => {
352
338
  })
353
339
 
354
340
  test('ws', async () => {
355
- const server = createServer({
356
- instance: anvil(),
341
+ const server = Server.create({
342
+ instance: Instance.anvil(),
357
343
  })
358
344
 
359
345
  const stop = await server.start()
@@ -380,8 +366,8 @@ describe("instance: 'anvil'", () => {
380
366
 
381
367
  describe("instance: 'alto'", () => {
382
368
  test('request: /{id}', async () => {
383
- const server = createServer({
384
- instance: alto(altoOptions({ port, pool: true })),
369
+ const server = Server.create({
370
+ instance: Instance.alto(altoOptions({ port, pool: true })),
385
371
  })
386
372
 
387
373
  const stop = await server.start()
@@ -413,118 +399,9 @@ describe("instance: 'alto'", () => {
413
399
  })
414
400
  })
415
401
 
416
- describe("instance: 'stackup'", () => {
417
- test('request: /{id}', async () => {
418
- const server = createServer({
419
- instance: stackup(stackupOptions({ port, pool: true })),
420
- })
421
-
422
- const stop = await server.start()
423
- const { port: port_2 } = server.address()!
424
- const response = await fetch(`http://localhost:${port_2}/1`, {
425
- body: JSON.stringify({
426
- method: 'eth_supportedEntryPoints',
427
- params: [],
428
- id: 0,
429
- jsonrpc: '2.0',
430
- }),
431
- headers: {
432
- 'Content-Type': 'application/json',
433
- },
434
- method: 'POST',
435
- })
436
- expect(response.status).toBe(200)
437
- expect(await response.json()).toMatchInlineSnapshot(`
438
- {
439
- "id": 0,
440
- "jsonrpc": "2.0",
441
- "result": [
442
- "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
443
- ],
444
- }
445
- `)
446
-
447
- await stop()
448
- })
449
- })
450
-
451
- describe("instance: 'rundler'", () => {
452
- test('request: /{id}', async () => {
453
- const server = createServer({
454
- instance: rundler(rundlerOptions({ port, pool: true })),
455
- })
456
-
457
- const stop = await server.start()
458
- const { port: port_2 } = server.address()!
459
- const response = await fetch(`http://localhost:${port_2}/1`, {
460
- body: JSON.stringify({
461
- method: 'eth_supportedEntryPoints',
462
- params: [],
463
- id: 0,
464
- jsonrpc: '2.0',
465
- }),
466
- headers: {
467
- 'Content-Type': 'application/json',
468
- },
469
- method: 'POST',
470
- })
471
- expect(response.status).toBe(200)
472
- expect(await response.json()).toMatchInlineSnapshot(`
473
- {
474
- "id": 0,
475
- "jsonrpc": "2.0",
476
- "result": [
477
- "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
478
- ],
479
- }
480
- `)
481
-
482
- await stop()
483
- })
484
- })
485
-
486
- describe("instance: 'silius'", () => {
487
- test(
488
- 'request: /{id}',
489
- async () => {
490
- const server = createServer({
491
- instance: silius(siliusOptions({ port, pool: true })),
492
- })
493
-
494
- const stop = await server.start()
495
- const { port: port_2 } = server.address()!
496
- const response = await fetch(`http://localhost:${port_2}/1`, {
497
- body: JSON.stringify({
498
- method: 'eth_supportedEntryPoints',
499
- params: [],
500
- id: 0,
501
- jsonrpc: '2.0',
502
- }),
503
- headers: {
504
- 'Content-Type': 'application/json',
505
- },
506
- method: 'POST',
507
- })
508
- expect(response.status).toBe(200)
509
- expect(await response.json()).toMatchInlineSnapshot(`
510
- {
511
- "id": 0,
512
- "jsonrpc": "2.0",
513
- "result": [
514
- "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
515
- ],
516
- }
517
- `)
518
-
519
- await stop()
520
- },
521
- { timeout: 10_000 },
522
- )
523
- })
524
-
525
402
  test('404', async () => {
526
- const server = createServer({
527
- instance: anvil(),
403
+ const server = Server.create({
404
+ instance: Instance.anvil(),
528
405
  })
529
406
 
530
407
  const stop = await server.start()
@@ -1,18 +1,17 @@
1
1
  import {
2
+ createServer as createServer_,
2
3
  type IncomingMessage,
3
4
  type Server,
4
5
  type ServerResponse,
5
- createServer as createServer_,
6
6
  } from 'node:http'
7
7
  import type { AddressInfo } from 'node:net'
8
8
  import httpProxy from 'http-proxy'
9
-
10
- import { type DefinePoolParameters, definePool } from './pool.js'
11
- import { extractPath } from './utils.js'
9
+ import { extractPath } from './internal/utils.js'
10
+ import * as Pool from './Pool.js'
12
11
 
13
12
  const { createProxyServer } = httpProxy
14
13
 
15
- export type CreateServerParameters = DefinePoolParameters<number> &
14
+ export type CreateServerParameters = Pool.define.Parameters<number> &
16
15
  (
17
16
  | {
18
17
  /** Host to run the server on. */
@@ -40,11 +39,10 @@ export type CreateServerReturnType = Omit<
40
39
  *
41
40
  * @example
42
41
  * ```
43
- * import { createServer } from 'prool'
44
- * import { anvil } from 'prool/instances'
42
+ * import { Instance, Server } from 'prool'
45
43
  *
46
- * const server = createServer({
47
- * instance: anvil(),
44
+ * const server = Server.create({
45
+ * instance: Instance.anvil(),
48
46
  * })
49
47
  *
50
48
  * const server = await server.start()
@@ -59,12 +57,12 @@ export type CreateServerReturnType = Omit<
59
57
  * // "http://localhost:8545/healthcheck"
60
58
  * ```
61
59
  */
62
- export function createServer(
60
+ export function create(
63
61
  parameters: CreateServerParameters,
64
62
  ): CreateServerReturnType {
65
63
  const { host = '::', instance, limit, port } = parameters
66
64
 
67
- const pool = definePool({ instance, limit })
65
+ const pool = Pool.define({ instance, limit })
68
66
  const proxy = createProxyServer({
69
67
  ignorePath: true,
70
68
  ws: true,
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * as Instance from './Instance.js'
2
+ export * as Pool from './Pool.js'
3
+ export * as Server from './Server.js'
@@ -1,17 +1,14 @@
1
1
  import getPort from 'get-port'
2
+ import { Instance } from 'prool'
2
3
  import { afterEach, beforeAll, expect, test } from 'vitest'
3
-
4
4
  import { altoOptions } from '../../test/utils.js'
5
- import type { Instance } from '../instance.js'
6
- import { type AltoParameters, alto } from './alto.js'
7
- import { anvil } from './anvil.js'
8
5
 
9
- const instances: Instance[] = []
6
+ const instances: Instance.Instance[] = []
10
7
 
11
8
  const port = await getPort()
12
9
 
13
- const defineInstance = (parameters: Partial<AltoParameters> = {}) => {
14
- const instance = alto({
10
+ const defineInstance = (parameters: Partial<Instance.alto.Parameters> = {}) => {
11
+ const instance = Instance.alto({
15
12
  ...altoOptions({ port, pool: false }),
16
13
  ...parameters,
17
14
  })
@@ -20,8 +17,8 @@ const defineInstance = (parameters: Partial<AltoParameters> = {}) => {
20
17
  }
21
18
 
22
19
  beforeAll(() =>
23
- anvil({
24
- forkUrl: process.env.VITE_FORK_URL ?? 'https://eth.merkle.io',
20
+ Instance.anvil({
21
+ forkUrl: process.env['VITE_FORK_URL'] ?? 'https://eth.merkle.io',
25
22
  port,
26
23
  }).start(),
27
24
  )
@@ -64,7 +61,7 @@ test.skip('behavior: instance errored (duplicate ports)', async () => {
64
61
  await expect(() => instance_2.start()).rejects.toThrowError()
65
62
  })
66
63
 
67
- test('behavior: start and stop multiple times', async () => {
64
+ test.skip('behavior: start and stop multiple times', async () => {
68
65
  const instance = defineInstance()
69
66
 
70
67
  await instance.start()
@@ -100,7 +97,7 @@ test.skip('behavior: can subscribe to stderr', async () => {
100
97
  test('behavior: exit', async () => {
101
98
  const instance = defineInstance()
102
99
 
103
- let exitCode: number | null | undefined = undefined
100
+ let exitCode: number | null | undefined
104
101
  instance.on('exit', (code) => {
105
102
  exitCode = code
106
103
  })