getBlockTime function added

This commit is contained in:
Rene V. Vergara A. 2024-03-28 15:06:02 -04:00
parent f099544162
commit 7cada685ce
5 changed files with 996 additions and 20 deletions

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,9 @@ zcash_primitives = "0.13.0"
zcash_client_backend = "0.10.0"
zip32 = "0.1.0"
proc-macro2 = "1.0.66"
reqwest = "0.12.1"
tokio = { version="1.36.0", features = ["full"] }
[features]
capi = []

View file

@ -66,6 +66,7 @@ use zcash_client_backend::keys::sapling::{
};
use zcash_primitives::zip32::DiversifierIndex;
use zcash_primitives::block::BlockHeader;
use orchard::{
Action,

View file

@ -102,3 +102,42 @@ makeZebraCall host port m params = do
case result zebraResp of
Nothing -> return $ Left "Empty response from Zebra"
Just zR -> return $ Right zR
-- |
hexDigitToInt :: Char -> Int
hexDigitToInt x = case x of
'0' -> 0
'1' -> 1
'2' -> 2
'3' -> 3
'4' -> 4
'5' -> 5
'6' -> 6
'7' -> 7
'8' -> 8
'9' -> 9
'a' -> 10
'b' -> 11
'c' -> 12
'd' -> 13
'e' -> 14
'f' -> 15
'A' -> 10
'B' -> 11
'C' -> 12
'D' -> 13
'E' -> 14
'F' -> 15
hexStringToInt :: String -> Int -> Int -> Int
hexStringToInt [] val _ = val
hexStringToInt (x:y:xs) val e =
hexStringToInt xs (val + ((hexDigitToInt x)*16 + (hexDigitToInt y))*256^e) (e+1)
getBlockTime :: String -> Int
getBlockTime hex_block = do
let hex_date = take 8 (drop 200 hex_block)
hexStringToInt hex_date 0 0

View file

@ -765,6 +765,10 @@ main = do
let bscAdr = SaplingReceiver $ BS.pack cAdr
let ca = genSaplingInternalAddress (SaplingSpendingKey $ BS.pack sk)
fromMaybe (SaplingReceiver "") ca `shouldBe` bscAdr
describe "Call zebra to get Block data" $ do
it "Call genBlockResponse" $ do
let blkdata <- genBlockResponse
return $ Just blkdata `shouldBe` ""
-- | Properties
prop_PhraseLength :: Property