(hex_in: &str, use_add_table: bool, use_full_xor: bool)
| 777 | } |
| 778 | } |
| 779 | fn test_sha256(hex_in: &str, use_add_table: bool, use_full_xor: bool) { |
| 780 | let mut hasher = Sha256::new(); |
| 781 | let data = Vec::<u8>::from_hex(hex_in).unwrap(); |
| 782 | hasher.update(&data); |
| 783 | let result = hasher.finalize(); |
| 784 | let res = result.to_lower_hex_string(); |
| 785 | println!("Result: {}", res); |
| 786 | |
| 787 | let mut stack = StackTracker::new(); |
| 788 | stack.custom( |
| 789 | script! { |
| 790 | {u4_hex_to_nibbles(hex_in)} |
| 791 | }, |
| 792 | 0, |
| 793 | false, |
| 794 | 0, |
| 795 | "message", |
| 796 | ); |
| 797 | // stack.custom(y, 0, false, 0, "message"); |
| 798 | let s = sha256_stack( |
| 799 | &mut stack, |
| 800 | hex_in.len() as u32 / 2, |
| 801 | use_add_table, |
| 802 | use_full_xor, |
| 803 | ); |
| 804 | println!("script len{}", s.len()); |
| 805 | |
| 806 | stack.to_altstack_count(64); |
| 807 | let mut expected = stack.var(64, u4_hex_to_nibbles(res.as_str()), "expected"); |
| 808 | let mut result = stack.from_altstack_joined(64, "res"); |
| 809 | stack.debug(); |
| 810 | stack.op_true(); |
| 811 | stack.equals(&mut result, true, &mut expected, true); |
| 812 | let res = stack.run(); |
| 813 | assert!(res.success); |
| 814 | let s = stack.get_script(); |
| 815 | println!("{}", s.len()); |
| 816 | let res = execute_script(StructuredScript::new("").push_script(s.compile())); |
| 817 | assert!(res.success); |
| 818 | } |
| 819 | #[test] |
| 820 | fn foostack80() { |
| 821 | test_sha256("b2222696d574e2c595e60b97b5fd30fe5efb9535de84214ad9dac92fb9a82f477cb5ffa4cefe9f749c4c5dd6190cfd197c30d1351a9db171a05883bf3f207a1045654654457567547547456775647654", true, true); |
no test coverage detected