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

Function test_copy_zip

bitvm/src/bigint/std.rs:854–945  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

852
853 #[test]
854 fn test_copy_zip() {
855 const N_U30_LIMBS: u32 = 9;
856
857 let mut prng = ChaCha20Rng::seed_from_u64(0);
858
859 for _ in 0..50 {
860 let mut v = vec![];
861 for _ in 0..N_U30_LIMBS {
862 v.push(prng.gen::<i32>());
863 }
864 for _ in 0..N_U30_LIMBS {
865 v.push(prng.gen::<i32>());
866 }
867
868 let mut expected = vec![];
869 for i in 0..N_U30_LIMBS {
870 expected.push(v[i as usize]);
871 expected.push(v[(N_U30_LIMBS + i) as usize]);
872 }
873
874 let script = script! {
875 for i in 0..N_U30_LIMBS * 2 {
876 { v[i as usize] }
877 }
878 { U254::copy_zip(1, 0) }
879 for i in 0..N_U30_LIMBS * 2 {
880 { expected[(N_U30_LIMBS * 2 - 1 - i) as usize] }
881 OP_EQUALVERIFY
882 }
883 { U254::drop() }
884 { U254::drop() }
885 OP_TRUE
886 };
887 run(script);
888
889 let mut expected = vec![];
890 for i in 0..N_U30_LIMBS {
891 expected.push(v[(N_U30_LIMBS + i) as usize]);
892 expected.push(v[i as usize]);
893 }
894
895 let script = script! {
896 for i in 0..N_U30_LIMBS * 2 {
897 { v[i as usize] }
898 }
899 { U254::copy_zip(0, 1) }
900 for i in 0..N_U30_LIMBS * 2 {
901 { expected[(N_U30_LIMBS * 2 - 1 - i) as usize] }
902 OP_EQUALVERIFY
903 }
904 { U254::drop() }
905 { U254::drop() }
906 OP_TRUE
907 };
908 run(script);
909
910 let mut expected = vec![];
911 for i in 0..N_U30_LIMBS {

Callers

nothing calls this directly

Calls 2

runFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected