Skip to content

Commit 970bc33

Browse files
committed
Add tests for adapter+vm protocol configs
1 parent 00828a9 commit 970bc33

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

crates/sui-protocol-config/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4548,6 +4548,14 @@ impl ProtocolConfig {
45484548
self.feature_flags.correct_gas_payment_limit_check = val;
45494549
}
45504550

4551+
pub fn set_enable_vm_v2_for_testing(&mut self, val: bool) {
4552+
self.feature_flags.enable_vm_v2 = val;
4553+
}
4554+
4555+
pub fn set_enable_adapter_v2_for_testing(&mut self, val: bool) {
4556+
self.feature_flags.enable_adapter_v2 = val;
4557+
}
4558+
45514559
pub fn set_consensus_round_prober_probe_accepted_rounds(&mut self, val: bool) {
45524560
self.feature_flags
45534561
.consensus_round_prober_probe_accepted_rounds = val;

sui-execution/src/tests.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)