(hex_in: &str)
| 507 | } |
| 508 | |
| 509 | fn test_sha256(hex_in: &str) { |
| 510 | let mut hasher = Sha256::new(); |
| 511 | let data = Vec::<u8>::from_hex(hex_in).unwrap(); |
| 512 | hasher.update(&data); |
| 513 | let result = hasher.finalize(); |
| 514 | let res = result.to_lower_hex_string(); |
| 515 | println!("Result: {}", res); |
| 516 | |
| 517 | let script = script! { |
| 518 | { u4_hex_to_nibbles(hex_in) } |
| 519 | { sha256(hex_in.len() as u32 / 2)} |
| 520 | |
| 521 | |
| 522 | { u4_hex_to_nibbles(res.as_str()) } |
| 523 | for _ in 0..64 { |
| 524 | OP_TOALTSTACK |
| 525 | } |
| 526 | |
| 527 | for i in 1..64 { |
| 528 | {i} |
| 529 | OP_ROLL |
| 530 | } |
| 531 | |
| 532 | for _ in 0..64 { |
| 533 | OP_FROMALTSTACK |
| 534 | OP_EQUALVERIFY |
| 535 | } |
| 536 | OP_TRUE |
| 537 | |
| 538 | }; |
| 539 | |
| 540 | let res = execute_script(script); |
| 541 | assert!(res.success); |
| 542 | } |
| 543 | |
| 544 | #[test] |
| 545 | fn test_sha256_strs() { |
no test coverage detected