fix: don't panic on invalid hex strings

This commit is contained in:
rvcas
2023-11-15 14:39:51 -05:00
committed by Lucas
parent dfa0378404
commit 308fb47e40
2 changed files with 16 additions and 6 deletions

View File

@@ -16,8 +16,10 @@ const EVALUATION_FAILURE: &str = "evaluation failure";
fn expected_to_program(expected_file: &PathBuf) -> Result<Program<Name>, String> {
let code = fs::read_to_string(expected_file).expect("Failed to read .uplc.expected file");
if code == PARSE_ERROR || code == EVALUATION_FAILURE {
Err(code)
if code.contains(PARSE_ERROR) {
Err(PARSE_ERROR.to_string())
} else if code.contains(EVALUATION_FAILURE) {
Err(EVALUATION_FAILURE.to_string())
} else {
parser::program(&code).map_err(|_| code)
}