@@ -10,7 +10,7 @@ use signet_zenith::{HostOrders::fillCall, RollupOrders::initiateCall};
1010use std:: time:: { Duration , Instant } ;
1111
1212#[ tokio:: test]
13- async fn test_with_host_sim ( ) {
13+ async fn host_sim ( ) {
1414 let builder = test_sim_env ( Instant :: now ( ) + Duration :: from_millis ( 200 ) ) ;
1515
1616 // Set up an order, fill pair
@@ -70,7 +70,7 @@ async fn test_with_host_sim() {
7070}
7171
7272#[ tokio:: test]
73- async fn test_with_host_sim_insufficient_fill ( ) {
73+ async fn host_sim_insufficient_fill ( ) {
7474 let builder = test_sim_env ( Instant :: now ( ) + Duration :: from_millis ( 200 ) ) ;
7575
7676 // Set up an order, fill pair
@@ -132,9 +132,7 @@ async fn test_with_host_sim_insufficient_fill() {
132132
133133// Currently 0-score bundles are dropped entirely. This may change in future.
134134#[ tokio:: test]
135- async fn test_with_host_sim_insufficient_fill_reverting_ok ( ) {
136- signet_test_utils:: init_tracing ( ) ;
137-
135+ async fn host_sim_insufficient_fill_reverting_ok ( ) {
138136 let builder = test_sim_env ( Instant :: now ( ) + Duration :: from_millis ( 200 ) ) ;
139137
140138 // Set up an order, fill pair
@@ -198,7 +196,7 @@ async fn test_with_host_sim_insufficient_fill_reverting_ok() {
198196}
199197
200198#[ tokio:: test]
201- async fn test_too_much_host_gas ( ) {
199+ async fn too_much_host_gas ( ) {
202200 let mut builder = test_sim_env ( Instant :: now ( ) + Duration :: from_millis ( 200 ) ) ;
203201 builder. set_max_host_gas ( 1 ) ; // Set max host gas very low
204202
@@ -256,7 +254,185 @@ async fn test_too_much_host_gas() {
256254
257255 let block = builder. build ( ) . await ;
258256
259- //
260257 assert ! ( block. transactions( ) . is_empty( ) ) ;
261258 assert ! ( block. host_transactions( ) . is_empty( ) ) ;
262259}
260+
261+ #[ tokio:: test]
262+ async fn larger_bundle ( ) {
263+ let builder = test_sim_env ( Instant :: now ( ) + Duration :: from_millis ( 200 ) ) ;
264+
265+ // Set up an order, fill pair
266+ let order = UnsignedOrder :: default ( )
267+ . with_input ( TEST_SYS . rollup ( ) . tokens ( ) . weth ( ) , U256 :: from ( 1000 ) )
268+ . with_output (
269+ TEST_SYS . host ( ) . tokens ( ) . weth ( ) ,
270+ U256 :: from ( 1000 ) ,
271+ TEST_USERS [ 5 ] ,
272+ TEST_SYS . host_chain_id ( ) as u32 ,
273+ )
274+ . to_order ( ) ;
275+
276+ let fill_outputs = order
277+ . outputs
278+ . clone ( )
279+ . into_iter ( )
280+ . map ( |mut output| {
281+ output. chainId = TEST_SYS . host_chain_id ( ) as u32 ;
282+ output
283+ } )
284+ . collect :: < Vec < _ > > ( ) ;
285+
286+ let order_call =
287+ initiateCall { deadline : U256 :: MAX , inputs : order. inputs , outputs : order. outputs } ;
288+
289+ let fill_call = fillCall { outputs : fill_outputs } ;
290+
291+ // Make RU and HOST transactions
292+ let ru_tx = signed_simple_call (
293+ & TEST_SIGNERS [ 0 ] ,
294+ TEST_SYS . ru_orders ( ) ,
295+ & order_call,
296+ U256 :: ZERO ,
297+ 0 ,
298+ TEST_SYS . ru_chain_id ( ) ,
299+ ) ;
300+ let ru_tx_1 = signed_simple_call (
301+ & TEST_SIGNERS [ 0 ] ,
302+ TEST_SYS . ru_orders ( ) ,
303+ & order_call,
304+ U256 :: ZERO ,
305+ 1 ,
306+ TEST_SYS . ru_chain_id ( ) ,
307+ ) ;
308+ let ru_tx_2 = signed_simple_call (
309+ & TEST_SIGNERS [ 0 ] ,
310+ TEST_SYS . ru_orders ( ) ,
311+ & order_call,
312+ U256 :: ZERO ,
313+ 2 ,
314+ TEST_SYS . ru_chain_id ( ) ,
315+ ) ;
316+
317+ let host_tx = signed_simple_call (
318+ & TEST_SIGNERS [ 1 ] ,
319+ TEST_SYS . host_orders ( ) ,
320+ & fill_call,
321+ U256 :: ZERO ,
322+ 0 ,
323+ TEST_SYS . host_chain_id ( ) ,
324+ ) ;
325+ let host_tx_1 = signed_simple_call (
326+ & TEST_SIGNERS [ 1 ] ,
327+ TEST_SYS . host_orders ( ) ,
328+ & fill_call,
329+ U256 :: ZERO ,
330+ 1 ,
331+ TEST_SYS . host_chain_id ( ) ,
332+ ) ;
333+ let host_tx_2 = signed_simple_call (
334+ & TEST_SIGNERS [ 1 ] ,
335+ TEST_SYS . host_orders ( ) ,
336+ & fill_call,
337+ U256 :: ZERO ,
338+ 2 ,
339+ TEST_SYS . host_chain_id ( ) ,
340+ ) ;
341+
342+ let bundle =
343+ simple_bundle ( vec ! [ ru_tx, ru_tx_1, ru_tx_2] , vec ! [ host_tx, host_tx_1, host_tx_2] , 0 ) ;
344+
345+ builder. sim_items ( ) . add_bundle ( bundle, 0 ) . unwrap ( ) ;
346+
347+ let block = builder. build ( ) . await ;
348+
349+ assert_eq ! ( block. transactions( ) . len( ) , 3 ) ;
350+ assert_eq ! ( block. host_transactions( ) . len( ) , 3 ) ;
351+ }
352+
353+ #[ tokio:: test]
354+ async fn larger_bundle_revert_ok ( ) {
355+ let builder = test_sim_env ( Instant :: now ( ) + Duration :: from_millis ( 200 ) ) ;
356+
357+ // Set up an order, fill pair
358+ let order = UnsignedOrder :: default ( )
359+ . with_input ( TEST_SYS . rollup ( ) . tokens ( ) . weth ( ) , U256 :: from ( 1000 ) )
360+ . with_output (
361+ TEST_SYS . host ( ) . tokens ( ) . weth ( ) ,
362+ U256 :: from ( 1000 ) ,
363+ TEST_USERS [ 5 ] ,
364+ TEST_SYS . host_chain_id ( ) as u32 ,
365+ )
366+ . to_order ( ) ;
367+
368+ let fill_outputs = order
369+ . outputs
370+ . clone ( )
371+ . into_iter ( )
372+ . map ( |mut output| {
373+ output. chainId = TEST_SYS . host_chain_id ( ) as u32 ;
374+ output
375+ } )
376+ . collect :: < Vec < _ > > ( ) ;
377+
378+ let order_call =
379+ initiateCall { deadline : U256 :: MAX , inputs : order. inputs , outputs : order. outputs } ;
380+
381+ let fill_call = fillCall { outputs : fill_outputs } ;
382+
383+ // Make RU and HOST transactions
384+ let ru_tx = signed_simple_call (
385+ & TEST_SIGNERS [ 0 ] ,
386+ TEST_SYS . ru_orders ( ) ,
387+ & order_call,
388+ U256 :: ZERO ,
389+ 0 ,
390+ TEST_SYS . ru_chain_id ( ) ,
391+ ) ;
392+ let ru_tx_1 = signed_simple_call (
393+ & TEST_SIGNERS [ 0 ] ,
394+ TEST_SYS . ru_orders ( ) ,
395+ & order_call,
396+ U256 :: ZERO ,
397+ 1 ,
398+ TEST_SYS . ru_chain_id ( ) ,
399+ ) ;
400+ let ru_tx_2 = signed_simple_call (
401+ & TEST_SIGNERS [ 0 ] ,
402+ TEST_SYS . ru_orders ( ) ,
403+ & order_call,
404+ U256 :: ZERO ,
405+ 2 ,
406+ TEST_SYS . ru_chain_id ( ) ,
407+ ) ;
408+
409+ let host_tx = signed_simple_call (
410+ & TEST_SIGNERS [ 1 ] ,
411+ TEST_SYS . host_orders ( ) ,
412+ & fill_call,
413+ U256 :: ZERO ,
414+ 0 ,
415+ TEST_SYS . host_chain_id ( ) ,
416+ ) ;
417+ let host_tx_1 = signed_simple_call (
418+ & TEST_SIGNERS [ 1 ] ,
419+ TEST_SYS . host_orders ( ) ,
420+ & fill_call,
421+ U256 :: ZERO ,
422+ 1 ,
423+ TEST_SYS . host_chain_id ( ) ,
424+ ) ;
425+
426+ let ru_tx_2_hash = * ru_tx_2. hash ( ) ;
427+
428+ let mut bundle = simple_bundle ( vec ! [ ru_tx, ru_tx_1] , vec ! [ host_tx, host_tx_1] , 0 ) ;
429+
430+ bundle. bundle . reverting_tx_hashes . push ( ru_tx_2_hash) ;
431+
432+ builder. sim_items ( ) . add_bundle ( bundle, 0 ) . unwrap ( ) ;
433+
434+ let block = builder. build ( ) . await ;
435+
436+ assert_eq ! ( block. transactions( ) . len( ) , 2 ) ;
437+ assert_eq ! ( block. host_transactions( ) . len( ) , 2 ) ;
438+ }
0 commit comments