From d276b332540dcbc96fbe1eb8d04d5fd266017cdd Mon Sep 17 00:00:00 2001 From: Ignacio Amigo Date: Tue, 17 Sep 2024 17:31:36 -0300 Subject: [PATCH] fix: Pass kernel root to mocked block --- Cargo.lock | 4 ++-- objects/src/block/header.rs | 9 ++++++++- objects/src/testing/block.rs | 36 +++++------------------------------- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b503f7d1..8a7a00064 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1730,9 +1730,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ "indexmap", "serde", diff --git a/objects/src/block/header.rs b/objects/src/block/header.rs index 41236fcf5..058cf93ec 100644 --- a/objects/src/block/header.rs +++ b/objects/src/block/header.rs @@ -265,7 +265,14 @@ mod tests { fn test_serde() { let chain_root: Word = rand_array(); let note_root: Word = rand_array(); - let header = BlockHeader::mock(0, Some(chain_root.into()), Some(note_root.into()), &[]); + let kernel_root: Word = rand_array(); + let header = BlockHeader::mock( + 0, + Some(chain_root.into()), + Some(note_root.into()), + &[], + kernel_root.into(), + ); let serialized = header.to_bytes(); let deserialized = BlockHeader::read_from_bytes(&serialized).unwrap(); diff --git a/objects/src/testing/block.rs b/objects/src/testing/block.rs index f8133ccf5..b54bcbe0e 100644 --- a/objects/src/testing/block.rs +++ b/objects/src/testing/block.rs @@ -20,6 +20,7 @@ impl BlockHeader { chain_root: Option, note_root: Option, accounts: &[Account], + kernel_root: Digest, ) -> Self { let acct_db = SimpleSmt::::with_leaves( accounts @@ -38,48 +39,21 @@ impl BlockHeader { let account_root = acct_db.root(); #[cfg(not(target_family = "wasm"))] - let ( - prev_hash, - chain_root, - nullifier_root, - note_root, - tx_hash, - kernel_root, - proof_hash, - timestamp, - ) = { + let (prev_hash, chain_root, nullifier_root, note_root, tx_hash, proof_hash, timestamp) = { let prev_hash = rand_array::().into(); let chain_root = chain_root.unwrap_or(rand_array::().into()); let nullifier_root = rand_array::().into(); let note_root = note_root.unwrap_or(rand_array::().into()); let tx_hash = rand_array::().into(); - let kernel_root = rand_array::().into(); let proof_hash = rand_array::().into(); let timestamp = rand_value(); - ( - prev_hash, - chain_root, - nullifier_root, - note_root, - tx_hash, - kernel_root, - proof_hash, - timestamp, - ) + (prev_hash, chain_root, nullifier_root, note_root, tx_hash, proof_hash, timestamp) }; #[cfg(target_family = "wasm")] - let ( - prev_hash, - chain_root, - nullifier_root, - note_root, - tx_hash, - kernel_root, - proof_hash, - timestamp, - ) = Default::default(); + let (prev_hash, chain_root, nullifier_root, note_root, tx_hash, proof_hash, timestamp) = + Default::default(); BlockHeader::new( 0,