2022-10-13 12:50:32 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2022 Fluence Labs Limited
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2023-08-03 21:58:42 +03:00
|
|
|
use air::min_supported_version;
|
2023-08-03 22:45:21 +03:00
|
|
|
use air::PreparationError;
|
2022-10-13 12:50:32 +03:00
|
|
|
use air_interpreter_interface::INTERPRETER_SUCCESS;
|
|
|
|
use air_test_utils::prelude::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn minimal_version_check() {
|
|
|
|
let mut vm = create_avm(echo_call_service(), "");
|
2023-02-07 21:07:02 +03:00
|
|
|
let script = "(null)";
|
2022-10-13 12:50:32 +03:00
|
|
|
|
|
|
|
let actual_version = semver::Version::new(0, 31, 1);
|
|
|
|
let current_data = InterpreterData::new(actual_version.clone());
|
2023-12-15 18:23:09 +04:00
|
|
|
let current_data = current_data.serialize().expect("default serializer shouldn't fail");
|
2023-02-07 21:07:02 +03:00
|
|
|
let result = call_vm!(vm, <_>::default(), script, "", current_data);
|
2022-10-13 12:50:32 +03:00
|
|
|
|
|
|
|
let expected_error = PreparationError::UnsupportedInterpreterVersion {
|
|
|
|
actual_version,
|
2023-08-03 21:58:42 +03:00
|
|
|
required_version: min_supported_version().clone(),
|
2022-10-13 12:50:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
assert!(check_error(&result, expected_error));
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn publish_version_check() {
|
|
|
|
let mut vm = create_avm(echo_call_service(), "");
|
|
|
|
let script = "(null)";
|
|
|
|
|
|
|
|
let actual_version =
|
2023-08-03 22:28:56 +03:00
|
|
|
semver::Version::parse("1.0.1-feat-VM-173-add-interpreter-version-in-data-a2d575b-205-1.0").unwrap();
|
2022-12-12 22:37:05 +07:00
|
|
|
let current_data = InterpreterData::new(actual_version);
|
2023-12-15 18:23:09 +04:00
|
|
|
let current_data = current_data.serialize().expect("default serializer shouldn't fail");
|
2022-10-13 12:50:32 +03:00
|
|
|
let result = call_vm!(vm, <_>::default(), script, "", current_data);
|
|
|
|
|
2023-06-23 00:45:40 +03:00
|
|
|
assert_eq!(result.ret_code, INTERPRETER_SUCCESS, "{:?}", result.error_message);
|
2022-10-13 12:50:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn publish_unsupported_version_check() {
|
|
|
|
let mut vm = create_avm(echo_call_service(), "");
|
|
|
|
|
|
|
|
let actual_version =
|
|
|
|
semver::Version::parse("0.31.1-feat-VM-173-add-interpreter-version-in-data-a2d575b-205-1.0").unwrap();
|
|
|
|
let current_data = InterpreterData::new(actual_version.clone());
|
2023-12-15 18:23:09 +04:00
|
|
|
let current_data = current_data.serialize().expect("default serializer shouldn't fail");
|
2022-10-13 12:50:32 +03:00
|
|
|
let result = call_vm!(vm, <_>::default(), "", "", current_data);
|
|
|
|
|
|
|
|
let expected_error = PreparationError::UnsupportedInterpreterVersion {
|
|
|
|
actual_version,
|
2023-08-03 21:58:42 +03:00
|
|
|
required_version: min_supported_version().clone(),
|
2022-10-13 12:50:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
assert!(check_error(&result, expected_error));
|
|
|
|
}
|