Explorar el Código

contract/dao: Fix tests

parazyd hace 3 años
padre
commit
42b3cfd8c7
Se han modificado 1 ficheros con 8 adiciones y 4 borrados
  1. 8 4
      src/contract/dao/src/wallet_cache.rs

+ 8 - 4
src/contract/dao/src/wallet_cache.rs

@@ -18,7 +18,8 @@
 
 use darkfi_sdk::{
     bridgetree,
-    crypto::{note::AeadEncryptedNote, MerkleNode, MerkleTree, SecretKey},
+    crypto::{note::AeadEncryptedNote, pasta_prelude::Field, MerkleNode, MerkleTree, SecretKey},
+    pasta::pallas,
 };
 
 use darkfi_money_contract::{client::MoneyNote, model::Coin};
@@ -33,19 +34,22 @@ pub struct WalletCache {
     // Normally this would be a HashMap, but SecretKey is not Hash-able
     // TODO: This can be HashableBase
     cache: Vec<(SecretKey, Vec<OwnCoin>)>,
-    /// The entire Merkle tree state
+    /// The entire Money Merkle tree state
     pub tree: MerkleTree,
 }
 
 impl Default for WalletCache {
     fn default() -> Self {
-        Self { cache: Vec::new(), tree: MerkleTree::new(100) }
+        Self::new()
     }
 }
 
 impl WalletCache {
     pub fn new() -> Self {
-        Self { cache: Vec::new(), tree: MerkleTree::new(100) }
+        let mut tree = MerkleTree::new(100);
+        tree.append(MerkleNode::from(pallas::Base::ZERO));
+        let _ = tree.mark().unwrap();
+        Self { cache: Vec::new(), tree }
     }
 
     /// Must be called at the start to begin tracking received coins for this secret.