@@ -161,6 +161,39 @@ async fn can_get_pending_block() {
161
161
assert_eq ! ( block. transactions. len( ) , 1 ) ;
162
162
}
163
163
164
+ #[ tokio:: test( flavor = "multi_thread" ) ]
165
+ async fn can_estimate_gas_with_undersized_max_fee_per_gas ( ) {
166
+ let ( api, handle) = spawn ( NodeConfig :: test ( ) ) . await ;
167
+ let wallet = handle. dev_wallets ( ) . next ( ) . unwrap ( ) ;
168
+ let signer: EthereumWallet = wallet. clone ( ) . into ( ) ;
169
+
170
+ let provider = http_provider_with_signer ( & handle. http_endpoint ( ) , signer) ;
171
+
172
+ api. anvil_set_auto_mine ( true ) . await . unwrap ( ) ;
173
+
174
+ let init_value = "toto" . to_string ( ) ;
175
+
176
+ let simple_storage_contract =
177
+ SimpleStorage :: deploy ( & provider, init_value. clone ( ) ) . await . unwrap ( ) ;
178
+
179
+ let undersized_max_fee_per_gas = 1_u128 ;
180
+
181
+ let latest_block = api. block_by_number ( BlockNumberOrTag :: Latest ) . await . unwrap ( ) . unwrap ( ) ;
182
+ let latest_block_base_fee_per_gas = latest_block. header . base_fee_per_gas . unwrap ( ) ;
183
+
184
+ assert ! ( undersized_max_fee_per_gas < latest_block_base_fee_per_gas) ;
185
+
186
+ let estimated_gas = simple_storage_contract
187
+ . setValue ( "new_value" . to_string ( ) )
188
+ . max_fee_per_gas ( undersized_max_fee_per_gas)
189
+ . from ( wallet. address ( ) )
190
+ . estimate_gas ( )
191
+ . await
192
+ . unwrap ( ) ;
193
+
194
+ assert ! ( estimated_gas > 0 ) ;
195
+ }
196
+
164
197
#[ tokio:: test( flavor = "multi_thread" ) ]
165
198
async fn can_call_on_pending_block ( ) {
166
199
let ( api, handle) = spawn ( NodeConfig :: test ( ) ) . await ;
@@ -239,6 +272,38 @@ async fn can_call_on_pending_block() {
239
272
}
240
273
}
241
274
275
+ #[ tokio:: test( flavor = "multi_thread" ) ]
276
+ async fn can_call_with_undersized_max_fee_per_gas ( ) {
277
+ let ( api, handle) = spawn ( NodeConfig :: test ( ) ) . await ;
278
+ let wallet = handle. dev_wallets ( ) . next ( ) . unwrap ( ) ;
279
+ let signer: EthereumWallet = wallet. clone ( ) . into ( ) ;
280
+
281
+ let provider = http_provider_with_signer ( & handle. http_endpoint ( ) , signer) ;
282
+
283
+ api. anvil_set_auto_mine ( true ) . await . unwrap ( ) ;
284
+
285
+ let init_value = "toto" . to_string ( ) ;
286
+
287
+ let simple_storage_contract =
288
+ SimpleStorage :: deploy ( & provider, init_value. clone ( ) ) . await . unwrap ( ) ;
289
+
290
+ let latest_block = api. block_by_number ( BlockNumberOrTag :: Latest ) . await . unwrap ( ) . unwrap ( ) ;
291
+ let latest_block_base_fee_per_gas = latest_block. header . base_fee_per_gas . unwrap ( ) ;
292
+ let undersized_max_fee_per_gas = 1_u128 ;
293
+
294
+ assert ! ( undersized_max_fee_per_gas < latest_block_base_fee_per_gas) ;
295
+
296
+ let last_sender = simple_storage_contract
297
+ . lastSender ( )
298
+ . max_fee_per_gas ( undersized_max_fee_per_gas)
299
+ . from ( wallet. address ( ) )
300
+ . call ( )
301
+ . await
302
+ . unwrap ( )
303
+ . _0 ;
304
+ assert_eq ! ( last_sender, Address :: ZERO ) ;
305
+ }
306
+
242
307
#[ tokio:: test( flavor = "multi_thread" ) ]
243
308
async fn can_call_with_state_override ( ) {
244
309
let ( api, handle) = spawn ( NodeConfig :: test ( ) ) . await ;
0 commit comments