Value.add Has Unexpected Behavior When Subtracting
logicalmechanism opened this issue · 0 comments
logicalmechanism commented
The value.add
function during subtraction returns incorrect results as shown in the example below.
Ubuntu 22.04.2 LTS
aiken v1.0.10-alpha 85d82e5
stdlib 1.2
test adding_values_together() {
let v =
value.from_lovelace(123)
|> value.add(#"acab", #"beef", 321)
|> value.add(#"acab", #"beef", -1 * 321)
v == value.from_lovelace(123)
}
This test fails when it should pass. The functionality should mirror the value.merge
function, removing assets from a value when they are zero. As of right now, it returns a value with just the policy id and an empty dictionary.
× adding_values_together failed
help: ┍━ left ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑
│ (con string "{_ h\'\': {_ h\'\': 123 }, h\'ACAB\': {} }") │
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┙
should be equal to
┍━ right ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑
│ (con string "{_ h\'\': {_ h\'\': 123 } }") │
┕━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┙