fix: casting a field type to Data with expect and traces on was assuming the raw Data was of type constr

This commit is contained in:
microproofs
2024-03-27 15:52:23 -04:00
parent 075668b52e
commit a5a0734629
2 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
pub type PublicKeyHash =
ByteArray
pub type ByteArrayDataPair {
key: ByteArray,
value: Data,
}
pub type ReferenceDatum {
data: List<ByteArrayDataPair>,
controller: PublicKeyHash,
}
pub fn find_data(datas: List<ByteArrayDataPair>, key: ByteArray) -> Data {
when datas is {
[] -> fail @"Data Structure Not Found"
[d, ..ds] ->
if d.key == key {
d.value
} else {
find_data(ds, key)
}
}
}
test thing() {
let stuff: Data =
ReferenceDatum([ByteArrayDataPair("key", "value")], "controller")
expect other: ReferenceDatum = stuff
other == other
}