@@ -26,6 +26,20 @@ func TestVerifyBundlesAtomicity(t *testing.T) {
2626 expectedErr error
2727 }{
2828 // Success cases
29+ {
30+ name : "Simple bundle with 1 tx included" ,
31+ includedBundles : map [common.Hash ][]bundleTxData {
32+ common .HexToHash ("0xb1" ): {
33+ {hash : common .HexToHash ("0xb11" ), canRevert : false },
34+ },
35+ },
36+ includedTxDataByHash : map [common.Hash ]includedTxData {
37+ common .HexToHash ("0xb11" ): {hash : common .HexToHash ("0xb11" ), index : 0 , reverted : false },
38+ },
39+ privateTxData : nil ,
40+ mempoolTxHashes : nil ,
41+ expectedErr : nil ,
42+ },
2943 {
3044 name : "Simple bundle included" ,
3145 includedBundles : map [common.Hash ][]bundleTxData {
@@ -120,6 +134,24 @@ func TestVerifyBundlesAtomicity(t *testing.T) {
120134 privateTxData : nil ,
121135 expectedErr : nil ,
122136 },
137+ {
138+ name : "Bundle marked included but none of the txs are included (all optional)" ,
139+ includedBundles : map [common.Hash ][]bundleTxData {
140+ common .HexToHash ("0xb1" ): {
141+ {hash : common .HexToHash ("0xb11" ), canRevert : true },
142+ {hash : common .HexToHash ("0xb12" ), canRevert : true },
143+ {hash : common .HexToHash ("0xb13" ), canRevert : true },
144+ },
145+ },
146+ includedTxDataByHash : map [common.Hash ]includedTxData {
147+ common .HexToHash ("0xc1" ): {hash : common .HexToHash ("0xc1" ), index : 0 , reverted : false },
148+ },
149+ mempoolTxHashes : map [common.Hash ]struct {}{
150+ common .HexToHash ("0xc1" ): {},
151+ },
152+ privateTxData : nil ,
153+ expectedErr : nil ,
154+ },
123155 {
124156 name : "Simple bundle included with all revertible tx, last of them is included as success" ,
125157 includedBundles : map [common.Hash ][]bundleTxData {
@@ -185,6 +217,76 @@ func TestVerifyBundlesAtomicity(t *testing.T) {
185217 },
186218 expectedErr : nil ,
187219 },
220+ {
221+ name : "Two bundles included, one have optional tx in the middle that gets included as part of other bundle" ,
222+ includedBundles : map [common.Hash ][]bundleTxData {
223+ common .HexToHash ("0xb1" ): {
224+ {hash : common .HexToHash ("0xb00" ), canRevert : true },
225+ {hash : common .HexToHash ("0xb12" ), canRevert : false },
226+ },
227+ common .HexToHash ("0xb2" ): {
228+ {hash : common .HexToHash ("0xb21" ), canRevert : false },
229+ {hash : common .HexToHash ("0xb00" ), canRevert : true },
230+ {hash : common .HexToHash ("0xb22" ), canRevert : false },
231+ },
232+ },
233+ includedTxDataByHash : map [common.Hash ]includedTxData {
234+ common .HexToHash ("0xb00" ): {hash : common .HexToHash ("0xb00" ), index : 0 , reverted : false },
235+ common .HexToHash ("0xb12" ): {hash : common .HexToHash ("0xb12" ), index : 1 , reverted : false },
236+ common .HexToHash ("0xc1" ): {hash : common .HexToHash ("0xc1" ), index : 2 , reverted : true },
237+ common .HexToHash ("0xb21" ): {hash : common .HexToHash ("0xb21" ), index : 3 , reverted : false },
238+ common .HexToHash ("0xb22" ): {hash : common .HexToHash ("0xb22" ), index : 4 , reverted : false },
239+ },
240+ privateTxData : nil ,
241+ mempoolTxHashes : map [common.Hash ]struct {}{
242+ common .HexToHash ("0xc1" ): {},
243+ },
244+ expectedErr : nil ,
245+ },
246+ {
247+ name : "Optional tx in the middle of the bundle was included after the bundle as part of mempool" ,
248+ includedBundles : map [common.Hash ][]bundleTxData {
249+ common .HexToHash ("0xb1" ): {
250+ {hash : common .HexToHash ("0xb11" ), canRevert : false },
251+ {hash : common .HexToHash ("0xb00" ), canRevert : true },
252+ {hash : common .HexToHash ("0xb12" ), canRevert : false },
253+ },
254+ },
255+ includedTxDataByHash : map [common.Hash ]includedTxData {
256+ common .HexToHash ("0xb11" ): {hash : common .HexToHash ("0xb11" ), index : 0 , reverted : false },
257+ common .HexToHash ("0xb12" ): {hash : common .HexToHash ("0xb12" ), index : 1 , reverted : false },
258+ common .HexToHash ("0xc1" ): {hash : common .HexToHash ("0xc1" ), index : 2 , reverted : true },
259+ common .HexToHash ("0xb00" ): {hash : common .HexToHash ("0xb00" ), index : 3 , reverted : false },
260+ },
261+ privateTxData : nil ,
262+ mempoolTxHashes : map [common.Hash ]struct {}{
263+ common .HexToHash ("0xc1" ): {},
264+ common .HexToHash ("0xb00" ): {},
265+ },
266+ expectedErr : nil ,
267+ },
268+ {
269+ name : "Optional tx in the middle of the bundle was included before the bundle as part of mempool" ,
270+ includedBundles : map [common.Hash ][]bundleTxData {
271+ common .HexToHash ("0xb1" ): {
272+ {hash : common .HexToHash ("0xb11" ), canRevert : false },
273+ {hash : common .HexToHash ("0xb00" ), canRevert : true },
274+ {hash : common .HexToHash ("0xb12" ), canRevert : false },
275+ },
276+ },
277+ includedTxDataByHash : map [common.Hash ]includedTxData {
278+ common .HexToHash ("0xb00" ): {hash : common .HexToHash ("0xb00" ), index : 0 , reverted : false },
279+ common .HexToHash ("0xb11" ): {hash : common .HexToHash ("0xb11" ), index : 1 , reverted : false },
280+ common .HexToHash ("0xb12" ): {hash : common .HexToHash ("0xb12" ), index : 2 , reverted : false },
281+ common .HexToHash ("0xc1" ): {hash : common .HexToHash ("0xc1" ), index : 3 , reverted : true },
282+ },
283+ privateTxData : nil ,
284+ mempoolTxHashes : map [common.Hash ]struct {}{
285+ common .HexToHash ("0xc1" ): {},
286+ common .HexToHash ("0xb00" ): {},
287+ },
288+ expectedErr : nil ,
289+ },
188290 {
189291 name : "Private tx from overlapping included bundle included" ,
190292 includedBundles : map [common.Hash ][]bundleTxData {
@@ -423,7 +525,7 @@ func TestVerifyBundlesAtomicity(t *testing.T) {
423525 require .NoError (t , err )
424526 } else {
425527 require .Error (t , err )
426- require .Equal (t , err , test .expectedErr )
528+ require .Equal (t , test .expectedErr , err )
427529 }
428530 })
429531 }
0 commit comments