mirror of
https://github.com/fluencelabs/aquavm
synced 2024-12-04 15:20:16 +00:00
chore(execution-engine): unused ApResultNotCorrespondToInstr cleanup (#513)
Remove `UncatchableError::ApResultNotCorrespondToInstr` This transformation is valid only if `MergerApResult` has only two variants mentioned in previos version. Co-authored-by: Ivan Boldyrev <ivan@fluence.one>
This commit is contained in:
parent
d99272f9d3
commit
790d3c2119
@ -22,7 +22,6 @@ use crate::ToErrorCode;
|
||||
use air_interpreter_cid::CidCalculationError;
|
||||
use air_interpreter_data::TracePos;
|
||||
use air_interpreter_data::ValueRef;
|
||||
use air_trace_handler::merger::MergerApResult;
|
||||
use air_trace_handler::GenerationCompatificationError;
|
||||
use air_trace_handler::TraceHandlerError;
|
||||
|
||||
@ -62,11 +61,6 @@ pub enum UncatchableError {
|
||||
#[error("multiple iterable values found for iterable name '{0}'")]
|
||||
MultipleIterableValues(String),
|
||||
|
||||
/// Errors occurred when result from data doesn't match to an ap instruction, f.e. an ap
|
||||
/// could be applied to a stream, but result doesn't contain generation in a source position.
|
||||
#[error("ap result {0:?} doesn't match with corresponding instruction")]
|
||||
ApResultNotCorrespondToInstr(MergerApResult),
|
||||
|
||||
/// Errors occurred when result from data doesn't match to a call instruction, f.e. a call
|
||||
/// could be applied to a stream, but result doesn't contain generation in a source position.
|
||||
#[error("call result value {0:?} doesn't match with corresponding instruction")]
|
||||
|
@ -61,13 +61,13 @@ fn should_touch_trace(ap: &Ap<'_>) -> bool {
|
||||
}
|
||||
|
||||
fn to_merger_ap_result(instr: &Ap<'_>, trace_ctx: &mut TraceHandler) -> ExecutionResult<MergerApResult> {
|
||||
if !should_touch_trace(instr) {
|
||||
return Ok(MergerApResult::NotMet);
|
||||
match instr.result {
|
||||
ast::ApResult::Scalar(_) => Ok(MergerApResult::NotMet),
|
||||
ast::ApResult::Stream(_) => {
|
||||
let merger_ap_result = trace_to_exec_err!(trace_ctx.meet_ap_start(), instr)?;
|
||||
Ok(merger_ap_result)
|
||||
}
|
||||
}
|
||||
|
||||
let merger_ap_result = trace_to_exec_err!(trace_ctx.meet_ap_start(), instr)?;
|
||||
try_match_trace_to_instr(&merger_ap_result, instr)?;
|
||||
Ok(merger_ap_result)
|
||||
}
|
||||
|
||||
fn populate_context<'ctx>(
|
||||
|
@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use super::ExecutionResult;
|
||||
use crate::execution_step::execution_context::StreamValueDescriptor;
|
||||
use crate::execution_step::Generation;
|
||||
use crate::execution_step::ValueAggregate;
|
||||
@ -46,14 +45,3 @@ pub(super) fn generate_value_descriptor<'stream>(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn try_match_trace_to_instr(merger_ap_result: &MergerApResult, instr: &ast::Ap<'_>) -> ExecutionResult<()> {
|
||||
use crate::execution_step::UncatchableError::ApResultNotCorrespondToInstr;
|
||||
use ast::ApResult;
|
||||
|
||||
match (&instr.result, merger_ap_result) {
|
||||
(ApResult::Stream(_), MergerApResult::Met(_)) => Ok(()),
|
||||
(_, MergerApResult::NotMet) => Ok(()),
|
||||
_ => Err(ApResultNotCorrespondToInstr(merger_ap_result.clone()).into()),
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use air::UncatchableError::ValueForCidNotFound;
|
||||
use air_interpreter_cid::CID;
|
||||
use air_interpreter_data::{CidStore, CidTracker};
|
||||
use air_test_framework::AirScriptExecutor;
|
||||
@ -181,12 +182,8 @@ fn test_canon_value_not_found() {
|
||||
|
||||
let cur_data = raw_data_from_trace_with_canon(trace, CidTracker::<_>::new(), tetraplet_tracker, canon_tracker);
|
||||
let result = call_vm!(vm, <_>::default(), air_script, vec![], cur_data);
|
||||
|
||||
assert_eq!(result.ret_code, 20012);
|
||||
assert_eq!(
|
||||
result.error_message,
|
||||
format!("value for CID \"{missing_cid}\" not found")
|
||||
);
|
||||
let expected_error = ValueForCidNotFound("value", String::from(missing_cid));
|
||||
assert!(check_error(&result, expected_error));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -238,11 +235,8 @@ fn test_canon_root_tetraplet_not_found() {
|
||||
let cur_data = raw_data_from_trace_with_canon(trace, value_tracker, fake_tetraplet_tracker, canon_tracker);
|
||||
let result = call_vm!(vm, <_>::default(), air_script, vec![], cur_data);
|
||||
|
||||
assert_eq!(result.ret_code, 20012);
|
||||
assert_eq!(
|
||||
result.error_message,
|
||||
format!("tetraplet for CID \"{missing_cid}\" not found")
|
||||
);
|
||||
let expected_error = ValueForCidNotFound("tetraplet", String::from(missing_cid));
|
||||
assert!(check_error(&result, expected_error));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -293,11 +287,8 @@ fn test_canon_tetraplet_not_found() {
|
||||
let cur_data = raw_data_from_trace_with_canon(trace, value_tracker, fake_tetraplet_tracker, canon_tracker);
|
||||
let result = call_vm!(vm, <_>::default(), air_script, vec![], cur_data);
|
||||
|
||||
assert_eq!(result.ret_code, 20012);
|
||||
assert_eq!(
|
||||
result.error_message,
|
||||
format!("tetraplet for CID \"{missing_cid}\" not found"),
|
||||
);
|
||||
let expected_error = ValueForCidNotFound("tetraplet", String::from(missing_cid));
|
||||
assert!(check_error(&result, expected_error));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -343,9 +334,6 @@ fn test_canon_agg_not_found() {
|
||||
let cur_data = raw_data_from_trace_with_canon(trace, value_tracker, tetraplet_tracker, <_>::default());
|
||||
let result = call_vm!(vm, <_>::default(), air_script, vec![], cur_data);
|
||||
|
||||
assert_eq!(result.ret_code, 20012);
|
||||
assert_eq!(
|
||||
result.error_message,
|
||||
format!("canon aggregate for CID \"{missing_cid}\" not found")
|
||||
);
|
||||
let expected_error = ValueForCidNotFound("canon aggregate", String::from(missing_cid));
|
||||
assert!(check_error(&result, expected_error));
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
mod canon;
|
||||
|
||||
use air::UncatchableError::ValueForCidNotFound;
|
||||
use air_interpreter_data::CidTracker;
|
||||
use air_test_framework::AirScriptExecutor;
|
||||
use air_test_utils::prelude::*;
|
||||
@ -35,11 +36,9 @@ fn test_missing_cid() {
|
||||
|
||||
let cur_data = raw_data_from_trace(trace, tracker);
|
||||
let result = call_vm!(vm, <_>::default(), air_script, vec![], cur_data);
|
||||
assert_eq!(result.ret_code, 20012);
|
||||
assert_eq!(
|
||||
result.error_message,
|
||||
"value for CID \"bagaaieraondvznakk2hi3kfaixhnceatpykz7cikytniqo3lc7ogkgz2qbeq\" not found"
|
||||
);
|
||||
let missing_cid = String::from("bagaaieraondvznakk2hi3kfaixhnceatpykz7cikytniqo3lc7ogkgz2qbeq");
|
||||
let expected_error = ValueForCidNotFound("value", missing_cid);
|
||||
assert!(check_error(&result, expected_error));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user