From e0f263f7f0a118e0df5579a164954918a05c5f08 Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Thu, 20 Jul 2023 10:13:47 -0500 Subject: [PATCH] Test updates --- src/ZGoBackend.hs | 3 ++- test/Spec.hs | 57 +++++++++++++++++++++++++++++++++++++++++++++-- zgo-backend.cabal | 2 +- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/ZGoBackend.hs b/src/ZGoBackend.hs index 99d5cde..c67fe69 100644 --- a/src/ZGoBackend.hs +++ b/src/ZGoBackend.hs @@ -364,10 +364,11 @@ zToZGoTx (ZcashTx t a aZ bh bt c conf m) = do zToZGoTx' :: Config -> Pipe -> ZcashTx -> IO () zToZGoTx' config pipe (ZcashTx t a aZ bh bt c conf m) = do - when (conf < 100) $ do + when (conf < c_confirmations config) $ do let zM = runParser pZGoMemo (T.unpack t) m case zM of Right zM' -> do + print zM' let tx = ZGoTx Nothing diff --git a/test/Spec.hs b/test/Spec.hs index 5f17d11..264d458 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -81,6 +81,17 @@ main = do Right m' -> m_session m' `shouldBe` U.fromString "ad8477d3-4fdd-4c97-90b2-76630b5f77e1" + it "parse Zingo memo" $ do + let m = + runParser + pZGoMemo + "Zingo memo" + "ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply to:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" + case m of + Left e -> putStrLn $ errorBundlePretty e + Right m' -> + m_session m' `shouldBe` + U.fromString "5d3d4494-51c0-432d-8495-050419957aea" it "converts ZecWallet tx to ZGo tx" $ do let t = ZcashTx @@ -123,6 +134,27 @@ main = do 0.5 "someId" "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGO::ad8477d3-4fdd-4c97-90b2-76630b5f77e1" + it "converts Zingo tx to ZGo tx" $ do + let t = + ZcashTx + "someId" + 0.5 + 50000000 + 1602000 + 18732456 + False + 5 + "ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply to:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" + zToZGoTx t `shouldBe` + ZGoTx + Nothing + "zs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" + "5d3d4494-51c0-432d-8495-050419957aea" + 5 + 18732456 + 0.5 + "someId" + "ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply to:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" it "converts ZecWallet payment tx to ZGo tx" $ do let t = ZcashTx @@ -165,6 +197,27 @@ main = do 0.5 "someId" "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGOp::ad8477d3-4fdd-4c97-90b2-76630b5f77e1" + it "converts Zingo payment tx to ZGo tx" $ do + let t = + ZcashTx + "someId" + 0.5 + 50000000 + 1602000 + 18732456 + False + 5 + "ZGOp::5d3d4494-51c0-432d-8495-050419957aea\nReply to:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" + zToZGoTx t `shouldBe` + ZGoTx + Nothing + "" + "5d3d4494-51c0-432d-8495-050419957aea" + 5 + 18732456 + 0.5 + "someId" + "ZGOp::5d3d4494-51c0-432d-8495-050419957aea\nReply to:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" describe "PIN generator" $ do it "should give a 7 digit" $ do pin <- generatePin @@ -909,7 +962,7 @@ main = do xit "logins are added to db" $ \p -> do _ <- access p master "test" (Database.MongoDB.delete (select [] "txs")) - _ <- scanZcash loadedConfig p + _ <- scanZcash' loadedConfig p threadDelay 1000000 t <- access p master "test" $ findOne (select [] "txs") let s = parseZGoTxBson =<< t @@ -922,7 +975,7 @@ main = do master "test" (Database.MongoDB.delete (select [] "payments")) - _ <- scanZcash loadedConfig p + _ <- scanZcash' loadedConfig p threadDelay 1000000 t <- access p master "test" $ findOne (select [] "payments") let s = (cast' . Doc) =<< t diff --git a/zgo-backend.cabal b/zgo-backend.cabal index 264cfbf..e9b46b8 100644 --- a/zgo-backend.cabal +++ b/zgo-backend.cabal @@ -5,7 +5,7 @@ cabal-version: 1.12 -- see: https://github.com/sol/hpack name: zgo-backend -version: 1.6.0 +version: 1.7.0 synopsis: Haskell Back-end for the ZGo point-of-sale application description: Please see the README at category: Web