MCPcopy Create free account
hub / github.com/BitVM/BitVM / test_double

Function test_double

bitvm/src/bigint/add.rs:607–637  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

605
606 #[test]
607 fn test_double() {
608 println!("U254.double: {} bytes", U254::double(0).len());
609 let mut prng = ChaCha20Rng::seed_from_u64(0);
610 for _ in 0..100 {
611 let a: BigUint = prng.sample(RandomBits::new(254));
612 let c: BigUint = (a.clone() + a.clone()).rem(BigUint::one().shl(254));
613
614 let script = script! {
615 { U254::push_u32_le(&a.to_u32_digits()) }
616 { U254::double(0) }
617 { U254::push_u32_le(&c.to_u32_digits()) }
618 { U254::equalverify(1, 0) }
619 OP_TRUE
620 };
621 run(script);
622 }
623
624 for _ in 0..100 {
625 let a: u64 = prng.gen();
626 let c = a.wrapping_add(a);
627
628 let script = script! {
629 { U64::push_u64_le(&[a]) }
630 { U64::double(0) }
631 { U64::push_u64_le(&[c]) }
632 { U64::equalverify(1, 0) }
633 OP_TRUE
634 };
635 run(script);
636 }
637 }
638}

Callers

nothing calls this directly

Calls 2

runFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected