@@ -110,7 +110,7 @@ def worker_key_funding_amount(
110110 sender_funding_transactions_gas_price : int ,
111111 sender_fund_refund_gas_limit : int ,
112112 seed_account_sweep_amount : int | None ,
113- ) -> int :
113+ ) -> int | None :
114114 """
115115 Calculate the initial balance of each worker key.
116116
@@ -125,7 +125,13 @@ def worker_key_funding_amount(
125125 It's not really possible to calculate the transaction costs of each test
126126 that each worker is going to run, so we can't really calculate the initial
127127 balance of each sender key based on that.
128+
129+ If we are not running tests in parallel, this method is skipped since
130+ all tests will run from the seed account.
128131 """
132+ if worker_count <= 1 :
133+ return None
134+
129135 base_name = "worker_key_funding_amount"
130136 base_file = session_temp_folder / base_name
131137 base_lock_file = session_temp_folder / f"{ base_name } .lock"
@@ -202,7 +208,8 @@ def worker_key_funding_amount(
202208def session_worker_key (
203209 request : pytest .FixtureRequest ,
204210 seed_key : EOA ,
205- worker_key_funding_amount : int ,
211+ worker_count : int ,
212+ worker_key_funding_amount : int | None ,
206213 eoa_iterator : Iterator [EOA ],
207214 eth_rpc : EthRPC ,
208215 session_temp_folder : Path ,
@@ -216,7 +223,29 @@ def session_worker_key(
216223
217224 Each worker will have a different key, but coordination is required
218225 because all worker keys come from the same seed key.
226+
227+ If we are not running tests in parallel, this method simply returns the
228+ seed account directly.
219229 """
230+ if worker_count <= 1 :
231+ logger .info ("Not running tests in parallel, using seed key directly" )
232+ starting_balance = eth_rpc .get_balance (seed_key )
233+ yield seed_key
234+
235+ remaining_balance = eth_rpc .get_balance (seed_key )
236+ used_balance = starting_balance - remaining_balance
237+ logger .info (
238+ f"Seed { seed_key } used balance: { used_balance / 10 ** 18 :.18f} ETH "
239+ f"(remaining: { remaining_balance / 10 ** 18 :.18f} ETH)"
240+ )
241+ request .config .stash [metadata_key ]["Senders" ][str (seed_key )] = (
242+ f"Used balance={ used_balance / 10 ** 18 :.18f} "
243+ )
244+ return None
245+
246+ assert worker_key_funding_amount is not None , (
247+ "`worker_key_funding_amount` is None"
248+ )
220249 # For the seed sender we do need to keep track of the nonce because it is
221250 # shared among different processes, and there might not be a new block
222251 # produced between the transactions.
0 commit comments