diff --git a/src/Zenith/Utils.hs b/src/Zenith/Utils.hs index 835099a..cfb98e9 100644 --- a/src/Zenith/Utils.hs +++ b/src/Zenith/Utils.hs @@ -285,7 +285,7 @@ getZcashPrice currency = do -- Parse memo result to convert it to a ByteString processEither :: Either String BC.ByteString -> BC.ByteString processEither (Right bs) = bs -processEither (Left e) = BC.pack e -- Returns the error +processEither (Left e) = BC.pack e -- Returns the error message -- Parse the query string into key-value pairs parseQuery :: String -> [(String, String)] diff --git a/test/Spec.hs b/test/Spec.hs index 3938dd8..fd2deb9 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1111,7 +1111,7 @@ main = do case price of Just p -> p `shouldNotBe` 0.0 Nothing -> assertFailure "Failed to get ZEC price" - describe "Parse an URI payment string" $ do + describe "Parse an URI payment string (all fields filled) " $ do it ("Parsing URI -> " ++ "zcash:ztestsapling10yy2ex5....") $ do let zcashURI2 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=100&memo=SGVsbG8sIFdvcmxkIQ==&message=Test" case parseZcashPayment zcashURI2 of @@ -1119,3 +1119,19 @@ main = do print p (uriAmount p) `shouldBe` Just 100.0 Left e -> assertFailure $ "Error: " ++ e + describe "Parse an URI payment string (just address and amount fields provided) " $ do + it ("Parsing URI -> " ++ "zcash:ztestsapling10yy2ex5....") $ do + let zcashURI3 = "zcash:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=100" + case parseZcashPayment zcashURI3 of + Right p -> do + print p + (uriAmount p) `shouldBe` Just 100.0 + Left e -> assertFailure $ "Error: " ++ e + describe "Parse an URI payment string (invalid URI provided) " $ do + it ("Parsing URI -> " ++ "zcash:ztestsapling10yy2ex5....") $ do + let zcashURI3 = "z:ztestsapling10yy2ex5dcqkclhc7z7yrnjq2z6feyjad56ptwlfgmy77dmaqqrl9gyhprdx59qgmsnyfska2kez?amount=100" + case parseZcashPayment zcashURI3 of + Right p -> do + print p + (uriAmount p) `shouldBe` Just 100.0 + Left e -> assertFailure $ "Error: " ++ e