@@ -70,7 +70,7 @@ func TestTxPriorityQueue_PriorityAndNonceOrdering(t *testing.T) {
7070 {sender : "3" , isEVM : true , evmAddress : "0xabc" , evmNonce : 3 , priority : 9 },
7171 {sender : "2" , isEVM : true , evmAddress : "0xabc" , evmNonce : 1 , priority : 7 },
7272 },
73- expectedOutput : []int64 {1 , 2 , 3 },
73+ expectedOutput : []int64 {1 , 3 },
7474 },
7575 {
7676 name : "PriorityWithEVMAndNonEVMDuplicateNonce" ,
@@ -380,17 +380,23 @@ func TestTxPriorityQueue_TryReplacement(t *testing.T) {
380380 expectedQueue []* WrappedTx
381381 expectedHeap []* WrappedTx
382382 }{
383- {& WrappedTx {isEVM : false }, []* WrappedTx {}, false , false , []* WrappedTx {}, []* WrappedTx {}},
384- {& WrappedTx {isEVM : true , evmAddress : "addr1" }, []* WrappedTx {}, false , false , []* WrappedTx {}, []* WrappedTx {}},
383+ // non-evm transaction is inserted into empty queue
384+ {& WrappedTx {isEVM : false }, []* WrappedTx {}, false , false , []* WrappedTx {{isEVM : false }}, []* WrappedTx {{isEVM : false }}},
385+ // evm transaction is inserted into empty queue
386+ {& WrappedTx {isEVM : true , evmAddress : "addr1" }, []* WrappedTx {}, false , false , []* WrappedTx {{isEVM : true , evmAddress : "addr1" }}, []* WrappedTx {{isEVM : true , evmAddress : "addr1" }}},
387+ // evm transaction (new nonce) is inserted into queue with existing tx (lower nonce)
385388 {
386389 & WrappedTx {isEVM : true , evmAddress : "addr1" , evmNonce : 1 , priority : 100 , tx : []byte ("abc" )}, []* WrappedTx {
387390 {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("def" )},
388391 }, false , false , []* WrappedTx {
389392 {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("def" )},
393+ {isEVM : true , evmAddress : "addr1" , evmNonce : 1 , priority : 100 , tx : []byte ("abc" )},
390394 }, []* WrappedTx {
391395 {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("def" )},
396+ {isEVM : true , evmAddress : "addr1" , evmNonce : 1 , priority : 100 , tx : []byte ("abc" )},
392397 },
393398 },
399+ // evm transaction (new nonce) is not inserted because it's a duplicate nonce and same priority
394400 {
395401 & WrappedTx {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("abc" )}, []* WrappedTx {
396402 {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("def" )},
@@ -400,6 +406,7 @@ func TestTxPriorityQueue_TryReplacement(t *testing.T) {
400406 {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("def" )},
401407 },
402408 },
409+ // evm transaction (new nonce) replaces the existing nonce transaction because its priority is higher
403410 {
404411 & WrappedTx {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 101 , tx : []byte ("abc" )}, []* WrappedTx {
405412 {isEVM : true , evmAddress : "addr1" , evmNonce : 0 , priority : 100 , tx : []byte ("def" )},
@@ -425,13 +432,13 @@ func TestTxPriorityQueue_TryReplacement(t *testing.T) {
425432 for _ , e := range test .existing {
426433 pq .PushTx (e )
427434 }
428- replaced , dropped := pq .TryReplacement (test .tx )
435+ replaced , inserted := pq .PushTx (test .tx )
429436 if test .expectedReplaced {
430437 require .NotNil (t , replaced )
431438 } else {
432439 require .Nil (t , replaced )
433440 }
434- require .Equal (t , test .expectedDropped , dropped )
441+ require .Equal (t , test .expectedDropped , ! inserted )
435442 for i , q := range pq .evmQueue [test .tx .evmAddress ] {
436443 require .Equal (t , test .expectedQueue [i ].tx .Key (), q .tx .Key ())
437444 require .Equal (t , test .expectedQueue [i ].priority , q .priority )
0 commit comments