@@ -165,28 +165,13 @@ func TestTransactionPriceNonceSort(t *testing.T) {
165
165
t .Errorf ("invalid nonce ordering: tx #%d (A=%x N=%v) < tx #%d (A=%x N=%v)" , i , fromi [:4 ], txi .Nonce (), i + j , fromj [:4 ], txj .Nonce ())
166
166
}
167
167
}
168
- // Find the previous and next nonce of this account
169
- prev , next := i - 1 , i + 1
170
- for j := i - 1 ; j >= 0 ; j -- {
171
- if fromj , _ := Sender (signer , txs [j ]); fromi == fromj {
172
- prev = j
173
- break
174
- }
175
- }
176
- for j := i + 1 ; j < len (txs ); j ++ {
177
- if fromj , _ := Sender (signer , txs [j ]); fromi == fromj {
178
- next = j
179
- break
180
- }
181
- }
182
- // Make sure that in between the neighbor nonces, the transaction is correctly positioned price wise
183
- for j := prev + 1 ; j < next ; j ++ {
184
- fromj , _ := Sender (signer , txs [j ])
185
- if j < i && txs [j ].GasPrice ().Cmp (txi .GasPrice ()) < 0 {
186
- t .Errorf ("invalid gasprice ordering: tx #%d (A=%x P=%v) < tx #%d (A=%x P=%v)" , j , fromj [:4 ], txs [j ].GasPrice (), i , fromi [:4 ], txi .GasPrice ())
187
- }
188
- if j > i && txs [j ].GasPrice ().Cmp (txi .GasPrice ()) > 0 {
189
- t .Errorf ("invalid gasprice ordering: tx #%d (A=%x P=%v) > tx #%d (A=%x P=%v)" , j , fromj [:4 ], txs [j ].GasPrice (), i , fromi [:4 ], txi .GasPrice ())
168
+
169
+ // If the next tx has different from account, the price must be lower than the current one
170
+ if i + 1 < len (txs ) {
171
+ next := txs [i + 1 ]
172
+ fromNext , _ := Sender (signer , next )
173
+ if fromi != fromNext && txi .GasPrice ().Cmp (next .GasPrice ()) < 0 {
174
+ t .Errorf ("invalid gasprice ordering: tx #%d (A=%x P=%v) < tx #%d (A=%x P=%v)" , i , fromi [:4 ], txi .GasPrice (), i + 1 , fromNext [:4 ], next .GasPrice ())
190
175
}
191
176
}
192
177
}
0 commit comments