From cd66980f8c072eeb38e6c64e59389d920d6a3b96 Mon Sep 17 00:00:00 2001 From: Zekun Wang <41706692+fEst1ck@users.noreply.github.com> Date: Fri, 1 Nov 2024 01:32:54 -0400 Subject: [PATCH] [Framework] Gate V2 Features in Framework until V2 Features Allowed on Mainnet (#15146) * add tests to gate v2 features in framework * remove change in framework code * linter --------- Co-authored-by: Zekun Wang --- .../framework/tests/gate_v2_features.rs | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 aptos-move/framework/tests/gate_v2_features.rs diff --git a/aptos-move/framework/tests/gate_v2_features.rs b/aptos-move/framework/tests/gate_v2_features.rs new file mode 100644 index 0000000000000..76b44089795ac --- /dev/null +++ b/aptos-move/framework/tests/gate_v2_features.rs @@ -0,0 +1,53 @@ +// Copyright © Aptos Foundation +// SPDX-License-Identifier: Apache-2.0 + +//! This file contains tests for compiling framework code with the v1 compiler, to make sure no V2 feature is used before it's ready for mainnet. + +use aptos_framework::{extended_checks, path_in_crate}; +use move_model::metadata::{CompilerVersion, LanguageVersion}; +use move_package::CompilerConfig; +use tempfile::tempdir; + +fn compile_pkg_with_v1(path_to_pkg: impl Into) { + let pkg_path = path_in_crate(path_to_pkg); + let compiler_config = CompilerConfig { + known_attributes: extended_checks::get_all_attribute_names().clone(), + bytecode_version: Some(6), + language_version: Some(LanguageVersion::V1), + compiler_version: Some(CompilerVersion::V1), + ..Default::default() + }; + let build_config = move_package::BuildConfig { + install_dir: Some(tempdir().unwrap().path().to_path_buf()), + compiler_config: compiler_config.clone(), + ..Default::default() + }; + build_config + .compile_package(pkg_path.as_path(), &mut std::io::stdout()) + .unwrap(); +} + +#[test] +fn compile_aptos_framework_with_v1() { + compile_pkg_with_v1("aptos-framework"); +} + +#[test] +fn compile_aptos_stdlib_with_v1() { + compile_pkg_with_v1("aptos-stdlib"); +} + +#[test] +fn compile_move_stdlib_with_v1() { + compile_pkg_with_v1("move-stdlib"); +} + +#[test] +fn compile_aptos_token_with_v1() { + compile_pkg_with_v1("aptos-token"); +} + +#[test] +fn compile_aptos_token_objects_with_v1() { + compile_pkg_with_v1("aptos-token-objects"); +}