prool 0.2.5 → 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/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/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/tempoZone.test.ts +60 -0
- package/src/instances/tempoZone.ts +207 -0
- package/src/testcontainers/Instance.test.ts +47 -1
- package/src/testcontainers/Instance.ts +226 -0
package/dist/Instance.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
2
2
|
export { alto } from './instances/alto.js';
|
|
3
3
|
export { anvil } from './instances/anvil.js';
|
|
4
4
|
export { tempo } from './instances/tempo.js';
|
|
5
|
+
export { tempoZone } from './instances/tempoZone.js';
|
|
5
6
|
type EventTypes = {
|
|
6
7
|
exit: [code: number | null, signal: NodeJS.Signals | null];
|
|
7
8
|
listening: [];
|
package/dist/Instance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../src/Instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file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I,CAAC,CAAA;KACpE,CAAA;IAED,KAAY,UAAU,CACpB,SAAS,SAAS,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,EACzD,UAAU,GAAG,SAAS,IACpB,CACF,GAAG,UAAU,EAAE,UAAU,SAAS,SAAS,GACvC,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,GAC3B,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC,KACpD,QAAQ,CAAC,SAAS,CAAC,CAAA;IAExB,KAAY,6BAA6B,GAAG;QAC1C,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;QACjC,WAAW,CAAC,CAAC,QAAQ,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,CAAA;QAC9D,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAC3B,CAAA;IAED,KAAY,4BAA4B,GAAG;QACzC,OAAO,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;QACjC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;KAC3B,CAAA;IAED,KAAY,oBAAoB,GAAG;QACjC;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACF"}
|
package/dist/Instance.js
CHANGED
|
@@ -2,6 +2,7 @@ import { EventEmitter } from 'eventemitter3';
|
|
|
2
2
|
export { alto } from './instances/alto.js';
|
|
3
3
|
export { anvil } from './instances/anvil.js';
|
|
4
4
|
export { tempo } from './instances/tempo.js';
|
|
5
|
+
export { tempoZone } from './instances/tempoZone.js';
|
|
5
6
|
/**
|
|
6
7
|
* Creates an instance definition.
|
|
7
8
|
*
|
package/dist/Instance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.js","sourceRoot":"","sources":["../src/Instance.ts"],"names":[],"mappings":"AAAA,OAAO,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|
+
/**
|
|
4
|
+
* Defines a Tempo Zone instance.
|
|
5
|
+
*
|
|
6
|
+
* Provisions a fresh zone against a Tempo dev L1 (`tempo-zone dev`) and runs
|
|
7
|
+
* the zone node. Requires a reachable Tempo dev L1 websocket RPC (`l1.rpcUrl`).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const instance = Instance.tempoZone({
|
|
12
|
+
* l1: { rpcUrl: 'ws://localhost:8546' },
|
|
13
|
+
* port: 9545,
|
|
14
|
+
* })
|
|
15
|
+
* await instance.start()
|
|
16
|
+
* // ...
|
|
17
|
+
* await instance.stop()
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const tempoZone: Instance.define.ReturnType<{
|
|
21
|
+
args: {
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Directory for genesis.json, zone.json, node data, and logs. Wiped on start.
|
|
25
|
+
*/
|
|
26
|
+
datadir?: string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Dev provisioning options.
|
|
29
|
+
*/
|
|
30
|
+
dev?: {
|
|
31
|
+
/**
|
|
32
|
+
* Dev private key (hex): L1 fee payer, factory deployer, portal admin,
|
|
33
|
+
* and zone sequencer.
|
|
34
|
+
*/
|
|
35
|
+
key?: string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Initial TIP-20 token enabled on the portal.
|
|
38
|
+
* @default pathUSD (0x20c0000000000000000000000000000000000000)
|
|
39
|
+
*/
|
|
40
|
+
token?: string | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Host the server will listen on.
|
|
44
|
+
*/
|
|
45
|
+
host?: string | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Tempo L1 options.
|
|
48
|
+
*/
|
|
49
|
+
l1?: {
|
|
50
|
+
/**
|
|
51
|
+
* Existing ZoneFactory address on the L1. Deploys the bundled factory
|
|
52
|
+
* when omitted.
|
|
53
|
+
*/
|
|
54
|
+
factoryAddress?: string | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Tempo L1 WebSocket RPC URL.
|
|
57
|
+
* @default "ws://localhost:8546"
|
|
58
|
+
*/
|
|
59
|
+
rpcUrl?: string | undefined;
|
|
60
|
+
} | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Extra arguments forwarded to `tempo-zone node`.
|
|
63
|
+
*/
|
|
64
|
+
nodeArgs?: string[] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Port the server will listen on.
|
|
67
|
+
*/
|
|
68
|
+
port?: number | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Private RPC options.
|
|
71
|
+
*/
|
|
72
|
+
privateRpc?: {
|
|
73
|
+
/**
|
|
74
|
+
* Zone private RPC port.
|
|
75
|
+
* @default `port + 3`
|
|
76
|
+
*/
|
|
77
|
+
port?: number | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
};
|
|
80
|
+
readonly process: import("../processes/execa.js").Process_internal;
|
|
81
|
+
}, Instance.tempoZone.Parameters | undefined>;
|
|
82
|
+
export declare namespace tempoZone {
|
|
83
|
+
type Parameters = {
|
|
84
|
+
/**
|
|
85
|
+
* Path or alias to the Tempo Zone binary.
|
|
86
|
+
*/
|
|
87
|
+
binary?: string | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Directory for genesis.json, zone.json, node data, and logs. Wiped on start.
|
|
90
|
+
*/
|
|
91
|
+
datadir?: string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Dev provisioning options.
|
|
94
|
+
*/
|
|
95
|
+
dev?: {
|
|
96
|
+
/**
|
|
97
|
+
* Dev private key (hex): L1 fee payer, factory deployer, portal admin,
|
|
98
|
+
* and zone sequencer.
|
|
99
|
+
*/
|
|
100
|
+
key?: string | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Initial TIP-20 token enabled on the portal.
|
|
103
|
+
* @default pathUSD (0x20c0000000000000000000000000000000000000)
|
|
104
|
+
*/
|
|
105
|
+
token?: string | undefined;
|
|
106
|
+
} | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* Host the server will listen on.
|
|
109
|
+
*/
|
|
110
|
+
host?: string | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Tempo L1 options.
|
|
113
|
+
*/
|
|
114
|
+
l1?: {
|
|
115
|
+
/**
|
|
116
|
+
* Existing ZoneFactory address on the L1. Deploys the bundled factory
|
|
117
|
+
* when omitted.
|
|
118
|
+
*/
|
|
119
|
+
factoryAddress?: string | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Tempo L1 WebSocket RPC URL.
|
|
122
|
+
* @default "ws://localhost:8546"
|
|
123
|
+
*/
|
|
124
|
+
rpcUrl?: string | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
/**
|
|
127
|
+
* Rust log level configuration (sets RUST_LOG environment variable).
|
|
128
|
+
* Can be a log level or a custom filter string.
|
|
129
|
+
*/
|
|
130
|
+
log?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | (string & {}) | boolean | undefined;
|
|
131
|
+
/**
|
|
132
|
+
* Extra arguments forwarded to `tempo-zone node`.
|
|
133
|
+
*/
|
|
134
|
+
nodeArgs?: string[] | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Port the server will listen on.
|
|
137
|
+
*/
|
|
138
|
+
port?: number | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* Private RPC options.
|
|
141
|
+
*/
|
|
142
|
+
privateRpc?: {
|
|
143
|
+
/**
|
|
144
|
+
* Zone private RPC port.
|
|
145
|
+
* @default `port + 3`
|
|
146
|
+
*/
|
|
147
|
+
port?: number | undefined;
|
|
148
|
+
} | undefined;
|
|
149
|
+
} & Record<string, unknown>;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=tempoZone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempoZone.d.ts","sourceRoot":"","sources":["../../src/instances/tempoZone.ts"],"names":[],"mappings":"AAEA,O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E;;;eAGG;YACH,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;YACnC;;;eAGG;YACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SAC5B,GACD,SAAS,CAAA;QACb;;;WAGG;QACH,GAAG,CAAC,EACA,OAAO,GACP,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,CAAC,MAAM,GAAG,EAAE,CAAC,GACb,OAAO,GACP,SAAS,CAAA;QACb;;WAEG;QACH,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;QAC/B;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACzB;;WAEG;QACH,UAAU,CAAC,EACP;YACE;;;eAGG;YACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SAC1B,GACD,SAAS,CAAA;KACd,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC5B"}
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
// `tempo-zone dev` derives the WS RPC (port + 1) and P2P (port + 2) ports from
|
|
7
|
+
// `http.port`. Each instance occupies the compact block [port, port + 4].
|
|
8
|
+
export function command(parameters) {
|
|
9
|
+
const { nodeArgs, port, ...rest } = parameters;
|
|
10
|
+
const datadir = path.join(os.tmpdir(), '.prool', `tempo-zone.${port}`);
|
|
11
|
+
const defaultParameters = {
|
|
12
|
+
datadir,
|
|
13
|
+
http: {
|
|
14
|
+
addr: '0.0.0.0',
|
|
15
|
+
port: port,
|
|
16
|
+
},
|
|
17
|
+
l1: {
|
|
18
|
+
rpcUrl: 'ws://localhost:8546',
|
|
19
|
+
},
|
|
20
|
+
privateRpc: {
|
|
21
|
+
port: port + 3,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const args = deepAssign(defaultParameters, rest);
|
|
25
|
+
return [
|
|
26
|
+
'dev',
|
|
27
|
+
...toArgs(args, {
|
|
28
|
+
arraySeparator: null,
|
|
29
|
+
}),
|
|
30
|
+
// Forwarded to `tempo-zone node`; keeps concurrent instances from colliding.
|
|
31
|
+
'--',
|
|
32
|
+
'--authrpc.port',
|
|
33
|
+
String(port + 4),
|
|
34
|
+
'--ipcdisable',
|
|
35
|
+
...(nodeArgs ?? []),
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Defines a Tempo Zone instance.
|
|
40
|
+
*
|
|
41
|
+
* Provisions a fresh zone against a Tempo dev L1 (`tempo-zone dev`) and runs
|
|
42
|
+
* the zone node. Requires a reachable Tempo dev L1 websocket RPC (`l1.rpcUrl`).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const instance = Instance.tempoZone({
|
|
47
|
+
* l1: { rpcUrl: 'ws://localhost:8546' },
|
|
48
|
+
* port: 9545,
|
|
49
|
+
* })
|
|
50
|
+
* await instance.start()
|
|
51
|
+
* // ...
|
|
52
|
+
* await instance.stop()
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export const tempoZone = Instance.define((parameters) => {
|
|
56
|
+
const { binary = 'tempo-zone', log: log_, ...args } = parameters || {};
|
|
57
|
+
const log = (() => {
|
|
58
|
+
try {
|
|
59
|
+
return JSON.parse(log_);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return log_;
|
|
63
|
+
}
|
|
64
|
+
})();
|
|
65
|
+
const RUST_LOG = log && typeof log !== 'boolean' ? log : '';
|
|
66
|
+
const name = 'tempo-zone';
|
|
67
|
+
const process = execa({ name });
|
|
68
|
+
return {
|
|
69
|
+
_internal: {
|
|
70
|
+
args,
|
|
71
|
+
get process() {
|
|
72
|
+
return process._internal.process;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
host: args.host ?? 'localhost',
|
|
76
|
+
name,
|
|
77
|
+
port: args.port ?? 9545,
|
|
78
|
+
async start({ port = args.port }, options) {
|
|
79
|
+
return await process.start(($) => $({
|
|
80
|
+
env: {
|
|
81
|
+
RUST_LOG,
|
|
82
|
+
},
|
|
83
|
+
}) `${[binary, ...command({ ...args, port })]}`, {
|
|
84
|
+
...options,
|
|
85
|
+
// Resolve when the zone RPC server is listening (fires after provisioning).
|
|
86
|
+
resolver({ process, reject, resolve }) {
|
|
87
|
+
let stderr = '';
|
|
88
|
+
process.stdout.on('data', (data) => {
|
|
89
|
+
const message = data.toString();
|
|
90
|
+
if (log)
|
|
91
|
+
console.log(message);
|
|
92
|
+
if (message.includes('RPC HTTP server started'))
|
|
93
|
+
resolve();
|
|
94
|
+
if (message.includes('shutting down'))
|
|
95
|
+
reject('shutting down');
|
|
96
|
+
});
|
|
97
|
+
process.stderr.on('data', (data) => {
|
|
98
|
+
const message = data.toString();
|
|
99
|
+
if (log)
|
|
100
|
+
console.error(message);
|
|
101
|
+
stderr += message;
|
|
102
|
+
});
|
|
103
|
+
// Provisioning failures (e.g. unreachable L1) exit non-zero before the RPC starts.
|
|
104
|
+
process.once('exit', (code) => {
|
|
105
|
+
if (code)
|
|
106
|
+
reject(stderr || `exited with code ${code}`);
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
async stop() {
|
|
112
|
+
await process.stop();
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=tempoZone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempoZone.js","sourceRoot":"","sources":["../../src/instances/tempoZone.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,QAAQ,M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AAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;wBAC7B,IAAI,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC;4BAAE,OAAO,EAAE,CAAA;wBAC1D,IAAI,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;4BAAE,MAAM,CAAC,eAAe,CAAC,CAAA;oBAChE,CAAC,CAAC,CAAA;oBACF,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;wBACjC,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAA;wBAC/B,IAAI,GAAG;4BAAE,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;wBAC/B,MAAM,IAAI,OAAO,CAAA;oBACnB,CAAC,CAAC,CAAA;oBACF,mFAAmF;oBACnF,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;wBAC5B,IAAI,IAAI;4BAAE,MAAM,CAAC,MAAM,IAAI,oBAAoB,IAAI,EAAE,CAAC,CAAA;oBACxD,CAAC,CAAC,CAAA;gBACJ,CAAC;aACF,CACF,CAAA;QACH,CAAC;QACD,KAAK,CAAC,IAAI;YACR,MAAM,OAAO,CAAC,IAAI,EAAE,CAAA;QACtB,CAAC;KACF,CAAA;AACH,CAAC,CACF,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Instance from '../Instance.js';
|
|
2
2
|
import { type tempo as core_tempo } from '../instances/tempo.js';
|
|
3
|
+
import { type tempoZone as core_tempoZone } from '../instances/tempoZone.js';
|
|
3
4
|
import * as ContainerOptions from './containerOptions.js';
|
|
4
5
|
export type { Instance, InstanceOptions } from '../Instance.js';
|
|
5
6
|
/**
|
|
@@ -46,4 +47,73 @@ export declare namespace tempo {
|
|
|
46
47
|
port?: number | undefined;
|
|
47
48
|
};
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Defines a Tempo Zone instance.
|
|
52
|
+
*
|
|
53
|
+
* Starts a Tempo dev L1 container and a zone container (`tempo-zone dev`) on a
|
|
54
|
+
* shared network, provisioning a fresh zone against the L1. Pass `l1.rpcUrl`
|
|
55
|
+
* to attach to an existing L1 instead (the URL must be reachable from inside
|
|
56
|
+
* the container, e.g. `ws://host.docker.internal:8546`).
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const instance = Instance.tempoZone({ port: 9545 })
|
|
61
|
+
* await instance.start()
|
|
62
|
+
* // ...
|
|
63
|
+
* await instance.stop()
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare const tempoZone: Instance.define.ReturnType<{
|
|
67
|
+
args: {
|
|
68
|
+
[x: string]: unknown;
|
|
69
|
+
/**
|
|
70
|
+
* Host the server will listen on.
|
|
71
|
+
*/
|
|
72
|
+
host?: string | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* Port the server will listen on.
|
|
75
|
+
*/
|
|
76
|
+
port?: number | undefined;
|
|
77
|
+
};
|
|
78
|
+
readonly l1: {
|
|
79
|
+
host: string;
|
|
80
|
+
port: number;
|
|
81
|
+
wsPort: number;
|
|
82
|
+
} | undefined;
|
|
83
|
+
}, tempoZone.Parameters | undefined>;
|
|
84
|
+
export declare namespace tempoZone {
|
|
85
|
+
type Parameters = Omit<core_tempoZone.Parameters, 'binary' | 'l1'> & ContainerOptions.Parameters & {
|
|
86
|
+
/**
|
|
87
|
+
* Name of the container.
|
|
88
|
+
*/
|
|
89
|
+
containerName?: string | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Docker image to use for the zone node.
|
|
92
|
+
*/
|
|
93
|
+
image?: string | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Host the server will listen on.
|
|
96
|
+
*/
|
|
97
|
+
host?: string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Tempo L1 options.
|
|
100
|
+
*/
|
|
101
|
+
l1?: (NonNullable<core_tempoZone.Parameters['l1']> & {
|
|
102
|
+
/**
|
|
103
|
+
* Docker image to use for the L1 node (when no `rpcUrl` is provided).
|
|
104
|
+
*/
|
|
105
|
+
image?: string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Existing Tempo L1 WebSocket RPC URL, reachable from inside the
|
|
108
|
+
* container (e.g. `ws://host.docker.internal:8546`). Starts a
|
|
109
|
+
* dev L1 container when omitted.
|
|
110
|
+
*/
|
|
111
|
+
rpcUrl?: string | undefined;
|
|
112
|
+
}) | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* Port the server will listen on.
|
|
115
|
+
*/
|
|
116
|
+
port?: number | undefined;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
49
119
|
//# sourceMappingURL=Instance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/testcontainers/Instance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Instance.d.ts","sourceRoot":"","sources":["../../src/testcontainers/Instance.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAW,KAAK,KAAK,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACzE,OAAO,EACL,KAAK,SAAS,IAAI,cAAc,EAEjC,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAA;AAEzD,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAE/D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK;;;QAoGZ;;WAEG;eACI,MAAM,GAAG,SAAS;QACzB;;WAEG;eACI,MAAM,GAAG,SAAS;;gCApB7B,CAAA;AAEF,MAAM,CAAC,OAAO,WAAW,KAAK,CAAC;IAC7B,KAAY,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,GAC5D,gBAAgB,CAAC,UAAU,GAAG;QAC5B;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAClC;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACzB;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACJ;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,SAAS;;;QAgLhB;;WAEG;eACI,MAAM,GAAG,SAAS;QAkBzB;;WAEG;eACI,MAAM,GAAG,SAAS;;;;;;;oCArC9B,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,SAAS,CAAC;IACjC,KAAY,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC,GACvE,gBAAgB,CAAC,UAAU,GAAG;QAC5B;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAClC;;WAEG;QACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QAC1B;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;QACzB;;WAEG;QACH,EAAE,CAAC,EACC,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG;YAC9C;;eAEG;YACH,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;YAC1B;;;;eAIG;YACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;SAC5B,CAAC,GACF,SAAS,CAAA;QACb;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC1B,CAAA;CACJ"}
|
|
@@ -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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M,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]
|
|
@@ -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
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import getPort from 'get-port'
|
|
2
2
|
import { Instance } from 'prool/testcontainers'
|
|
3
|
-
import { afterEach, expect, test } from 'vitest'
|
|
3
|
+
import { afterEach, describe, expect, test } from 'vitest'
|
|
4
4
|
|
|
5
5
|
const instances: Instance.Instance[] = []
|
|
6
6
|
const slowTestTimeout = 30_000
|
|
@@ -125,3 +125,49 @@ test('behavior: faucet funds address', { timeout: 120_000 }, async () => {
|
|
|
125
125
|
}
|
|
126
126
|
expect(balance).toBeGreaterThan(0n)
|
|
127
127
|
})
|
|
128
|
+
|
|
129
|
+
// Requires a `tempo-zone` image with the `dev` command and GHCR access
|
|
130
|
+
// (the package is private), e.g. `VITE_TEMPO_ZONE_IMAGE=ghcr.io/tempoxyz/tempo-zone:latest`.
|
|
131
|
+
const tempoZoneImage = process.env['VITE_TEMPO_ZONE_IMAGE']
|
|
132
|
+
const zonePort = await getPort()
|
|
133
|
+
|
|
134
|
+
describe.runIf(tempoZoneImage)('tempoZone', () => {
|
|
135
|
+
const defineZoneInstance = (
|
|
136
|
+
parameters: Instance.tempoZone.Parameters = {},
|
|
137
|
+
) => {
|
|
138
|
+
const instance = Instance.tempoZone({
|
|
139
|
+
image: tempoZoneImage,
|
|
140
|
+
port: zonePort,
|
|
141
|
+
startupTimeout: 120_000,
|
|
142
|
+
...parameters,
|
|
143
|
+
})
|
|
144
|
+
instances.push(instance)
|
|
145
|
+
return instance
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
test('default', { timeout: 300_000 }, async () => {
|
|
149
|
+
const instance = defineZoneInstance()
|
|
150
|
+
|
|
151
|
+
await instance.start()
|
|
152
|
+
expect(instance.status).toEqual('started')
|
|
153
|
+
|
|
154
|
+
const rpc = async (method: string, params: unknown[]) => {
|
|
155
|
+
const response = await fetch(`http://${instance.host}:${instance.port}`, {
|
|
156
|
+
body: JSON.stringify({ id: 0, jsonrpc: '2.0', method, params }),
|
|
157
|
+
headers: { 'Content-Type': 'application/json' },
|
|
158
|
+
method: 'POST',
|
|
159
|
+
})
|
|
160
|
+
return await response.json()
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Zone chain IDs are derived: ZONE_CHAIN_ID_BASE + (zone_id % range).
|
|
164
|
+
const { result: chainId } = await rpc('eth_chainId', [])
|
|
165
|
+
expect(BigInt(chainId)).toBeGreaterThanOrEqual(421_700_000n)
|
|
166
|
+
|
|
167
|
+
const { result: blockNumber } = await rpc('eth_blockNumber', [])
|
|
168
|
+
expect(blockNumber).toBeDefined()
|
|
169
|
+
|
|
170
|
+
await instance.stop()
|
|
171
|
+
expect(instance.status).toEqual('stopped')
|
|
172
|
+
})
|
|
173
|
+
})
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GenericContainer,
|
|
3
|
+
Network,
|
|
3
4
|
PullPolicy,
|
|
5
|
+
type StartedNetwork,
|
|
4
6
|
type StartedTestContainer,
|
|
5
7
|
Wait,
|
|
6
8
|
} from 'testcontainers'
|
|
7
9
|
import * as Instance from '../Instance.js'
|
|
8
10
|
import { command, type tempo as core_tempo } from '../instances/tempo.js'
|
|
11
|
+
import {
|
|
12
|
+
type tempoZone as core_tempoZone,
|
|
13
|
+
command as zoneCommand,
|
|
14
|
+
} from '../instances/tempoZone.js'
|
|
9
15
|
import * as ContainerOptions from './containerOptions.js'
|
|
10
16
|
|
|
11
17
|
export type { Instance, InstanceOptions } from '../Instance.js'
|
|
@@ -131,3 +137,223 @@ export declare namespace tempo {
|
|
|
131
137
|
port?: number | undefined
|
|
132
138
|
}
|
|
133
139
|
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Defines a Tempo Zone instance.
|
|
143
|
+
*
|
|
144
|
+
* Starts a Tempo dev L1 container and a zone container (`tempo-zone dev`) on a
|
|
145
|
+
* shared network, provisioning a fresh zone against the L1. Pass `l1.rpcUrl`
|
|
146
|
+
* to attach to an existing L1 instead (the URL must be reachable from inside
|
|
147
|
+
* the container, e.g. `ws://host.docker.internal:8546`).
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* const instance = Instance.tempoZone({ port: 9545 })
|
|
152
|
+
* await instance.start()
|
|
153
|
+
* // ...
|
|
154
|
+
* await instance.stop()
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
export const tempoZone = Instance.define(
|
|
158
|
+
(parameters?: tempoZone.Parameters) => {
|
|
159
|
+
const {
|
|
160
|
+
containerName = `tempo-zone.${crypto.randomUUID()}`,
|
|
161
|
+
image = 'ghcr.io/tempoxyz/tempo-zone:latest',
|
|
162
|
+
l1: l1Parameters,
|
|
163
|
+
log: log_,
|
|
164
|
+
startupTimeout,
|
|
165
|
+
...args
|
|
166
|
+
} = parameters || {}
|
|
167
|
+
|
|
168
|
+
const log = (() => {
|
|
169
|
+
try {
|
|
170
|
+
return JSON.parse(log_ as string)
|
|
171
|
+
} catch {
|
|
172
|
+
return log_
|
|
173
|
+
}
|
|
174
|
+
})()
|
|
175
|
+
const RUST_LOG = log && typeof log !== 'boolean' ? log : ''
|
|
176
|
+
|
|
177
|
+
// L1 ports inside the container (only reachable over the shared network).
|
|
178
|
+
const l1HttpPort = 8545
|
|
179
|
+
const l1WsPort = 8546
|
|
180
|
+
|
|
181
|
+
const name = 'tempo-zone'
|
|
182
|
+
let container: StartedTestContainer | undefined
|
|
183
|
+
let l1Container: StartedTestContainer | undefined
|
|
184
|
+
let network: StartedNetwork | undefined
|
|
185
|
+
|
|
186
|
+
async function teardown() {
|
|
187
|
+
if (container) await container.stop().catch(() => {})
|
|
188
|
+
if (l1Container) await l1Container.stop().catch(() => {})
|
|
189
|
+
if (network) await network.stop().catch(() => {})
|
|
190
|
+
container = undefined
|
|
191
|
+
l1Container = undefined
|
|
192
|
+
network = undefined
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
_internal: {
|
|
197
|
+
args,
|
|
198
|
+
get l1() {
|
|
199
|
+
if (!l1Container) return undefined
|
|
200
|
+
return {
|
|
201
|
+
host: l1Container.getHost(),
|
|
202
|
+
port: l1Container.getMappedPort(l1HttpPort),
|
|
203
|
+
wsPort: l1Container.getMappedPort(l1WsPort),
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
host: args.host ?? 'localhost',
|
|
208
|
+
name,
|
|
209
|
+
port: args.port ?? 9545,
|
|
210
|
+
async start({ port = args.port }, { emitter, setEndpoint }) {
|
|
211
|
+
const containerPort = port ?? 9545
|
|
212
|
+
const timeout = ContainerOptions.resolveStartupTimeout(startupTimeout)
|
|
213
|
+
|
|
214
|
+
const logConsumer =
|
|
215
|
+
(reject: (error: Error) => void) =>
|
|
216
|
+
(stream: NodeJS.ReadableStream) => {
|
|
217
|
+
stream.on('data', (data) => {
|
|
218
|
+
const message = data.toString()
|
|
219
|
+
emitter.emit('message', message)
|
|
220
|
+
emitter.emit('stdout', message)
|
|
221
|
+
if (log) console.log(message)
|
|
222
|
+
if (message.includes('shutting down'))
|
|
223
|
+
reject(new Error(`Failed to start: ${message}`))
|
|
224
|
+
})
|
|
225
|
+
stream.on('error', (error) => {
|
|
226
|
+
if (log) console.error(error.message)
|
|
227
|
+
emitter.emit('message', error.message)
|
|
228
|
+
emitter.emit('stderr', error.message)
|
|
229
|
+
reject(new Error(`Failed to start: ${error.message}`))
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
// Start a dev L1 on a shared network unless attaching to an existing one.
|
|
235
|
+
let l1RpcUrl = l1Parameters?.rpcUrl
|
|
236
|
+
if (!l1RpcUrl) {
|
|
237
|
+
network = await new Network().start()
|
|
238
|
+
l1Container = await new GenericContainer(
|
|
239
|
+
l1Parameters?.image ?? 'ghcr.io/tempoxyz/tempo:latest',
|
|
240
|
+
)
|
|
241
|
+
.withPullPolicy(PullPolicy.alwaysPull())
|
|
242
|
+
.withPlatform('linux/x86_64')
|
|
243
|
+
.withNetwork(network)
|
|
244
|
+
.withNetworkAliases('l1')
|
|
245
|
+
.withExposedPorts(l1HttpPort, l1WsPort)
|
|
246
|
+
.withName(`${containerName}.l1`)
|
|
247
|
+
.withEnvironment({ RUST_LOG })
|
|
248
|
+
.withCommand(
|
|
249
|
+
command({
|
|
250
|
+
port: l1HttpPort,
|
|
251
|
+
// The zone anchors to the L1 over WebSocket.
|
|
252
|
+
ws: [true, { addr: '0.0.0.0', api: 'all', port: l1WsPort }],
|
|
253
|
+
}),
|
|
254
|
+
)
|
|
255
|
+
.withWaitStrategy(
|
|
256
|
+
Wait.forLogMessage(
|
|
257
|
+
/Received (block|new payload) from consensus engine/,
|
|
258
|
+
),
|
|
259
|
+
)
|
|
260
|
+
.withLogConsumer(
|
|
261
|
+
logConsumer(() => {
|
|
262
|
+
// L1 shutdown surfaces via the zone container failing to start.
|
|
263
|
+
}),
|
|
264
|
+
)
|
|
265
|
+
.withStartupTimeout(timeout)
|
|
266
|
+
.start()
|
|
267
|
+
l1RpcUrl = `ws://l1:${l1WsPort}`
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const promise = Promise.withResolvers<void>()
|
|
271
|
+
|
|
272
|
+
let c = new GenericContainer(image)
|
|
273
|
+
.withPullPolicy(PullPolicy.alwaysPull())
|
|
274
|
+
.withPlatform('linux/x86_64')
|
|
275
|
+
.withExposedPorts(containerPort)
|
|
276
|
+
.withExtraHosts([
|
|
277
|
+
{ host: 'host.docker.internal', ipAddress: 'host-gateway' },
|
|
278
|
+
])
|
|
279
|
+
.withName(containerName)
|
|
280
|
+
.withEnvironment({ RUST_LOG })
|
|
281
|
+
.withCommand(
|
|
282
|
+
zoneCommand({
|
|
283
|
+
...args,
|
|
284
|
+
l1: {
|
|
285
|
+
...(l1Parameters?.factoryAddress
|
|
286
|
+
? { factoryAddress: l1Parameters.factoryAddress }
|
|
287
|
+
: {}),
|
|
288
|
+
rpcUrl: l1RpcUrl,
|
|
289
|
+
},
|
|
290
|
+
port: containerPort,
|
|
291
|
+
}),
|
|
292
|
+
)
|
|
293
|
+
.withWaitStrategy(Wait.forLogMessage('RPC HTTP server started'))
|
|
294
|
+
.withLogConsumer(logConsumer(promise.reject))
|
|
295
|
+
.withStartupTimeout(timeout)
|
|
296
|
+
if (network) c = c.withNetwork(network)
|
|
297
|
+
|
|
298
|
+
c.start()
|
|
299
|
+
.then((started) => {
|
|
300
|
+
container = started
|
|
301
|
+
setEndpoint?.({
|
|
302
|
+
host: started.getHost(),
|
|
303
|
+
port: started.getMappedPort(containerPort),
|
|
304
|
+
})
|
|
305
|
+
promise.resolve()
|
|
306
|
+
})
|
|
307
|
+
.catch(promise.reject)
|
|
308
|
+
|
|
309
|
+
await promise.promise
|
|
310
|
+
} catch (error) {
|
|
311
|
+
await teardown()
|
|
312
|
+
throw error
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
async stop() {
|
|
316
|
+
await teardown()
|
|
317
|
+
},
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
)
|
|
321
|
+
|
|
322
|
+
export declare namespace tempoZone {
|
|
323
|
+
export type Parameters = Omit<core_tempoZone.Parameters, 'binary' | 'l1'> &
|
|
324
|
+
ContainerOptions.Parameters & {
|
|
325
|
+
/**
|
|
326
|
+
* Name of the container.
|
|
327
|
+
*/
|
|
328
|
+
containerName?: string | undefined
|
|
329
|
+
/**
|
|
330
|
+
* Docker image to use for the zone node.
|
|
331
|
+
*/
|
|
332
|
+
image?: string | undefined
|
|
333
|
+
/**
|
|
334
|
+
* Host the server will listen on.
|
|
335
|
+
*/
|
|
336
|
+
host?: string | undefined
|
|
337
|
+
/**
|
|
338
|
+
* Tempo L1 options.
|
|
339
|
+
*/
|
|
340
|
+
l1?:
|
|
341
|
+
| (NonNullable<core_tempoZone.Parameters['l1']> & {
|
|
342
|
+
/**
|
|
343
|
+
* Docker image to use for the L1 node (when no `rpcUrl` is provided).
|
|
344
|
+
*/
|
|
345
|
+
image?: string | undefined
|
|
346
|
+
/**
|
|
347
|
+
* Existing Tempo L1 WebSocket RPC URL, reachable from inside the
|
|
348
|
+
* container (e.g. `ws://host.docker.internal:8546`). Starts a
|
|
349
|
+
* dev L1 container when omitted.
|
|
350
|
+
*/
|
|
351
|
+
rpcUrl?: string | undefined
|
|
352
|
+
})
|
|
353
|
+
| undefined
|
|
354
|
+
/**
|
|
355
|
+
* Port the server will listen on.
|
|
356
|
+
*/
|
|
357
|
+
port?: number | undefined
|
|
358
|
+
}
|
|
359
|
+
}
|