Skip to content

Commit be172e5

Browse files
committed
tests
1 parent 71ff300 commit be172e5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

rust/src/plutus.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,4 +1644,15 @@ mod tests {
16441644
);
16451645
assert_eq!(hex::encode(hash.to_bytes()), "357041b88b914670a3b5e3b0861d47f2ac05ed4935ea73886434d8944aa6dfe0");
16461646
}
1647+
1648+
#[test]
1649+
fn test_same_datum_in_different_formats_with_expected_hashes() {
1650+
// This is a known datum with indefinite arrays and a known expected hash
1651+
let pdata1 = PlutusData::from_bytes(hex::decode("d8799fd8799f581ca183bf86925f66c579a3745c9517744399679b090927b8f6e2f2e1bb4f616461706541696c656e416d61746fffd8799f581c9a4e855293a0b9af5e50935a331d83e7982ab5b738ea0e6fc0f9e6564e4652414d455f36353030335f4c30ff581cbea1c521df58f4eeef60c647e5ebd88c6039915409f9fd6454a476b9ff").unwrap()).unwrap();
1652+
assert_eq!(hex::encode(hash_plutus_data(&pdata1).to_bytes()), "ec3028f46325b983a470893a8bdc1b4a100695b635fb1237d301c3490b23e89b");
1653+
// This is the same exact datum manually converted to definite arrays
1654+
// and it produces a different known expected hash because the format is preserved after deserialization
1655+
let pdata2 = PlutusData::from_bytes(hex::decode("d87983d87982581ca183bf86925f66c579a3745c9517744399679b090927b8f6e2f2e1bb4f616461706541696c656e416d61746fd87982581c9a4e855293a0b9af5e50935a331d83e7982ab5b738ea0e6fc0f9e6564e4652414d455f36353030335f4c30581cbea1c521df58f4eeef60c647e5ebd88c6039915409f9fd6454a476b9").unwrap()).unwrap();
1656+
assert_eq!(hex::encode(hash_plutus_data(&pdata2).to_bytes()), "816cdf6d4d8cba3ad0188ca643db95ddf0e03cdfc0e75a9550a72a82cb146222");
1657+
}
16471658
}

0 commit comments

Comments
 (0)