@@ -141,3 +141,61 @@ impl Packages {
141141 self . normal_edges ( pkg) . map ( move |( _, to) | to)
142142 }
143143}
144+
145+ #[ cfg( test) ]
146+ mod adapter_vm_v2_tests {
147+ use sui_protocol_config:: ProtocolConfig ;
148+
149+ #[ test]
150+ fn test_executor_with_old_adapter_old_vm ( ) {
151+ let protocol_config = ProtocolConfig :: get_for_max_version_UNSAFE ( ) ;
152+
153+ // By default both adapter v2 and vm v2 are disabled.
154+
155+ let executor_result = crate :: executor ( & protocol_config, true ) ;
156+
157+ assert ! (
158+ executor_result. is_ok( ) ,
159+ "Executor should be created successfully with VM v2 enabled"
160+ ) ;
161+
162+ assert ! ( !protocol_config. get_use_adapter_v2( ) ) ;
163+ assert ! ( !protocol_config. get_use_vm_v2( ) ) ;
164+ }
165+
166+ #[ test]
167+ fn test_executor_with_new_adapter_old_vm ( ) {
168+ let mut protocol_config = ProtocolConfig :: get_for_max_version_UNSAFE ( ) ;
169+
170+ // Enable Adapter v2 (old vm + new adapter)
171+ protocol_config. set_enable_adapter_v2_for_testing ( true ) ;
172+
173+ let executor_result = crate :: executor ( & protocol_config, true ) ;
174+
175+ assert ! (
176+ executor_result. is_ok( ) ,
177+ "Executor should be created successfully with VM v2 enabled"
178+ ) ;
179+
180+ assert ! ( protocol_config. get_use_adapter_v2( ) ) ;
181+ assert ! ( !protocol_config. get_use_vm_v2( ) ) ;
182+ }
183+ #[ test]
184+ fn test_executor_with_new_adapter_new_vm ( ) {
185+ let mut protocol_config = ProtocolConfig :: get_for_max_version_UNSAFE ( ) ;
186+
187+ // Enable Adapter v2 (new vm + new adapter)
188+ protocol_config. set_enable_adapter_v2_for_testing ( true ) ;
189+ protocol_config. set_enable_vm_v2_for_testing ( true ) ;
190+
191+ let executor_result = crate :: executor ( & protocol_config, true ) ;
192+
193+ assert ! (
194+ executor_result. is_ok( ) ,
195+ "Executor should be created successfully with VM v2 enabled"
196+ ) ;
197+
198+ assert ! ( protocol_config. get_use_adapter_v2( ) ) ;
199+ assert ! ( protocol_config. get_use_vm_v2( ) ) ;
200+ }
201+ }
0 commit comments