#[cfg(all(target_arch = "wasm32", feature = "js"))]
use wasm_bindgen::prelude::*;
use crate::cel;
pub type ResponseVerificationResult<T = ()> = Result<T, ResponseVerificationError>;
#[derive(thiserror::Error, Debug)]
pub enum ResponseVerificationError {
    #[error(r#"Failed to parse url: "{0}""#)]
    MalformedUrl(String),
    #[error(r#"Failed to parse hash tree: "{0}""#)]
    MalformedHashTree(String),
    #[error(r#"Failed to parse certificate: "{0}""#)]
    MalformedCertificate(String),
    #[error(r#"Certificate is missing the "time" path"#)]
    MissingTimePathInTree,
    #[error(r#"IO error: "{0}""#)]
    IoError(#[from] std::io::Error),
    #[error("Certificate time is too far in the future. Received {certificate_time:?}, expected {max_certificate_time:?} or earlier")]
    CertificateTimeTooFarInTheFuture {
        certificate_time: u128,
        max_certificate_time: u128,
    },
    #[error("Certificate time is too far in the past. Received {certificate_time:?}, expected {min_certificate_time:?} or later")]
    CertificateTimeTooFarInThePast {
        certificate_time: u128,
        min_certificate_time: u128,
    },
    #[error(r#"Invalid cbor: "{0}""#)]
    MalformedCbor(String),
    #[error(r#"Expected node with name {node_name:?} to have type {expected_type:?}, found {found_type:?}"#)]
    UnexpectedCborNodeType {
        node_name: String,
        expected_type: String,
        found_type: String,
    },
    #[error(r#"Invalid pruned data: "{0}""#)]
    IncorrectPrunedDataLength(#[from] std::array::TryFromSliceError),
    #[error("Overflow while decoding leb")]
    LebDecodingOverflow,
    #[error(r#"Error converting UTF8 string bytes: "{0}""#)]
    Utf8ConversionError(#[from] std::string::FromUtf8Error),
    #[error(r#"The requested verification version {requested_version:?} is not supported, the current supported range is {min_supported_version:?}-{max_supported_version:?}"#)]
    UnsupportedVerificationVersion {
        min_supported_version: u8,
        max_supported_version: u8,
        requested_version: u8,
    },
    #[error(r#"The requested verification version {requested_version:?} is lower than the minimum requested version {min_requested_verification_version:?}"#)]
    RequestedVerificationVersionMismatch {
        min_requested_verification_version: u8,
        requested_version: u8,
    },
    #[error("Cel parser error")]
    CelError(#[from] cel::CelParserError),
    #[error(
        r#"BLS DER-encoded public key must be {expected} bytes long, but is {actual} bytes long"#
    )]
    DerKeyLengthMismatch {
        expected: usize,
        actual: usize,
    },
    #[error("BLS DER-encoded public key is invalid. Expected the following prefix: {expected:?}, but got {actual:?}")]
    DerPrefixMismatch {
        expected: Vec<u8>,
        actual: Vec<u8>,
    },
    #[error("Certificate verification failed")]
    CertificateVerificationFailed,
    #[error("Certificate verification failed with principal out of range")]
    CertificatePrincipalOutOfRange,
    #[error("Certificate verification subnet public key not found")]
    CertificateSubnetPublicKeyNotFound,
    #[error("Certificate verification subnet canister ranges not found")]
    CertificateSubnetCanisterRangesNotFound,
    #[error("Invalid cbor canister ranges")]
    MalformedCborCanisterRanges,
    #[error("Base64 decoding error")]
    Base64DecodingError(#[from] base64::DecodeError),
    #[error("Error parsing int")]
    ParseIntError(#[from] std::num::ParseIntError),
    #[error("Invalid tree root hash")]
    InvalidTree,
    #[error("Invalid expression path")]
    InvalidExpressionPath,
    #[error("Invalid response body")]
    InvalidResponseBody,
    #[error("Invalid response hashes")]
    InvalidResponseHashes,
    #[error("Certificate not found")]
    MissingCertificate,
    #[error("Tree not found")]
    MissingTree,
    #[error("Certificate expression path not found")]
    MissingCertificateExpressionPath,
    #[error("Certificate expression not found")]
    MissingCertificateExpression,
    #[error("Certification values not found")]
    MissingCertification,
}
#[cfg(all(target_arch = "wasm32", feature = "js"))]
#[wasm_bindgen(js_name = ResponseVerificationErrorCode)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum ResponseVerificationJsErrorCode {
    MalformedUrl,
    MalformedHashTree,
    MalformedCertificate,
    MissingTimePathInTree,
    IoError,
    CertificateTimeTooFarInTheFuture,
    CertificateTimeTooFarInThePast,
    MalformedCbor,
    UnexpectedCborNodeType,
    IncorrectPrunedDataLength,
    LebDecodingOverflow,
    Utf8ConversionError,
    UnsupportedVerificationVersion,
    RequestedVerificationVersionMismatch,
    CelError,
    DerKeyLengthMismatch,
    DerPrefixMismatch,
    CertificateVerificationFailed,
    CertificatePrincipalOutOfRange,
    CertificateSubnetPublicKeyNotFound,
    CertificateSubnetCanisterRangesNotFound,
    MalformedCborCanisterRanges,
    Base64DecodingError,
    ParseIntError,
    InvalidTree,
    InvalidExpressionPath,
    InvalidResponseBody,
    InvalidResponseHashes,
    MissingCertificate,
    MissingTree,
    MissingCertificateExpressionPath,
    MissingCertificateExpression,
    MissingCertification,
}
#[cfg(all(target_arch = "wasm32", feature = "js"))]
#[wasm_bindgen(inspectable, js_name = ResponseVerificationError)]
#[derive(Debug, Eq, PartialEq)]
pub struct ResponseVerificationJsError {
    #[wasm_bindgen(readonly)]
    pub code: ResponseVerificationJsErrorCode,
    #[wasm_bindgen(getter_with_clone, readonly)]
    pub message: String,
}
#[cfg(all(target_arch = "wasm32", feature = "js"))]
impl From<ResponseVerificationError> for ResponseVerificationJsError {
    fn from(error: ResponseVerificationError) -> ResponseVerificationJsError {
        let code = match error {
            ResponseVerificationError::MalformedUrl(_) => {
                ResponseVerificationJsErrorCode::MalformedUrl
            }
            ResponseVerificationError::MalformedHashTree(_) => {
                ResponseVerificationJsErrorCode::MalformedHashTree
            }
            ResponseVerificationError::MalformedCertificate(_) => {
                ResponseVerificationJsErrorCode::MalformedCertificate
            }
            ResponseVerificationError::MissingTimePathInTree => {
                ResponseVerificationJsErrorCode::MissingTimePathInTree
            }
            ResponseVerificationError::IoError(_) => ResponseVerificationJsErrorCode::IoError,
            ResponseVerificationError::CertificateTimeTooFarInTheFuture { .. } => {
                ResponseVerificationJsErrorCode::CertificateTimeTooFarInTheFuture
            }
            ResponseVerificationError::CertificateTimeTooFarInThePast { .. } => {
                ResponseVerificationJsErrorCode::CertificateTimeTooFarInThePast
            }
            ResponseVerificationError::MalformedCbor(_) => {
                ResponseVerificationJsErrorCode::MalformedCbor
            }
            ResponseVerificationError::UnexpectedCborNodeType { .. } => {
                ResponseVerificationJsErrorCode::UnexpectedCborNodeType
            }
            ResponseVerificationError::IncorrectPrunedDataLength(_) => {
                ResponseVerificationJsErrorCode::IncorrectPrunedDataLength
            }
            ResponseVerificationError::LebDecodingOverflow { .. } => {
                ResponseVerificationJsErrorCode::LebDecodingOverflow
            }
            ResponseVerificationError::Utf8ConversionError { .. } => {
                ResponseVerificationJsErrorCode::Utf8ConversionError
            }
            ResponseVerificationError::UnsupportedVerificationVersion { .. } => {
                ResponseVerificationJsErrorCode::UnsupportedVerificationVersion
            }
            ResponseVerificationError::RequestedVerificationVersionMismatch { .. } => {
                ResponseVerificationJsErrorCode::RequestedVerificationVersionMismatch
            }
            ResponseVerificationError::DerPrefixMismatch { .. } => {
                ResponseVerificationJsErrorCode::DerPrefixMismatch
            }
            ResponseVerificationError::DerKeyLengthMismatch { .. } => {
                ResponseVerificationJsErrorCode::DerKeyLengthMismatch
            }
            ResponseVerificationError::CertificateVerificationFailed { .. } => {
                ResponseVerificationJsErrorCode::CertificateVerificationFailed
            }
            ResponseVerificationError::CertificatePrincipalOutOfRange { .. } => {
                ResponseVerificationJsErrorCode::CertificatePrincipalOutOfRange
            }
            ResponseVerificationError::CertificateSubnetPublicKeyNotFound { .. } => {
                ResponseVerificationJsErrorCode::CertificateSubnetPublicKeyNotFound
            }
            ResponseVerificationError::CertificateSubnetCanisterRangesNotFound { .. } => {
                ResponseVerificationJsErrorCode::CertificateSubnetCanisterRangesNotFound
            }
            ResponseVerificationError::MalformedCborCanisterRanges { .. } => {
                ResponseVerificationJsErrorCode::MalformedCborCanisterRanges
            }
            ResponseVerificationError::CelError(_) => ResponseVerificationJsErrorCode::CelError,
            ResponseVerificationError::Base64DecodingError(_) => {
                ResponseVerificationJsErrorCode::Base64DecodingError
            }
            ResponseVerificationError::ParseIntError(_) => {
                ResponseVerificationJsErrorCode::ParseIntError
            }
            ResponseVerificationError::InvalidTree => ResponseVerificationJsErrorCode::InvalidTree,
            ResponseVerificationError::InvalidExpressionPath => {
                ResponseVerificationJsErrorCode::InvalidExpressionPath
            }
            ResponseVerificationError::InvalidResponseBody => {
                ResponseVerificationJsErrorCode::InvalidResponseBody
            }
            ResponseVerificationError::InvalidResponseHashes => {
                ResponseVerificationJsErrorCode::InvalidResponseHashes
            }
            ResponseVerificationError::MissingCertificate => {
                ResponseVerificationJsErrorCode::MissingCertificate
            }
            ResponseVerificationError::MissingTree => ResponseVerificationJsErrorCode::MissingTree,
            ResponseVerificationError::MissingCertificateExpressionPath => {
                ResponseVerificationJsErrorCode::MissingCertificateExpressionPath
            }
            ResponseVerificationError::MissingCertificateExpression => {
                ResponseVerificationJsErrorCode::MissingCertificateExpression
            }
            ResponseVerificationError::MissingCertification => {
                ResponseVerificationJsErrorCode::MissingCertification
            }
        };
        let message = error.to_string();
        ResponseVerificationJsError {
            code: code.into(),
            message,
        }
    }
}
#[cfg(all(target_arch = "wasm32", feature = "js", test))]
mod tests {
    use super::*;
    use crate::{cel::CelParserError, test_utils::test_utils::hex_decode};
    use std::array::TryFromSliceError;
    use wasm_bindgen_test::wasm_bindgen_test;
    #[wasm_bindgen_test]
    fn error_into_invalid_url() {
        let error = ResponseVerificationError::MalformedUrl("https://internetcomputer.org".into());
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MalformedUrl,
                message: r#"Failed to parse url: "https://internetcomputer.org""#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_hash_tree() {
        let error = ResponseVerificationError::MalformedHashTree(
            "Missing ByteString for Pruned node".into(),
        );
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MalformedHashTree,
                message: r#"Failed to parse hash tree: "Missing ByteString for Pruned node""#
                    .into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_certificate() {
        let error = ResponseVerificationError::MalformedCertificate(
            "Expected Tree when parsing Certificate Cbor".into(),
        );
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MalformedCertificate,
                message:
                    r#"Failed to parse certificate: "Expected Tree when parsing Certificate Cbor""#
                        .into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_missing_time_path_in_tree() {
        let error = ResponseVerificationError::MissingTimePathInTree;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MissingTimePathInTree,
                message: r#"Certificate is missing the "time" path"#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_io_error() {
        let inner_error = std::fs::File::open("foo.txt").expect_err("Expected error");
        let error_msg = inner_error.to_string();
        let error = ResponseVerificationError::IoError(inner_error);
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::IoError,
                message: format!(r#"IO error: "{}""#, error_msg),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_certificate_time_too_far_in_the_future() {
        let error = ResponseVerificationError::CertificateTimeTooFarInTheFuture {
            certificate_time: 1000,
            max_certificate_time: 500,
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CertificateTimeTooFarInTheFuture,
                message: "Certificate time is too far in the future. Received 1000, expected 500 or earlier".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_certificate_time_too_far_in_the_past() {
        let error = ResponseVerificationError::CertificateTimeTooFarInThePast {
            certificate_time: 500,
            min_certificate_time: 1000,
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CertificateTimeTooFarInThePast,
                message:
                    "Certificate time is too far in the past. Received 500, expected 1000 or later"
                        .into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_malformed_cbor() {
        let error = ResponseVerificationError::MalformedCbor("Unexpected EOF reached".into());
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MalformedCbor,
                message: r#"Invalid cbor: "Unexpected EOF reached""#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_unexpected_cbor_node_type() {
        let error = ResponseVerificationError::UnexpectedCborNodeType {
            node_name: "Foo".into(),
            found_type: "Bar".into(),
            expected_type: "Baz".into(),
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::UnexpectedCborNodeType,
                message: r#"Expected node with name "Foo" to have type "Baz", found "Bar""#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_incorrect_pruned_data_length() {
        let incorrectly_sized_data: &[u8] = &[0u8];
        let conversion_attempt: Result<[u8; 10], TryFromSliceError> =
            TryFrom::try_from(incorrectly_sized_data);
        let inner_error = conversion_attempt.expect_err("Expected error");
        let error = ResponseVerificationError::IncorrectPrunedDataLength(inner_error);
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::IncorrectPrunedDataLength,
                message: format!(r#"Invalid pruned data: "{}""#, inner_error.to_string()),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_leb_decoding_overflow() {
        let error = ResponseVerificationError::LebDecodingOverflow;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::LebDecodingOverflow,
                message: "Overflow while decoding leb".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_utf8_conversion_error() {
        let invalid_utf_bytes = hex_decode("fca1a1a1a1a1");
        let inner_error = String::from_utf8(invalid_utf_bytes).expect_err("Expected error");
        let error = ResponseVerificationError::Utf8ConversionError(inner_error.clone());
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::Utf8ConversionError,
                message: format!(
                    r#"Error converting UTF8 string bytes: "{0}""#,
                    inner_error.to_string()
                ),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_unsupported_verification_version() {
        let error = ResponseVerificationError::UnsupportedVerificationVersion {
            min_supported_version: 1,
            max_supported_version: 2,
            requested_version: 42,
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::UnsupportedVerificationVersion,
                message: r#"The requested verification version 42 is not supported, the current supported range is 1-2"#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_verification_version_mismatch() {
        let error = ResponseVerificationError::RequestedVerificationVersionMismatch {
            min_requested_verification_version: 2,
            requested_version: 1,
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::RequestedVerificationVersionMismatch,
                message: r#"The requested verification version 1 is lower than the minimum requested version 2"#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_cel_error() {
        let inner_error = CelParserError::CelSyntaxException(
            "Garbage is not allowed in the CEL expression!".into(),
        );
        let error = ResponseVerificationError::from(inner_error);
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CelError,
                message: r#"Cel parser error"#.into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_der_prefix_mismatch() {
        let error = ResponseVerificationError::DerPrefixMismatch {
            actual: vec![1, 2, 4],
            expected: vec![1, 2, 3],
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::DerPrefixMismatch,
                message: "BLS DER-encoded public key is invalid. Expected the following prefix: [1, 2, 3], but got [1, 2, 4]".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_der_key_length_mismatch() {
        let error = ResponseVerificationError::DerKeyLengthMismatch {
            actual: 10,
            expected: 11,
        };
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::DerKeyLengthMismatch,
                message: "BLS DER-encoded public key must be 11 bytes long, but is 10 bytes long"
                    .into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_certificate_verification_failed() {
        let error = ResponseVerificationError::CertificateVerificationFailed;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CertificateVerificationFailed,
                message: "Certificate verification failed".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_certificate_principal_out_of_range() {
        let error = ResponseVerificationError::CertificatePrincipalOutOfRange;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CertificatePrincipalOutOfRange,
                message: "Certificate verification failed with principal out of range".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_certificate_subnet_public_key_not_found() {
        let error = ResponseVerificationError::CertificateSubnetPublicKeyNotFound;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CertificateSubnetPublicKeyNotFound,
                message: "Certificate verification subnet public key not found".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_certificate_subnet_canister_ranges_not_found() {
        let error = ResponseVerificationError::CertificateSubnetCanisterRangesNotFound;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::CertificateSubnetCanisterRangesNotFound,
                message: "Certificate verification subnet canister ranges not found".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_malformed_cbor_canister_ranges() {
        let error = ResponseVerificationError::MalformedCborCanisterRanges;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MalformedCborCanisterRanges,
                message: "Invalid cbor canister ranges".into(),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_base64_decoding_error() {
        let invalid_base64 = hex_decode("fca1a1a1a1a1");
        let inner_error = base64::decode(invalid_base64).expect_err("Expected error");
        let error = ResponseVerificationError::Base64DecodingError(inner_error);
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::Base64DecodingError,
                message: format!(r#"Base64 decoding error"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_parse_int_error() {
        let invalid_int = "fortytwo";
        let inner_error = invalid_int.parse::<u8>().expect_err("Expected error");
        let error = ResponseVerificationError::ParseIntError(inner_error);
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::ParseIntError,
                message: format!(r#"Error parsing int"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_tree_error() {
        let error = ResponseVerificationError::InvalidTree;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::InvalidTree,
                message: format!(r#"Invalid tree root hash"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_expression_path_error() {
        let error = ResponseVerificationError::InvalidExpressionPath;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::InvalidExpressionPath,
                message: format!(r#"Invalid expression path"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_response_body_error() {
        let error = ResponseVerificationError::InvalidResponseBody;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::InvalidResponseBody,
                message: format!(r#"Invalid response body"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_response_hashes_error() {
        let error = ResponseVerificationError::InvalidResponseHashes;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::InvalidResponseHashes,
                message: format!(r#"Invalid response hashes"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_missing_certificate_error() {
        let error = ResponseVerificationError::MissingCertificate;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MissingCertificate,
                message: format!(r#"Certificate not found"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_missing_tree_error() {
        let error = ResponseVerificationError::MissingTree;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MissingTree,
                message: format!(r#"Tree not found"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_missing_certificate_expr_path_error() {
        let error = ResponseVerificationError::MissingCertificateExpressionPath;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MissingCertificateExpressionPath,
                message: format!(r#"Certificate expression path not found"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_missing_certificate_expr_error() {
        let error = ResponseVerificationError::MissingCertificateExpression;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MissingCertificateExpression,
                message: format!(r#"Certificate expression not found"#),
            }
        )
    }
    #[wasm_bindgen_test]
    fn error_into_invalid_missing_certification_error() {
        let error = ResponseVerificationError::MissingCertification;
        let result = ResponseVerificationJsError::from(error);
        assert_eq!(
            result,
            ResponseVerificationJsError {
                code: ResponseVerificationJsErrorCode::MissingCertification,
                message: format!(r#"Certification values not found"#),
            }
        )
    }
}