@@ -18,6 +18,8 @@ use zksync_types::{
1818 commitment:: { L1BatchCommitmentMode , PubdataParams } ,
1919 fee_model:: { BatchFeeInput , PubdataIndependentBatchFeeModelInput } ,
2020 l2:: L2Tx ,
21+ protocol_upgrade:: ProtocolUpgradeTx ,
22+ protocol_version:: ProtocolSemanticVersion ,
2123 AccountTreeId , Address , L1BatchNumber , L2BlockNumber , L2ChainId , ProtocolVersion ,
2224 ProtocolVersionId , StorageKey , TransactionTimeRangeConstraint , H256 , U256 ,
2325} ;
@@ -848,6 +850,52 @@ async fn test_mempool_with_timestamp_assertion() {
848850 ) ;
849851}
850852
853+ #[ tokio:: test]
854+ async fn test_batch_params_with_protocol_upgrade_tx ( ) {
855+ let connection_pool = ConnectionPool :: < Core > :: constrained_test_pool ( 2 ) . await ;
856+ let tester = Tester :: new ( L1BatchCommitmentMode :: Rollup ) ;
857+ // Genesis is needed for proper mempool initialization.
858+ tester. genesis ( & connection_pool) . await ;
859+
860+ let ( mut mempool, _) = tester. create_test_mempool_io ( connection_pool. clone ( ) ) . await ;
861+ let ( cursor, _) = mempool. initialize ( ) . await . unwrap ( ) ;
862+
863+ // Check that new batch params are not returned when there is no tx to process.
864+ let new_batch_params = mempool
865+ . wait_for_new_batch_params ( & cursor, Duration :: from_millis ( 100 ) )
866+ . await
867+ . unwrap ( ) ;
868+ assert ! ( new_batch_params. is_none( ) ) ;
869+
870+ // Insert protocol version with upgrade tx.
871+ let protocol_upgrade_tx = ProtocolUpgradeTx {
872+ execute : Default :: default ( ) ,
873+ common_data : Default :: default ( ) ,
874+ received_timestamp_ms : 0 ,
875+ } ;
876+ let version = ProtocolVersion {
877+ version : ProtocolSemanticVersion {
878+ minor : ProtocolVersionId :: next ( ) ,
879+ patch : 0 . into ( ) ,
880+ } ,
881+ tx : Some ( protocol_upgrade_tx) ,
882+ ..Default :: default ( )
883+ } ;
884+ connection_pool
885+ . connection ( )
886+ . await
887+ . unwrap ( )
888+ . protocol_versions_dal ( )
889+ . save_protocol_version_with_tx ( & version)
890+ . await
891+ . unwrap ( ) ;
892+ let new_batch_params = mempool
893+ . wait_for_new_batch_params ( & cursor, Duration :: from_millis ( 100 ) )
894+ . await
895+ . unwrap ( ) ;
896+ assert ! ( new_batch_params. is_some( ) ) ;
897+ }
898+
851899async fn insert_l2_transaction ( storage : & mut Connection < ' _ , Core > , tx : & L2Tx ) {
852900 storage
853901 . transactions_dal ( )
0 commit comments