@@ -215,3 +215,46 @@ async fn test_can_use_fee_history() {
215
215
assert_eq ! ( latest_fee_history_fee, next_base_fee as u64 ) ;
216
216
}
217
217
}
218
+
219
+ #[ tokio:: test( flavor = "multi_thread" ) ]
220
+ async fn test_estimate_gas_empty_data ( ) {
221
+ let ( api, handle) = spawn ( NodeConfig :: test ( ) ) . await ;
222
+ let accounts = handle. dev_accounts ( ) . collect :: < Vec < _ > > ( ) ;
223
+ let from = accounts[ 0 ] ;
224
+ let to = accounts[ 1 ] ;
225
+
226
+ let tx_without_data =
227
+ TransactionRequest :: default ( ) . with_from ( from) . with_to ( to) . with_value ( U256 :: from ( 1 ) ) ;
228
+
229
+ let gas_without_data = api
230
+ . estimate_gas ( WithOtherFields :: new ( tx_without_data) , None , Default :: default ( ) )
231
+ . await
232
+ . unwrap ( ) ;
233
+
234
+ let tx_with_empty_data = TransactionRequest :: default ( )
235
+ . with_from ( from)
236
+ . with_to ( to)
237
+ . with_value ( U256 :: from ( 1 ) )
238
+ . with_input ( vec ! [ ] ) ;
239
+
240
+ let gas_with_empty_data = api
241
+ . estimate_gas ( WithOtherFields :: new ( tx_with_empty_data) , None , Default :: default ( ) )
242
+ . await
243
+ . unwrap ( ) ;
244
+
245
+ let tx_with_data = TransactionRequest :: default ( )
246
+ . with_from ( from)
247
+ . with_to ( to)
248
+ . with_value ( U256 :: from ( 1 ) )
249
+ . with_input ( vec ! [ 0x12 , 0x34 ] ) ;
250
+
251
+ let gas_with_data = api
252
+ . estimate_gas ( WithOtherFields :: new ( tx_with_data) , None , Default :: default ( ) )
253
+ . await
254
+ . unwrap ( ) ;
255
+
256
+ assert_eq ! ( gas_without_data, U256 :: from( GAS_TRANSFER ) ) ;
257
+ assert_eq ! ( gas_with_empty_data, U256 :: from( GAS_TRANSFER ) ) ;
258
+ assert ! ( gas_with_data > U256 :: from( GAS_TRANSFER ) ) ;
259
+ assert_eq ! ( gas_without_data, gas_with_empty_data) ;
260
+ }
0 commit comments