@@ -174,8 +174,8 @@ mod check_if_resubmission_makes_sense {
174174 }
175175
176176 #[ test]
177- fn resubmission_with_same_gas_price_is_rejected ( ) {
178- // Transaction with existing gas price
177+ fn resubmission_with_same_gas_price_is_rejected_for_included ( ) {
178+ // Transaction with existing gas price in Included status
179179 let mut tx = dummy_evm_tx (
180180 ExpectedTxType :: Eip1559 ,
181181 vec ! [ ] ,
@@ -207,6 +207,144 @@ mod check_if_resubmission_makes_sense {
207207 assert ! ( matches!( result, Err ( LanderError :: TxAlreadyExists ) ) ) ;
208208 }
209209
210+ #[ test]
211+ fn resubmission_with_same_gas_price_is_rejected_for_pending_inclusion ( ) {
212+ // Transaction with existing gas price in PendingInclusion status
213+ let mut tx = dummy_evm_tx (
214+ ExpectedTxType :: Eip1559 ,
215+ vec ! [ ] ,
216+ crate :: TransactionStatus :: PendingInclusion ,
217+ H160 :: random ( ) ,
218+ ) ;
219+
220+ // Set existing gas price
221+ if let VmSpecificTxData :: Evm ( ethereum_tx_precursor) = & mut tx. vm_specific_data {
222+ ethereum_tx_precursor. tx = TypedTransaction :: Eip1559 ( Eip1559TransactionRequest {
223+ from : Some ( H160 :: random ( ) ) ,
224+ to : Some ( H160 :: random ( ) . into ( ) ) ,
225+ nonce : Some ( 0 . into ( ) ) ,
226+ gas : Some ( 21000 . into ( ) ) ,
227+ max_fee_per_gas : Some ( 1000000000 . into ( ) ) ,
228+ max_priority_fee_per_gas : Some ( 1000000 . into ( ) ) ,
229+ value : Some ( 1 . into ( ) ) ,
230+ ..Default :: default ( )
231+ } ) ;
232+ }
233+
234+ // New gas price is the same
235+ let new_gas_price = GasPrice :: Eip1559 {
236+ max_fee : 1000000000u64 . into ( ) ,
237+ max_priority_fee : 1000000u64 . into ( ) ,
238+ } ;
239+
240+ let result = EthereumAdapter :: check_if_resubmission_makes_sense ( & tx, & new_gas_price) ;
241+ assert ! ( matches!( result, Err ( LanderError :: TxWontBeResubmitted ) ) ) ;
242+ }
243+
244+ #[ test]
245+ fn resubmission_with_same_gas_price_is_rejected_for_mempool ( ) {
246+ // Transaction with existing gas price in Mempool status
247+ let mut tx = dummy_evm_tx (
248+ ExpectedTxType :: Eip1559 ,
249+ vec ! [ ] ,
250+ crate :: TransactionStatus :: Mempool ,
251+ H160 :: random ( ) ,
252+ ) ;
253+
254+ // Set existing gas price
255+ if let VmSpecificTxData :: Evm ( ethereum_tx_precursor) = & mut tx. vm_specific_data {
256+ ethereum_tx_precursor. tx = TypedTransaction :: Eip1559 ( Eip1559TransactionRequest {
257+ from : Some ( H160 :: random ( ) ) ,
258+ to : Some ( H160 :: random ( ) . into ( ) ) ,
259+ nonce : Some ( 0 . into ( ) ) ,
260+ gas : Some ( 21000 . into ( ) ) ,
261+ max_fee_per_gas : Some ( 1000000000 . into ( ) ) ,
262+ max_priority_fee_per_gas : Some ( 1000000 . into ( ) ) ,
263+ value : Some ( 1 . into ( ) ) ,
264+ ..Default :: default ( )
265+ } ) ;
266+ }
267+
268+ // New gas price is the same
269+ let new_gas_price = GasPrice :: Eip1559 {
270+ max_fee : 1000000000u64 . into ( ) ,
271+ max_priority_fee : 1000000u64 . into ( ) ,
272+ } ;
273+
274+ let result = EthereumAdapter :: check_if_resubmission_makes_sense ( & tx, & new_gas_price) ;
275+ assert ! ( matches!( result, Err ( LanderError :: TxAlreadyExists ) ) ) ;
276+ }
277+
278+ #[ test]
279+ fn resubmission_with_same_gas_price_is_rejected_for_finalized ( ) {
280+ // Transaction with existing gas price in Finalized status
281+ let mut tx = dummy_evm_tx (
282+ ExpectedTxType :: Eip1559 ,
283+ vec ! [ ] ,
284+ crate :: TransactionStatus :: Finalized ,
285+ H160 :: random ( ) ,
286+ ) ;
287+
288+ // Set existing gas price
289+ if let VmSpecificTxData :: Evm ( ethereum_tx_precursor) = & mut tx. vm_specific_data {
290+ ethereum_tx_precursor. tx = TypedTransaction :: Eip1559 ( Eip1559TransactionRequest {
291+ from : Some ( H160 :: random ( ) ) ,
292+ to : Some ( H160 :: random ( ) . into ( ) ) ,
293+ nonce : Some ( 0 . into ( ) ) ,
294+ gas : Some ( 21000 . into ( ) ) ,
295+ max_fee_per_gas : Some ( 1000000000 . into ( ) ) ,
296+ max_priority_fee_per_gas : Some ( 1000000 . into ( ) ) ,
297+ value : Some ( 1 . into ( ) ) ,
298+ ..Default :: default ( )
299+ } ) ;
300+ }
301+
302+ // New gas price is the same
303+ let new_gas_price = GasPrice :: Eip1559 {
304+ max_fee : 1000000000u64 . into ( ) ,
305+ max_priority_fee : 1000000u64 . into ( ) ,
306+ } ;
307+
308+ let result = EthereumAdapter :: check_if_resubmission_makes_sense ( & tx, & new_gas_price) ;
309+ assert ! ( matches!( result, Err ( LanderError :: TxAlreadyExists ) ) ) ;
310+ }
311+
312+ #[ test]
313+ fn resubmission_with_same_gas_price_is_rejected_for_dropped ( ) {
314+ use crate :: transaction:: DropReason ;
315+
316+ // Transaction with existing gas price in Dropped status
317+ let mut tx = dummy_evm_tx (
318+ ExpectedTxType :: Eip1559 ,
319+ vec ! [ ] ,
320+ crate :: TransactionStatus :: Dropped ( DropReason :: DroppedByChain ) ,
321+ H160 :: random ( ) ,
322+ ) ;
323+
324+ // Set existing gas price
325+ if let VmSpecificTxData :: Evm ( ethereum_tx_precursor) = & mut tx. vm_specific_data {
326+ ethereum_tx_precursor. tx = TypedTransaction :: Eip1559 ( Eip1559TransactionRequest {
327+ from : Some ( H160 :: random ( ) ) ,
328+ to : Some ( H160 :: random ( ) . into ( ) ) ,
329+ nonce : Some ( 0 . into ( ) ) ,
330+ gas : Some ( 21000 . into ( ) ) ,
331+ max_fee_per_gas : Some ( 1000000000 . into ( ) ) ,
332+ max_priority_fee_per_gas : Some ( 1000000 . into ( ) ) ,
333+ value : Some ( 1 . into ( ) ) ,
334+ ..Default :: default ( )
335+ } ) ;
336+ }
337+
338+ // New gas price is the same
339+ let new_gas_price = GasPrice :: Eip1559 {
340+ max_fee : 1000000000u64 . into ( ) ,
341+ max_priority_fee : 1000000u64 . into ( ) ,
342+ } ;
343+
344+ let result = EthereumAdapter :: check_if_resubmission_makes_sense ( & tx, & new_gas_price) ;
345+ assert ! ( matches!( result, Err ( LanderError :: TxWontBeResubmitted ) ) ) ;
346+ }
347+
210348 #[ test]
211349 fn legacy_tx_resubmission_with_higher_gas_price_is_allowed ( ) {
212350 // Transaction with existing legacy gas price
@@ -240,8 +378,8 @@ mod check_if_resubmission_makes_sense {
240378 }
241379
242380 #[ test]
243- fn legacy_tx_resubmission_with_same_gas_price_is_rejected ( ) {
244- // Transaction with existing legacy gas price
381+ fn legacy_tx_resubmission_with_same_gas_price_is_rejected_for_included ( ) {
382+ // Transaction with existing legacy gas price in Included status
245383 let mut tx = dummy_evm_tx (
246384 ExpectedTxType :: Legacy ,
247385 vec ! [ ] ,
@@ -271,6 +409,38 @@ mod check_if_resubmission_makes_sense {
271409 assert ! ( matches!( result, Err ( LanderError :: TxAlreadyExists ) ) ) ;
272410 }
273411
412+ #[ test]
413+ fn legacy_tx_resubmission_with_same_gas_price_is_rejected_for_pending_inclusion ( ) {
414+ // Transaction with existing legacy gas price in PendingInclusion status
415+ let mut tx = dummy_evm_tx (
416+ ExpectedTxType :: Legacy ,
417+ vec ! [ ] ,
418+ crate :: TransactionStatus :: PendingInclusion ,
419+ H160 :: random ( ) ,
420+ ) ;
421+
422+ // Set existing gas price
423+ if let VmSpecificTxData :: Evm ( ethereum_tx_precursor) = & mut tx. vm_specific_data {
424+ ethereum_tx_precursor. tx = TypedTransaction :: Legacy ( TransactionRequest {
425+ from : Some ( H160 :: random ( ) ) ,
426+ to : Some ( H160 :: random ( ) . into ( ) ) ,
427+ nonce : Some ( 0 . into ( ) ) ,
428+ gas : Some ( 21000 . into ( ) ) ,
429+ gas_price : Some ( 1000000000 . into ( ) ) ,
430+ value : Some ( 1 . into ( ) ) ,
431+ ..Default :: default ( )
432+ } ) ;
433+ }
434+
435+ // New gas price is the same
436+ let new_gas_price = GasPrice :: NonEip1559 {
437+ gas_price : 1000000000u64 . into ( ) ,
438+ } ;
439+
440+ let result = EthereumAdapter :: check_if_resubmission_makes_sense ( & tx, & new_gas_price) ;
441+ assert ! ( matches!( result, Err ( LanderError :: TxWontBeResubmitted ) ) ) ;
442+ }
443+
274444 #[ test]
275445 fn eip1559_resubmission_with_only_max_fee_increased_is_allowed ( ) {
276446 // Transaction with existing gas price
0 commit comments