prool 0.2.4 → 0.2.6
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/dist/Instance.d.ts +1 -0
- package/dist/Instance.d.ts.map +1 -1
- package/dist/Instance.js +1 -0
- package/dist/Instance.js.map +1 -1
- package/dist/instances/tempo.d.ts +20 -0
- package/dist/instances/tempo.d.ts.map +1 -1
- package/dist/instances/tempo.js +7 -1
- package/dist/instances/tempo.js.map +1 -1
- package/dist/instances/tempoZone.d.ts +151 -0
- package/dist/instances/tempoZone.d.ts.map +1 -0
- package/dist/instances/tempoZone.js +116 -0
- package/dist/instances/tempoZone.js.map +1 -0
- package/dist/processes/execa.d.ts.map +1 -1
- package/dist/processes/execa.js +4 -3
- package/dist/processes/execa.js.map +1 -1
- package/dist/testcontainers/Instance.d.ts +70 -0
- package/dist/testcontainers/Instance.d.ts.map +1 -1
- package/dist/testcontainers/Instance.js +157 -1
- package/dist/testcontainers/Instance.js.map +1 -1
- package/package.json +1 -1
- package/src/Instance.ts +1 -0
- package/src/instances/tempo.test.ts +87 -0
- package/src/instances/tempo.ts +19 -1
- package/src/instances/tempoZone.test.ts +60 -0
- package/src/instances/tempoZone.ts +207 -0
- package/src/processes/execa.ts +4 -3
- package/src/testcontainers/Instance.test.ts +93 -1
- package/src/testcontainers/Instance.ts +226 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { GenericContainer, PullPolicy, Wait, } from 'testcontainers';
|
|
1
|
+
import { GenericContainer, Network, PullPolicy, Wait, } from 'testcontainers';
|
|
2
2
|
import * as Instance from '../Instance.js';
|
|
3
3
|
import { command } from '../instances/tempo.js';
|
|
4
|
+
import { command as zoneCommand, } from '../instances/tempoZone.js';
|
|
4
5
|
import * as ContainerOptions from './containerOptions.js';
|
|
5
6
|
/**
|
|
6
7
|
* Defines a Tempo instance.
|
|
@@ -86,4 +87,159 @@ export const tempo = Instance.define((parameters) => {
|
|
|
86
87
|
},
|
|
87
88
|
};
|
|
88
89
|
});
|
|
90
|
+
/**
|
|
91
|
+
* Defines a Tempo Zone instance.
|
|
92
|
+
*
|
|
93
|
+
* Starts a Tempo dev L1 container and a zone container (`tempo-zone dev`) on a
|
|
94
|
+
* shared network, provisioning a fresh zone against the L1. Pass `l1.rpcUrl`
|
|
95
|
+
* to attach to an existing L1 instead (the URL must be reachable from inside
|
|
96
|
+
* the container, e.g. `ws://host.docker.internal:8546`).
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const instance = Instance.tempoZone({ port: 9545 })
|
|
101
|
+
* await instance.start()
|
|
102
|
+
* // ...
|
|
103
|
+
* await instance.stop()
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export const tempoZone = Instance.define((parameters) => {
|
|
107
|
+
const { containerName = `tempo-zone.${crypto.randomUUID()}`, image = 'ghcr.io/tempoxyz/tempo-zone:latest', l1: l1Parameters, log: log_, startupTimeout, ...args } = parameters || {};
|
|
108
|
+
const log = (() => {
|
|
109
|
+
try {
|
|
110
|
+
return JSON.parse(log_);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return log_;
|
|
114
|
+
}
|
|
115
|
+
})();
|
|
116
|
+
const RUST_LOG = log && typeof log !== 'boolean' ? log : '';
|
|
117
|
+
// L1 ports inside the container (only reachable over the shared network).
|
|
118
|
+
const l1HttpPort = 8545;
|
|
119
|
+
const l1WsPort = 8546;
|
|
120
|
+
const name = 'tempo-zone';
|
|
121
|
+
let container;
|
|
122
|
+
let l1Container;
|
|
123
|
+
let network;
|
|
124
|
+
async function teardown() {
|
|
125
|
+
if (container)
|
|
126
|
+
await container.stop().catch(() => { });
|
|
127
|
+
if (l1Container)
|
|
128
|
+
await l1Container.stop().catch(() => { });
|
|
129
|
+
if (network)
|
|
130
|
+
await network.stop().catch(() => { });
|
|
131
|
+
container = undefined;
|
|
132
|
+
l1Container = undefined;
|
|
133
|
+
network = undefined;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
_internal: {
|
|
137
|
+
args,
|
|
138
|
+
get l1() {
|
|
139
|
+
if (!l1Container)
|
|
140
|
+
return undefined;
|
|
141
|
+
return {
|
|
142
|
+
host: l1Container.getHost(),
|
|
143
|
+
port: l1Container.getMappedPort(l1HttpPort),
|
|
144
|
+
wsPort: l1Container.getMappedPort(l1WsPort),
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
host: args.host ?? 'localhost',
|
|
149
|
+
name,
|
|
150
|
+
port: args.port ?? 9545,
|
|
151
|
+
async start({ port = args.port }, { emitter, setEndpoint }) {
|
|
152
|
+
const containerPort = port ?? 9545;
|
|
153
|
+
const timeout = ContainerOptions.resolveStartupTimeout(startupTimeout);
|
|
154
|
+
const logConsumer = (reject) => (stream) => {
|
|
155
|
+
stream.on('data', (data) => {
|
|
156
|
+
const message = data.toString();
|
|
157
|
+
emitter.emit('message', message);
|
|
158
|
+
emitter.emit('stdout', message);
|
|
159
|
+
if (log)
|
|
160
|
+
console.log(message);
|
|
161
|
+
if (message.includes('shutting down'))
|
|
162
|
+
reject(new Error(`Failed to start: ${message}`));
|
|
163
|
+
});
|
|
164
|
+
stream.on('error', (error) => {
|
|
165
|
+
if (log)
|
|
166
|
+
console.error(error.message);
|
|
167
|
+
emitter.emit('message', error.message);
|
|
168
|
+
emitter.emit('stderr', error.message);
|
|
169
|
+
reject(new Error(`Failed to start: ${error.message}`));
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
try {
|
|
173
|
+
// Start a dev L1 on a shared network unless attaching to an existing one.
|
|
174
|
+
let l1RpcUrl = l1Parameters?.rpcUrl;
|
|
175
|
+
if (!l1RpcUrl) {
|
|
176
|
+
network = await new Network().start();
|
|
177
|
+
l1Container = await new GenericContainer(l1Parameters?.image ?? 'ghcr.io/tempoxyz/tempo:latest')
|
|
178
|
+
.withPullPolicy(PullPolicy.alwaysPull())
|
|
179
|
+
.withPlatform('linux/x86_64')
|
|
180
|
+
.withNetwork(network)
|
|
181
|
+
.withNetworkAliases('l1')
|
|
182
|
+
.withExposedPorts(l1HttpPort, l1WsPort)
|
|
183
|
+
.withName(`${containerName}.l1`)
|
|
184
|
+
.withEnvironment({ RUST_LOG })
|
|
185
|
+
.withCommand(command({
|
|
186
|
+
port: l1HttpPort,
|
|
187
|
+
// The zone anchors to the L1 over WebSocket.
|
|
188
|
+
ws: [true, { addr: '0.0.0.0', api: 'all', port: l1WsPort }],
|
|
189
|
+
}))
|
|
190
|
+
.withWaitStrategy(Wait.forLogMessage(/Received (block|new payload) from consensus engine/))
|
|
191
|
+
.withLogConsumer(logConsumer(() => {
|
|
192
|
+
// L1 shutdown surfaces via the zone container failing to start.
|
|
193
|
+
}))
|
|
194
|
+
.withStartupTimeout(timeout)
|
|
195
|
+
.start();
|
|
196
|
+
l1RpcUrl = `ws://l1:${l1WsPort}`;
|
|
197
|
+
}
|
|
198
|
+
const promise = Promise.withResolvers();
|
|
199
|
+
let c = new GenericContainer(image)
|
|
200
|
+
.withPullPolicy(PullPolicy.alwaysPull())
|
|
201
|
+
.withPlatform('linux/x86_64')
|
|
202
|
+
.withExposedPorts(containerPort)
|
|
203
|
+
.withExtraHosts([
|
|
204
|
+
{ host: 'host.docker.internal', ipAddress: 'host-gateway' },
|
|
205
|
+
])
|
|
206
|
+
.withName(containerName)
|
|
207
|
+
.withEnvironment({ RUST_LOG })
|
|
208
|
+
.withCommand(zoneCommand({
|
|
209
|
+
...args,
|
|
210
|
+
l1: {
|
|
211
|
+
...(l1Parameters?.factoryAddress
|
|
212
|
+
? { factoryAddress: l1Parameters.factoryAddress }
|
|
213
|
+
: {}),
|
|
214
|
+
rpcUrl: l1RpcUrl,
|
|
215
|
+
},
|
|
216
|
+
port: containerPort,
|
|
217
|
+
}))
|
|
218
|
+
.withWaitStrategy(Wait.forLogMessage('RPC HTTP server started'))
|
|
219
|
+
.withLogConsumer(logConsumer(promise.reject))
|
|
220
|
+
.withStartupTimeout(timeout);
|
|
221
|
+
if (network)
|
|
222
|
+
c = c.withNetwork(network);
|
|
223
|
+
c.start()
|
|
224
|
+
.then((started) => {
|
|
225
|
+
container = started;
|
|
226
|
+
setEndpoint?.({
|
|
227
|
+
host: started.getHost(),
|
|
228
|
+
port: started.getMappedPort(containerPort),
|
|
229
|
+
});
|
|
230
|
+
promise.resolve();
|
|
231
|
+
})
|
|
232
|
+
.catch(promise.reject);
|
|
233
|
+
await promise.promise;
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
await teardown();
|
|
237
|
+
throw error;
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
async stop() {
|
|
241
|
+
await teardown();
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
});
|
|
89
245
|
//# sourceMappingURL=Instance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.js","sourceRoot":"","sources":["../../src/testcontainers/Instance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,UAAU,
|
|
1
|
+
{"version":3,"file":"Instance.js","sourceRoot":"","sources":["../../src/testcontainers/Instance.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,UAAU,EAGV,IAAI,GACL,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAA4B,MAAM,uBAAuB,CAAA;AACzE,OAAO,EAEL,OAAO,IAAI,WAAW,GACvB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAIzD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,UAA6B,EAAE,EAAE;IACrE,MAAM,EACJ,aAAa,GAAG,SAAS,MAAM,CAAC,UAAU,EAAE,EAAE,EAC9C,KAAK,GAAG,+BAA+B,E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YAAY,EAAE,cAAc;4BAC9B,CAAC,CAAC,EAAE,cAAc,EAAE,YAAY,CAAC,cAAc,EAAE;4BACjD,CAAC,CAAC,EAAE,CAAC;wBACP,MAAM,EAAE,QAAQ;qBACjB;oBACD,IAAI,EAAE,aAAa;iBACpB,CAAC,CACH;qBACA,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;qBAC/D,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;qBAC5C,kBAAkB,CAAC,OAAO,CAAC,CAAA;gBAC9B,IAAI,OAAO;oBAAE,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;gBAEvC,CAAC,CAAC,KAAK,EAAE;qBACN,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;oBAChB,SAAS,GAAG,OAAO,CAAA;oBACnB,WAAW,EAAE,CAAC;wBACZ,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE;wBACvB,IAAI,EAAE,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC;qBAC3C,CAAC,CAAA;oBACF,OAAO,CAAC,OAAO,EAAE,CAAA;gBACnB,CAAC,CAAC;qBACD,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBAExB,MAAM,OAAO,CAAC,OAAO,CAAA;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,QAAQ,EAAE,CAAA;gBAChB,MAAM,KAAK,CAAA;YACb,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI;YACR,MAAM,QAAQ,EAAE,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC,CACF,CAAA"}
|
package/package.json
CHANGED
package/src/Instance.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { EventEmitter } from 'eventemitter3'
|
|
|
3
3
|
export { alto } from './instances/alto.js'
|
|
4
4
|
export { anvil } from './instances/anvil.js'
|
|
5
5
|
export { tempo } from './instances/tempo.js'
|
|
6
|
+
export { tempoZone } from './instances/tempoZone.js'
|
|
6
7
|
|
|
7
8
|
type EventTypes = {
|
|
8
9
|
exit: [code: number | null, signal: NodeJS.Signals | null]
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as os from 'node:os'
|
|
1
2
|
import getPort from 'get-port'
|
|
2
3
|
import { Instance } from 'prool'
|
|
3
4
|
import { afterEach, expect, test } from 'vitest'
|
|
5
|
+
import { command } from './tempo.js'
|
|
4
6
|
|
|
5
7
|
const instances: Instance.Instance[] = []
|
|
6
8
|
const slowTestTimeout = 30_000
|
|
@@ -87,3 +89,88 @@ test('behavior: can subscribe to stderr', async () => {
|
|
|
87
89
|
instance_2.on('stderr', (message) => messages.push(message))
|
|
88
90
|
await expect(instance_2.start()).rejects.toThrow('Failed to start')
|
|
89
91
|
})
|
|
92
|
+
|
|
93
|
+
test(
|
|
94
|
+
'behavior: faucet funds address',
|
|
95
|
+
{ timeout: slowTestTimeout },
|
|
96
|
+
async () => {
|
|
97
|
+
const instance = defineInstance()
|
|
98
|
+
await instance.start()
|
|
99
|
+
|
|
100
|
+
const rpc = async (method: string, params: unknown[]) => {
|
|
101
|
+
const response = await fetch(`http://localhost:${port}`, {
|
|
102
|
+
body: JSON.stringify({ id: 0, jsonrpc: '2.0', method, params }),
|
|
103
|
+
headers: { 'Content-Type': 'application/json' },
|
|
104
|
+
method: 'POST',
|
|
105
|
+
})
|
|
106
|
+
return await response.json()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Funding races the first wall-clock block; expiring-nonce validation rejects until one exists.
|
|
110
|
+
let json: { result?: string[] } = {}
|
|
111
|
+
for (let i = 0; i < 50; i++) {
|
|
112
|
+
json = await rpc('tempo_fundAddress', [
|
|
113
|
+
'0x000000000000000000000000000000000000beef',
|
|
114
|
+
])
|
|
115
|
+
if (json.result) break
|
|
116
|
+
await new Promise((resolve) => setTimeout(resolve, 200))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
expect(
|
|
120
|
+
JSON.stringify(json).replaceAll(/0x[0-9a-f]{64}/g, '<hash>'),
|
|
121
|
+
).toMatchInlineSnapshot(
|
|
122
|
+
`"{"jsonrpc":"2.0","id":0,"result":["<hash>","<hash>","<hash>","<hash>"]}"`,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
// balanceOf(0x...beef) on the first faucet token.
|
|
126
|
+
let balance = 0n
|
|
127
|
+
for (let i = 0; i < 50; i++) {
|
|
128
|
+
const { result } = await rpc('eth_call', [
|
|
129
|
+
{
|
|
130
|
+
data: '0x70a08231000000000000000000000000000000000000000000000000000000000000beef',
|
|
131
|
+
to: '0x20c0000000000000000000000000000000000000',
|
|
132
|
+
},
|
|
133
|
+
'latest',
|
|
134
|
+
])
|
|
135
|
+
balance = BigInt(result ?? 0)
|
|
136
|
+
if (balance > 0n) break
|
|
137
|
+
await new Promise((resolve) => setTimeout(resolve, 200))
|
|
138
|
+
}
|
|
139
|
+
expect(balance).toBeGreaterThan(0n)
|
|
140
|
+
},
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
const redact = (args: string[]) =>
|
|
144
|
+
args.join(' ').replaceAll(os.tmpdir(), '<tmpdir>')
|
|
145
|
+
|
|
146
|
+
test('command: default', () => {
|
|
147
|
+
expect(redact(command({ port: 8545 }))).toMatchInlineSnapshot(
|
|
148
|
+
`"node --authrpc.port 8575 --datadir <tmpdir>/.prool/tempo.8545 --dev --dev.block-time 50ms --engine.disable-precompile-cache --engine.legacy-state-root --faucet.address 0x20c0000000000000000000000000000000000000 0x20c0000000000000000000000000000000000001 0x20c0000000000000000000000000000000000002 0x20c0000000000000000000000000000000000003 --faucet.amount 1000000000000 --faucet.enabled --faucet.private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --faucet.node-address http://localhost:8545 --http.addr 0.0.0.0 --http.api all --http.corsdomain * --http.port 8545 --port 8555 --ws.port 8565"`,
|
|
149
|
+
)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
test('command: behavior: faucet node address', () => {
|
|
153
|
+
expect(
|
|
154
|
+
redact(
|
|
155
|
+
command({ faucet: { nodeAddress: 'http://localhost:1337' }, port: 8545 }),
|
|
156
|
+
),
|
|
157
|
+
).toMatchInlineSnapshot(
|
|
158
|
+
`"node --authrpc.port 8575 --datadir <tmpdir>/.prool/tempo.8545 --dev --dev.block-time 50ms --engine.disable-precompile-cache --engine.legacy-state-root --faucet.address 0x20c0000000000000000000000000000000000000 0x20c0000000000000000000000000000000000001 0x20c0000000000000000000000000000000000002 0x20c0000000000000000000000000000000000003 --faucet.amount 1000000000000 --faucet.enabled --faucet.private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --faucet.node-address http://localhost:1337 --http.addr 0.0.0.0 --http.api all --http.corsdomain * --http.port 8545 --port 8555 --ws.port 8565"`,
|
|
159
|
+
)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
test('command: behavior: faucet disabled', () => {
|
|
163
|
+
expect(
|
|
164
|
+
redact(command({ faucet: { enabled: false }, port: 8545 })),
|
|
165
|
+
).toMatchInlineSnapshot(
|
|
166
|
+
`"node --authrpc.port 8575 --datadir <tmpdir>/.prool/tempo.8545 --dev --dev.block-time 50ms --engine.disable-precompile-cache --engine.legacy-state-root --faucet.address 0x20c0000000000000000000000000000000000000 0x20c0000000000000000000000000000000000001 0x20c0000000000000000000000000000000000002 0x20c0000000000000000000000000000000000003 --faucet.amount 1000000000000 --faucet.enabled false --faucet.private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --http.addr 0.0.0.0 --http.api all --http.corsdomain * --http.port 8545 --port 8555 --ws.port 8565"`,
|
|
167
|
+
)
|
|
168
|
+
})
|
|
169
|
+
|
|
170
|
+
test('command: behavior: http port override', () => {
|
|
171
|
+
expect(
|
|
172
|
+
redact(command({ http: { port: 1337 }, port: 8545 })),
|
|
173
|
+
).toMatchInlineSnapshot(
|
|
174
|
+
`"node --authrpc.port 8575 --datadir <tmpdir>/.prool/tempo.8545 --dev --dev.block-time 50ms --engine.disable-precompile-cache --engine.legacy-state-root --faucet.address 0x20c0000000000000000000000000000000000000 0x20c0000000000000000000000000000000000001 0x20c0000000000000000000000000000000000002 0x20c0000000000000000000000000000000000003 --faucet.amount 1000000000000 --faucet.enabled --faucet.private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --faucet.node-address http://localhost:1337 --http.addr 0.0.0.0 --http.api all --http.corsdomain * --http.port 1337 --port 8555 --ws.port 8565"`,
|
|
175
|
+
)
|
|
176
|
+
})
|
package/src/instances/tempo.ts
CHANGED
|
@@ -50,9 +50,17 @@ export function command(parameters: tempo.Parameters): string[] {
|
|
|
50
50
|
},
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
const args = deepAssign(defaultParameters, rest)
|
|
54
|
+
|
|
55
|
+
// Faucet submits funding transactions over RPC; point it at the resolved http port (node default: 8545).
|
|
56
|
+
const faucet = args['faucet'] as tempo.Parameters['faucet']
|
|
57
|
+
const http = args['http'] as { port: number }
|
|
58
|
+
if (faucet?.enabled && !faucet.nodeAddress)
|
|
59
|
+
faucet.nodeAddress = `http://localhost:${http.port}`
|
|
60
|
+
|
|
53
61
|
return [
|
|
54
62
|
'node',
|
|
55
|
-
...toArgs(
|
|
63
|
+
...toArgs(args, {
|
|
56
64
|
arraySeparator: null,
|
|
57
65
|
}),
|
|
58
66
|
]
|
|
@@ -177,6 +185,16 @@ export declare namespace tempo {
|
|
|
177
185
|
* Amount for each faucet funding transaction
|
|
178
186
|
*/
|
|
179
187
|
amount?: bigint | undefined
|
|
188
|
+
/**
|
|
189
|
+
* Whether the faucet is enabled
|
|
190
|
+
* @default true
|
|
191
|
+
*/
|
|
192
|
+
enabled?: boolean | undefined
|
|
193
|
+
/**
|
|
194
|
+
* Node RPC address the faucet submits funding transactions to
|
|
195
|
+
* @default `http://localhost:${port}`
|
|
196
|
+
*/
|
|
197
|
+
nodeAddress?: string | undefined
|
|
180
198
|
/**
|
|
181
199
|
* Faucet funding mnemonic
|
|
182
200
|
*/
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as os from 'node:os'
|
|
2
|
+
import { expect, test } from 'vitest'
|
|
3
|
+
import { command } from './tempoZone.js'
|
|
4
|
+
|
|
5
|
+
const redact = (args: string[]) =>
|
|
6
|
+
args.join(' ').replaceAll(os.tmpdir(), '<tmpdir>')
|
|
7
|
+
|
|
8
|
+
test('command: default', () => {
|
|
9
|
+
expect(redact(command({ port: 9545 }))).toMatchInlineSnapshot(
|
|
10
|
+
`"dev --datadir <tmpdir>/.prool/tempo-zone.9545 --http.addr 0.0.0.0 --http.port 9545 --l1.rpc-url ws://localhost:8546 --private-rpc.port 9548 -- --authrpc.port 9549 --ipcdisable"`,
|
|
11
|
+
)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('command: behavior: l1 options', () => {
|
|
15
|
+
expect(
|
|
16
|
+
redact(
|
|
17
|
+
command({
|
|
18
|
+
l1: {
|
|
19
|
+
factoryAddress: '0x00000000000000000000000000000000000fac70',
|
|
20
|
+
rpcUrl: 'ws://l1:8546',
|
|
21
|
+
},
|
|
22
|
+
port: 9545,
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
).toMatchInlineSnapshot(
|
|
26
|
+
`"dev --datadir <tmpdir>/.prool/tempo-zone.9545 --http.addr 0.0.0.0 --http.port 9545 --l1.rpc-url ws://l1:8546 --l1.factory-address 0x00000000000000000000000000000000000fac70 --private-rpc.port 9548 -- --authrpc.port 9549 --ipcdisable"`,
|
|
27
|
+
)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('command: behavior: dev options', () => {
|
|
31
|
+
expect(
|
|
32
|
+
redact(
|
|
33
|
+
command({
|
|
34
|
+
dev: {
|
|
35
|
+
key: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
36
|
+
token: '0x20c0000000000000000000000000000000000001',
|
|
37
|
+
},
|
|
38
|
+
port: 9545,
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
).toMatchInlineSnapshot(
|
|
42
|
+
`"dev --datadir <tmpdir>/.prool/tempo-zone.9545 --http.addr 0.0.0.0 --http.port 9545 --l1.rpc-url ws://localhost:8546 --private-rpc.port 9548 --dev.key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --dev.token 0x20c0000000000000000000000000000000000001 -- --authrpc.port 9549 --ipcdisable"`,
|
|
43
|
+
)
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
test('command: behavior: node args', () => {
|
|
47
|
+
expect(
|
|
48
|
+
redact(command({ nodeArgs: ['--full'], port: 9545 })),
|
|
49
|
+
).toMatchInlineSnapshot(
|
|
50
|
+
`"dev --datadir <tmpdir>/.prool/tempo-zone.9545 --http.addr 0.0.0.0 --http.port 9545 --l1.rpc-url ws://localhost:8546 --private-rpc.port 9548 -- --authrpc.port 9549 --ipcdisable --full"`,
|
|
51
|
+
)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('command: behavior: private rpc port override', () => {
|
|
55
|
+
expect(
|
|
56
|
+
redact(command({ port: 9545, privateRpc: { port: 1337 } })),
|
|
57
|
+
).toMatchInlineSnapshot(
|
|
58
|
+
`"dev --datadir <tmpdir>/.prool/tempo-zone.9545 --http.addr 0.0.0.0 --http.port 9545 --l1.rpc-url ws://localhost:8546 --private-rpc.port 1337 -- --authrpc.port 9549 --ipcdisable"`,
|
|
59
|
+
)
|
|
60
|
+
})
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import * as os from 'node:os'
|
|
2
|
+
import * as path from 'node:path'
|
|
3
|
+
import * as Instance from '../Instance.js'
|
|
4
|
+
import { deepAssign, toArgs } from '../internal/utils.js'
|
|
5
|
+
import { execa } from '../processes/execa.js'
|
|
6
|
+
|
|
7
|
+
// `tempo-zone dev` derives the WS RPC (port + 1) and P2P (port + 2) ports from
|
|
8
|
+
// `http.port`. Each instance occupies the compact block [port, port + 4].
|
|
9
|
+
export function command(parameters: tempoZone.Parameters): string[] {
|
|
10
|
+
const { nodeArgs, port, ...rest } = parameters
|
|
11
|
+
|
|
12
|
+
const datadir = path.join(os.tmpdir(), '.prool', `tempo-zone.${port}`)
|
|
13
|
+
const defaultParameters = {
|
|
14
|
+
datadir,
|
|
15
|
+
http: {
|
|
16
|
+
addr: '0.0.0.0',
|
|
17
|
+
port: port!,
|
|
18
|
+
},
|
|
19
|
+
l1: {
|
|
20
|
+
rpcUrl: 'ws://localhost:8546',
|
|
21
|
+
},
|
|
22
|
+
privateRpc: {
|
|
23
|
+
port: port! + 3,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const args = deepAssign(defaultParameters, rest)
|
|
28
|
+
|
|
29
|
+
return [
|
|
30
|
+
'dev',
|
|
31
|
+
...toArgs(args, {
|
|
32
|
+
arraySeparator: null,
|
|
33
|
+
}),
|
|
34
|
+
// Forwarded to `tempo-zone node`; keeps concurrent instances from colliding.
|
|
35
|
+
'--',
|
|
36
|
+
'--authrpc.port',
|
|
37
|
+
String(port! + 4),
|
|
38
|
+
'--ipcdisable',
|
|
39
|
+
...((nodeArgs as string[] | undefined) ?? []),
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Defines a Tempo Zone instance.
|
|
45
|
+
*
|
|
46
|
+
* Provisions a fresh zone against a Tempo dev L1 (`tempo-zone dev`) and runs
|
|
47
|
+
* the zone node. Requires a reachable Tempo dev L1 websocket RPC (`l1.rpcUrl`).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const instance = Instance.tempoZone({
|
|
52
|
+
* l1: { rpcUrl: 'ws://localhost:8546' },
|
|
53
|
+
* port: 9545,
|
|
54
|
+
* })
|
|
55
|
+
* await instance.start()
|
|
56
|
+
* // ...
|
|
57
|
+
* await instance.stop()
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export const tempoZone = Instance.define(
|
|
61
|
+
(parameters?: tempoZone.Parameters) => {
|
|
62
|
+
const { binary = 'tempo-zone', log: log_, ...args } = parameters || {}
|
|
63
|
+
|
|
64
|
+
const log = (() => {
|
|
65
|
+
try {
|
|
66
|
+
return JSON.parse(log_ as string)
|
|
67
|
+
} catch {
|
|
68
|
+
return log_
|
|
69
|
+
}
|
|
70
|
+
})()
|
|
71
|
+
const RUST_LOG = log && typeof log !== 'boolean' ? log : ''
|
|
72
|
+
|
|
73
|
+
const name = 'tempo-zone'
|
|
74
|
+
const process = execa({ name })
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
_internal: {
|
|
78
|
+
args,
|
|
79
|
+
get process() {
|
|
80
|
+
return process._internal.process
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
host: args.host ?? 'localhost',
|
|
84
|
+
name,
|
|
85
|
+
port: args.port ?? 9545,
|
|
86
|
+
async start({ port = args.port }, options) {
|
|
87
|
+
return await process.start(
|
|
88
|
+
($) =>
|
|
89
|
+
$({
|
|
90
|
+
env: {
|
|
91
|
+
RUST_LOG,
|
|
92
|
+
},
|
|
93
|
+
})`${[binary, ...command({ ...args, port })]}`,
|
|
94
|
+
{
|
|
95
|
+
...options,
|
|
96
|
+
// Resolve when the zone RPC server is listening (fires after provisioning).
|
|
97
|
+
resolver({ process, reject, resolve }) {
|
|
98
|
+
let stderr = ''
|
|
99
|
+
process.stdout.on('data', (data) => {
|
|
100
|
+
const message = data.toString()
|
|
101
|
+
if (log) console.log(message)
|
|
102
|
+
if (message.includes('RPC HTTP server started')) resolve()
|
|
103
|
+
if (message.includes('shutting down')) reject('shutting down')
|
|
104
|
+
})
|
|
105
|
+
process.stderr.on('data', (data) => {
|
|
106
|
+
const message = data.toString()
|
|
107
|
+
if (log) console.error(message)
|
|
108
|
+
stderr += message
|
|
109
|
+
})
|
|
110
|
+
// Provisioning failures (e.g. unreachable L1) exit non-zero before the RPC starts.
|
|
111
|
+
process.once('exit', (code) => {
|
|
112
|
+
if (code) reject(stderr || `exited with code ${code}`)
|
|
113
|
+
})
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
)
|
|
117
|
+
},
|
|
118
|
+
async stop() {
|
|
119
|
+
await process.stop()
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
export declare namespace tempoZone {
|
|
126
|
+
export type Parameters = {
|
|
127
|
+
/**
|
|
128
|
+
* Path or alias to the Tempo Zone binary.
|
|
129
|
+
*/
|
|
130
|
+
binary?: string | undefined
|
|
131
|
+
/**
|
|
132
|
+
* Directory for genesis.json, zone.json, node data, and logs. Wiped on start.
|
|
133
|
+
*/
|
|
134
|
+
datadir?: string | undefined
|
|
135
|
+
/**
|
|
136
|
+
* Dev provisioning options.
|
|
137
|
+
*/
|
|
138
|
+
dev?:
|
|
139
|
+
| {
|
|
140
|
+
/**
|
|
141
|
+
* Dev private key (hex): L1 fee payer, factory deployer, portal admin,
|
|
142
|
+
* and zone sequencer.
|
|
143
|
+
*/
|
|
144
|
+
key?: string | undefined
|
|
145
|
+
/**
|
|
146
|
+
* Initial TIP-20 token enabled on the portal.
|
|
147
|
+
* @default pathUSD (0x20c0000000000000000000000000000000000000)
|
|
148
|
+
*/
|
|
149
|
+
token?: string | undefined
|
|
150
|
+
}
|
|
151
|
+
| undefined
|
|
152
|
+
/**
|
|
153
|
+
* Host the server will listen on.
|
|
154
|
+
*/
|
|
155
|
+
host?: string | undefined
|
|
156
|
+
/**
|
|
157
|
+
* Tempo L1 options.
|
|
158
|
+
*/
|
|
159
|
+
l1?:
|
|
160
|
+
| {
|
|
161
|
+
/**
|
|
162
|
+
* Existing ZoneFactory address on the L1. Deploys the bundled factory
|
|
163
|
+
* when omitted.
|
|
164
|
+
*/
|
|
165
|
+
factoryAddress?: string | undefined
|
|
166
|
+
/**
|
|
167
|
+
* Tempo L1 WebSocket RPC URL.
|
|
168
|
+
* @default "ws://localhost:8546"
|
|
169
|
+
*/
|
|
170
|
+
rpcUrl?: string | undefined
|
|
171
|
+
}
|
|
172
|
+
| undefined
|
|
173
|
+
/**
|
|
174
|
+
* Rust log level configuration (sets RUST_LOG environment variable).
|
|
175
|
+
* Can be a log level or a custom filter string.
|
|
176
|
+
*/
|
|
177
|
+
log?:
|
|
178
|
+
| 'trace'
|
|
179
|
+
| 'debug'
|
|
180
|
+
| 'info'
|
|
181
|
+
| 'warn'
|
|
182
|
+
| 'error'
|
|
183
|
+
| (string & {})
|
|
184
|
+
| boolean
|
|
185
|
+
| undefined
|
|
186
|
+
/**
|
|
187
|
+
* Extra arguments forwarded to `tempo-zone node`.
|
|
188
|
+
*/
|
|
189
|
+
nodeArgs?: string[] | undefined
|
|
190
|
+
/**
|
|
191
|
+
* Port the server will listen on.
|
|
192
|
+
*/
|
|
193
|
+
port?: number | undefined
|
|
194
|
+
/**
|
|
195
|
+
* Private RPC options.
|
|
196
|
+
*/
|
|
197
|
+
privateRpc?:
|
|
198
|
+
| {
|
|
199
|
+
/**
|
|
200
|
+
* Zone private RPC port.
|
|
201
|
+
* @default `port + 3`
|
|
202
|
+
*/
|
|
203
|
+
port?: number | undefined
|
|
204
|
+
}
|
|
205
|
+
| undefined
|
|
206
|
+
} & Record<string, unknown>
|
|
207
|
+
}
|
package/src/processes/execa.ts
CHANGED
|
@@ -33,9 +33,10 @@ export function execa(parameters: execa.Parameters): execa.ReturnType {
|
|
|
33
33
|
let process: Process_internal
|
|
34
34
|
|
|
35
35
|
async function stop(signal?: keyof SignalConstants | number) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
process.kill(signal)
|
|
37
|
+
// Process may have exited on its own; 'exit' will not re-fire.
|
|
38
|
+
if (process.exitCode !== null || process.signalCode !== null) return
|
|
39
|
+
return new Promise((resolve) => process.once('exit', resolve))
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
return {
|