Przeglądaj źródła

zk/smt: fix broken unit test

zero 2 lat temu
rodzic
commit
fb4a521f70
2 zmienionych plików z 4 dodań i 8 usunięć
  1. 2 4
      src/zk/gadget/smt.rs
  2. 2 4
      tests/smt.rs

+ 2 - 4
src/zk/gadget/smt.rs

@@ -224,7 +224,7 @@ impl PathChip {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use darkfi_sdk::crypto::smt::{MemoryStorageFp, PoseidonFp, SmtMemoryFp};
+    use darkfi_sdk::crypto::smt::{MemoryStorageFp, PoseidonFp, SmtMemoryFp, EMPTY_NODES_FP};
     use halo2_proofs::{circuit::floor_planner, dev::MockProver, plonk::Circuit};
     use rand::rngs::OsRng;
 
@@ -329,10 +329,8 @@ mod tests {
     #[test]
     fn test_smt_circuit() {
         let hasher = PoseidonFp::new();
-        let empty_leaf = Fp::ZERO;
-
         let store = MemoryStorageFp::new();
-        let mut smt = SmtMemoryFp::new(store, hasher.clone(), empty_leaf.clone());
+        let mut smt = SmtMemoryFp::new(store, hasher.clone(), &EMPTY_NODES_FP);
 
         let leaves = vec![Fp::random(&mut OsRng), Fp::random(&mut OsRng), Fp::random(&mut OsRng)];
         // Use the leaf value as its position in the SMT

+ 2 - 4
tests/smt.rs

@@ -16,7 +16,7 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
-use darkfi_sdk::crypto::smt::{MemoryStorageFp, PoseidonFp, SmtMemoryFp};
+use darkfi_sdk::crypto::smt::{MemoryStorageFp, PoseidonFp, SmtMemoryFp, EMPTY_NODES_FP};
 use halo2_proofs::{arithmetic::Field, circuit::Value, dev::MockProver, pasta::Fp};
 use rand::rngs::OsRng;
 
@@ -37,10 +37,8 @@ fn zkvm_smt() -> Result<()> {
     let zkbin = ZkBinary::decode(bincode)?;
 
     let hasher = PoseidonFp::new();
-    let empty_leaf = Fp::from(0);
-
     let store = MemoryStorageFp::new();
-    let mut smt = SmtMemoryFp::new(store, hasher.clone(), empty_leaf.clone());
+    let mut smt = SmtMemoryFp::new(store, hasher.clone(), &EMPTY_NODES_FP);
 
     let leaves = vec![Fp::random(&mut OsRng), Fp::random(&mut OsRng), Fp::random(&mut OsRng)];
     // Use the leaf value as its position in the SMT