4848 Wei ,
4949)
5050
51- KEYFILE_PW = ' web3py-test'
51+ KEYFILE_PW = " web3py-test"
5252
5353parser = argparse .ArgumentParser ()
5454parser .add_argument (
55- "--num-calls" , type = int , default = 10 , help = "The number of RPC calls to make" ,
55+ "--num-calls" ,
56+ type = int ,
57+ default = 10 ,
58+ help = "The number of RPC calls to make" ,
5659)
5760
5861# TODO - layers to test:
@@ -65,7 +68,7 @@ def build_web3_http(endpoint_uri: str) -> Web3:
6568 wait_for_http (endpoint_uri )
6669 _w3 = Web3 (
6770 HTTPProvider (endpoint_uri ),
68- middlewares = [gas_price_strategy_middleware , buffered_gas_estimate_middleware ]
71+ middlewares = [gas_price_strategy_middleware , buffered_gas_estimate_middleware ],
6972 )
7073 return _w3
7174
@@ -74,7 +77,10 @@ async def build_async_w3_http(endpoint_uri: str) -> Web3:
7477 await wait_for_aiohttp (endpoint_uri )
7578 _w3 = Web3 (
7679 AsyncHTTPProvider (endpoint_uri ), # type: ignore
77- middlewares = [async_gas_price_strategy_middleware , async_buffered_gas_estimate_middleware ],
80+ middlewares = [
81+ async_gas_price_strategy_middleware ,
82+ async_buffered_gas_estimate_middleware ,
83+ ],
7884 modules = {"eth" : AsyncEth },
7985 )
8086 return _w3
@@ -121,7 +127,9 @@ def main(logger: logging.Logger, num_calls: int) -> None:
121127 for process in built_fixture :
122128 w3_http = build_web3_http (fixture .endpoint_uri )
123129 loop = asyncio .get_event_loop ()
124- async_w3_http = loop .run_until_complete (build_async_w3_http (fixture .endpoint_uri ))
130+ async_w3_http = loop .run_until_complete (
131+ build_async_w3_http (fixture .endpoint_uri )
132+ )
125133 # TODO: swap out w3_http for the async_w3_http once GethPersonal module is async
126134 async_unlocked_acct = loop .run_until_complete (
127135 async_unlocked_account (w3_http , async_w3_http .eth )
@@ -137,16 +145,20 @@ def main(logger: logging.Logger, num_calls: int) -> None:
137145 {
138146 "name" : "eth_sendTransaction" ,
139147 "params" : {},
140- "exec" : lambda : w3_http .eth .send_transaction ({
141- 'to' : '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' ,
142- 'from' : unlocked_account (w3_http ),
143- 'value' : Wei (12345 ),
144- }),
145- "async_exec" : lambda : async_w3_http .eth .send_transaction ({
146- 'to' : '0xd3CdA913deB6f67967B99D67aCDFa1712C293601' ,
147- 'from' : async_unlocked_acct ,
148- 'value' : Wei (12345 )
149- }),
148+ "exec" : lambda : w3_http .eth .send_transaction (
149+ {
150+ "to" : "0xd3CdA913deB6f67967B99D67aCDFa1712C293601" ,
151+ "from" : unlocked_account (w3_http ),
152+ "value" : Wei (12345 ),
153+ }
154+ ),
155+ "async_exec" : lambda : async_w3_http .eth .send_transaction (
156+ {
157+ "to" : "0xd3CdA913deB6f67967B99D67aCDFa1712C293601" ,
158+ "from" : async_unlocked_acct ,
159+ "value" : Wei (12345 ),
160+ }
161+ ),
150162 },
151163 {
152164 "name" : "eth_blockNumber" ,
@@ -165,7 +177,10 @@ def main(logger: logging.Logger, num_calls: int) -> None:
165177 def benchmark (method : Dict [str , Any ]) -> None :
166178 outcomes : Dict [str , Union [str , float ]] = defaultdict (lambda : "N/A" )
167179 outcomes ["name" ] = method ["name" ]
168- outcomes ["HTTPProvider" ] = sync_benchmark (method ["exec" ], num_calls ,)
180+ outcomes ["HTTPProvider" ] = sync_benchmark (
181+ method ["exec" ],
182+ num_calls ,
183+ )
169184 outcomes ["AsyncHTTPProvider" ] = loop .run_until_complete (
170185 async_benchmark (method ["async_exec" ], num_calls )
171186 )
0 commit comments