From b74cd5f35467f84088b9b982736306d6ccfc5791 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Wed, 24 Apr 2024 16:04:56 -0500 Subject: [PATCH] Update note position calculation --- librustzcash-wrapper/src/lib.rs | 12 ++---------- test/Spec.hs | 24 +++++++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/librustzcash-wrapper/src/lib.rs b/librustzcash-wrapper/src/lib.rs index ab7c934..67a7447 100644 --- a/librustzcash-wrapper/src/lib.rs +++ b/librustzcash-wrapper/src/lib.rs @@ -1247,16 +1247,8 @@ pub extern "C" fn rust_wrapper_read_sapling_position( let wit_in: Vec = marshall_from_haskell_var(wit, wit_len, RW); let wit_reader = Cursor::new(wit_in); let iw: IncrementalWitness = read_incremental_witness(wit_reader).unwrap(); - let path = iw.path(); - match path { - Some(p) => { - let pos = p.position(); - return u64::from(pos); - }, - None => { - return 0; - } - } + let pos = iw.witnessed_position(); + return u64::from(pos); } #[no_mangle] diff --git a/test/Spec.hs b/test/Spec.hs index 5c6f3a5..19ca7a4 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1113,23 +1113,25 @@ main = do MainNet External p - dn `shouldNotBe` Nothing - + dn `shouldBe` Nothing describe "Generate an ExchangeAddress (MainNet) from transparent address" $ do let ta = decodeTransparentAddress "t1dMjvesbzdG41xgKaGU3HgwYJwSgbCK54e" it "Try to generate valid ExchangeAddress from Transparent Address" $ do - case ta of - Nothing -> assertFailure "Failed to decode transparent address" - Just t -> do - case (tr_type (ta_receiver t) ) of - P2SH -> assertFailure "P2SH not supported for ExchengeAddress generation" + case ta of + Nothing -> assertFailure "Failed to decode transparent address" + Just t -> do + case (tr_type (ta_receiver t)) of + P2SH -> + assertFailure + "P2SH not supported for ExchengeAddress generation" P2PKH -> do - let exch = encodeExchangeAddress (ta_network t) (ta_receiver t) + let exch = + encodeExchangeAddress (ta_network t) (ta_receiver t) case exch of - Nothing -> assertFailure "Failed to encode Exchange address" - Just addr -> do + Nothing -> assertFailure "Failed to encode Exchange address" + Just addr -> do let eadr = decodeExchangeAddress addr - eadr `shouldNotBe` Nothing + eadr `shouldNotBe` Nothing -- | Properties prop_PhraseLength :: Property -- 2.34.1