@@ -6,43 +6,60 @@ import {
66 Wait ,
77} from 'testcontainers'
88import * as Instance from '../Instance.js'
9+ import { deepAssign , toArgs } from '../internal/utils.js'
910import { execa } from '../processes/execa.js'
1011
1112export function command ( parameters : tempo . Parameters ) : string [ ] {
12- const { faucet, port } = parameters
13- const dataDir = path . join ( os . tmpdir ( ) , '.prool' , `tempo.${ port } ` )
13+ const { blockMaxTransactions, blockTime, mnemonic, port, ...rest } =
14+ parameters
15+
16+ const datadir = path . join ( os . tmpdir ( ) , '.prool' , `tempo.${ port } ` )
17+ const defaultParameters = {
18+ authrpc : {
19+ port : port ! + 30 ,
20+ } ,
21+ datadir,
22+ dev : [
23+ true ,
24+ {
25+ blockTime : blockTime ?? '50ms' ,
26+ ...( blockMaxTransactions ? { blockMaxTransactions } : { } ) ,
27+ ...( mnemonic ? { mnemonic } : { } ) ,
28+ } ,
29+ ] ,
30+ engine : {
31+ disablePrecompileCache : true ,
32+ legacyStateRoot : true ,
33+ } ,
34+ faucet : {
35+ address : [
36+ '0x20c0000000000000000000000000000000000000' ,
37+ '0x20c0000000000000000000000000000000000001' ,
38+ '0x20c0000000000000000000000000000000000002' ,
39+ '0x20c0000000000000000000000000000000000003' ,
40+ ] ,
41+ amount : '1000000000000' ,
42+ enabled : true ,
43+ privateKey :
44+ '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' ,
45+ } ,
46+ http : {
47+ addr : '0.0.0.0' ,
48+ api : 'all' ,
49+ corsdomain : '*' ,
50+ port : port ! ,
51+ } ,
52+ port : port ! + 10 ,
53+ ws : {
54+ port : port ! + 20 ,
55+ } ,
56+ }
57+
1458 return [
1559 'node' ,
16- `--authrpc.port=${ port ! + 30 } ` ,
17- `--datadir=${ dataDir } ` ,
18- '--dev' ,
19- `--dev.block-time=${ parameters ?. blockTime ?? '50ms' } ` ,
20- '--engine.disable-precompile-cache' ,
21- '--engine.legacy-state-root' ,
22- '--faucet.address' ,
23- ...( faucet ?. addresses ?? [
24- '0x20c0000000000000000000000000000000000000' ,
25- '0x20c0000000000000000000000000000000000001' ,
26- '0x20c0000000000000000000000000000000000002' ,
27- '0x20c0000000000000000000000000000000000003' ,
28- ] ) ,
29- `--faucet.amount=${ faucet ?. amount ?? '1000000000000' } ` ,
30- '--faucet.enabled' ,
31- `--faucet.private-key=${ faucet ?. privateKey ?? '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' } ` ,
32- '--http' ,
33- '--http.addr=0.0.0.0' ,
34- '--http.api=all' ,
35- '--http.corsdomain=*' ,
36- `--http.port=${ port ! } ` ,
37- `--port=${ port ! + 10 } ` ,
38- '--txpool.basefee-max-count=10000000000000' ,
39- '--txpool.basefee-max-size=10000' ,
40- '--txpool.max-account-slots=500000' ,
41- '--txpool.pending-max-count=10000000000000' ,
42- '--txpool.pending-max-size=10000' ,
43- '--txpool.queued-max-count=10000000000000' ,
44- '--txpool.queued-max-size=10000' ,
45- `--ws.port=${ port ! + 20 } ` ,
60+ ...toArgs ( deepAssign ( defaultParameters , rest ) , {
61+ arraySeparator : null ,
62+ } ) ,
4663 ]
4764}
4865
@@ -89,7 +106,7 @@ export const tempo = Instance.define((parameters?: tempo.Parameters) => {
89106 env : {
90107 RUST_LOG ,
91108 } ,
92- } ) `${ [ binary , ...command ( { ...parameters , port } ) ] } ` ,
109+ } ) `${ [ binary , ...command ( { ...args , port } ) ] } ` ,
93110 {
94111 ...options ,
95112 // Resolve when the process is listening via "RPC HTTP server started" message.
@@ -124,6 +141,28 @@ export declare namespace tempo {
124141 * Interval between blocks.
125142 */
126143 blockTime ?: string | undefined
144+ /**
145+ * How many transactions to mine per block
146+ */
147+ blockMaxTransactions ?: number | undefined
148+ /**
149+ * Path to a configuration file.
150+ */
151+ config ?: string | undefined
152+ /**
153+ * The chain this node is running.
154+ * Possible values are either a built-in chain or the path to a chain specification file.
155+ *
156+ * Built-in chains:
157+ * - testnet
158+ *
159+ * @default "testnet"
160+ */
161+ chain ?: string | undefined
162+ /**
163+ * The path to the data dir for all reth files and subdirectories.
164+ */
165+ datadir ?: string | undefined
127166 /**
128167 * Faucet options.
129168 */
@@ -160,11 +199,16 @@ export declare namespace tempo {
160199 * Host the server will listen on.
161200 */
162201 host ?: string | undefined
202+ /**
203+ * Derive dev accounts from a fixed mnemonic instead of random ones.
204+ * @default "test test test test test test test test test test test junk"
205+ */
206+ mnemonic ?: string | undefined
163207 /**
164208 * Port the server will listen on.
165209 */
166210 port ?: number | undefined
167- }
211+ } & Record < string , unknown >
168212}
169213
170214/**
@@ -218,7 +262,7 @@ export const tempoDocker = Instance.define(
218262 ] )
219263 . withName ( containerName )
220264 . withEnvironment ( { RUST_LOG } )
221- . withCommand ( command ( { ...parameters , port } ) )
265+ . withCommand ( command ( { ...args , port } ) )
222266 . withWaitStrategy ( Wait . forLogMessage ( / R P C H T T P s e r v e r s t a r t e d / ) )
223267 . withLogConsumer ( ( stream ) => {
224268 stream . on ( 'data' , ( data ) => {
0 commit comments