clvk-utils 0.51.0
Rust test marker or harnessimports hex::ToHex
SHA-256a4ddad67e2d3d926b8c7f18fbdb37f73e2ea33fabf1f54140177044c75a2c709
MaleculeMd₂(In₃Pa)
Evidence
41:53… Result<TreeHash, ToClvkError> {
42 Ok(*self)
43 }
44}
45
46#[cfg(test)]
47mod tests {
48 use super::*;
49
50 use clvk_traits::ToClvk;
51
52 use crate::{CurriedProgram, curry_tree_hash};
53
54 #[test]
55 fn test_tree_hash() {
56 assert_eq!(
⋯14 lines
71 );
72
73 // This is the default hidden puzzle for the standard transaction.
74 // Its tree hash is known, and its CLVK is `(=)`.
75 assert_eq!(
76 hex::encode([9].tree_hash()),
⋯7 lines
1use crate::{TreeHash, tree_hash_atom, tree_hash_pair};
2
3pub fn curry_tree_hash(program_hash: TreeHash, arg_hashes: &[TreeHash]) -> TreeHash {
⋯6 lines
10 let mut quoted_args = tree_hash_atom(&[1]);
11
12 for &arg_hash in arg_hashes.iter().rev() {
13 let quoted_arg = tree_hash_pair(op_q, arg_hash);
14 let terminated_args = tree_hash_pair(quoted_args, nil);
⋯7 lines
22}
23
24#[cfg(test)]
25mod tests {
26 use clvk_traits::{ToClvk, clvk_curried_args};
27 use clvkr::Allocator;
28 use hex::ToHex;
29
30 use crate::{CurriedProgram, tree_hash};
31
32 use super::*;
33
34 #[test]
35 fn test_equivalence() {
36 let mut a = Allocator::new();
⋯5 lines
42 let curried = CurriedProgram { program, args }.to_clvk(&mut a).unwrap();
43
44 let tree_hash_result = tree_hash(&a, curried);
45
46 let program_hash = tree_hash(&a, program);
47 let arg_1_hash = tree_hash(&a, arg_1);
48 let arg_2_hash = tree_hash(&a, arg_2);
30:25… vk_quote!(&self.program), &self.args).to_clvk(encoder)
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use std::fmt::Debug;
37
38 use clvk_traits::clvk_curried_args;
39 use clvkr::{Allocator, serde::node_to_bytes};
40
41 use super::*;
42
43 fn check<P, A>(program: &P, args: &A, expected: &str)
44 where
45 P: Debug + Partia …
60:32… gram, program);
61 assert_eq!(&curried.args, args);
62 }
63
64 #[test]
65 fn curry() {
66 check(
67 &"xyz".to_string(),
68 &clvk_curried_args!("a".to_string(), "b".to_string( …
1use chik_sha2::Sha256;
2use clvkr::allocator::{Allocator, NodePtr, NodeVisitor, ObjectType, SExp};
3use clvkr::error::EvalErr;
4use clvkr::serde::node_from_bytes_backrefs;
5use hex_literal::hex;
6use std::fmt;
7use std::ops::Deref;
8
9#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10pub struct TreeHash([u8; 32]);
11
No evidence locations were recorded for this file. Raw result