Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
panleone committed Nov 7, 2024
1 parent a458049 commit 7b01631
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions src/transaction/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#![cfg(test)]

use crate::transaction::{create_transaction_internal, get_nullifier_from_note_internal};
use crate::transaction::{
create_transaction_internal, get_nullifier_from_note_internal, SpendableNote,
};
use pivx_primitives::merkle_tree::IncrementalWitness;

use super::handle_transaction;
use either::Either;
Expand Down Expand Up @@ -35,7 +38,7 @@ fn check_tx_decryption() {
assert_eq!(nullifiers.len(), 0);
//Successfully decrypt exactly 1 note
assert_eq!(new_comp_note.len(), 1);
let note = &new_comp_note[0].0;
let note = &new_comp_note[0].note;
//Successfully decrypt the balance
assert_eq!(note.value().inner(), 1000000000);
//Successfully decrypt the payment address
Expand Down Expand Up @@ -94,12 +97,12 @@ pub async fn test_create_transaction() -> Result<(), Box<dyn Error>> {
&mut new_notes,
)?;
assert_eq!(new_notes.len(), 1);
let (note, path) = &new_notes[0];
let mut path_vec = vec![];
path.write(&mut path_vec)?;
let path = hex::encode(path_vec);
let SpendableNote { note, witness, .. } = &new_notes[0];
let mut witness_vec = vec![];
witness.write(&mut witness_vec)?;
let path = hex::encode(witness_vec);
let tx = create_transaction_internal(
Either::Left(vec![(note.clone(), path.clone())]),
Either::Left(vec![(note.clone(), path)]),
&extended_spending_key,
output,
address,
Expand All @@ -118,9 +121,12 @@ pub async fn test_create_transaction() -> Result<(), Box<dyn Error>> {
// Verify that get_nullifier_from_note_internal yields the same nullifier
assert_eq!(
get_nullifier_from_note_internal(
extended_spending_key.to_extended_full_viewing_key(),
note.clone(),
path
&extended_spending_key
.to_extended_full_viewing_key()
.to_diversifiable_full_viewing_key()
.to_nk(Scope::External),
&note,
&witness,
)?,
"5269442d8022af933774f9f22775566d92089a151ba733f6d751f5bb65a7f56d"
);
Expand Down

0 comments on commit 7b01631

Please sign in to comment.