From c45643bb016c7b12ec43a041bd4d8bd8c66bc3b1 Mon Sep 17 00:00:00 2001 From: Kasey White Date: Fri, 23 Sep 2022 04:09:28 -0400 Subject: [PATCH] empty bytestring should return 0 not 1 --- crates/uplc/src/machine.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/uplc/src/machine.rs b/crates/uplc/src/machine.rs index e03e12e1..f8a4fa87 100644 --- a/crates/uplc/src/machine.rs +++ b/crates/uplc/src/machine.rs @@ -457,7 +457,13 @@ impl Value { ((i.abs() as f64).log2().floor() as i64 / 64) + 1 } } - Constant::ByteString(b) => (((b.len() as i64 - 1) / 8) + 1), + Constant::ByteString(b) => { + if b.is_empty() { + 0 + } else { + ((b.len() as i64 - 1) / 8) + 1 + } + } Constant::String(s) => s.chars().count() as i64, Constant::Unit => 1, Constant::Bool(_) => 1,