From 7258af44c38f597c58b1278556b0c24d14cc4d9a Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Sat, 12 Aug 2023 21:17:42 -0500 Subject: [PATCH 1/2] Enable the config file in test suite --- test/Spec.hs | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/test/Spec.hs b/test/Spec.hs index 264d458..e493d88 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1211,17 +1211,40 @@ unwrapDoc _ = [] startAPI :: Config -> IO () startAPI config = do putStrLn "Starting test server ..." - pipe <- connect $ host "127.0.0.1" - c <- access pipe master "zgo" (auth "zgo" "zcashrules") + pipe <- connect $ host $ c_dbHost config + c <- access pipe master "zgo" (auth (c_dbUser config) (c_dbPassword config)) let appRoutes = routes pipe config _ <- forkIO (scotty 3000 appRoutes) _ <- - access pipe master "test" (Database.MongoDB.delete (select [] "wootokens")) - _ <- access pipe master "test" (Database.MongoDB.delete (select [] "users")) - _ <- access pipe master "test" (Database.MongoDB.delete (select [] "items")) - _ <- access pipe master "test" (Database.MongoDB.delete (select [] "orders")) + access + pipe + master + (c_dbName config) + (Database.MongoDB.delete (select [] "wootokens")) _ <- - access pipe master "test" (Database.MongoDB.delete (select [] "xerotokens")) + access + pipe + master + (c_dbName config) + (Database.MongoDB.delete (select [] "users")) + _ <- + access + pipe + master + (c_dbName config) + (Database.MongoDB.delete (select [] "items")) + _ <- + access + pipe + master + (c_dbName config) + (Database.MongoDB.delete (select [] "orders")) + _ <- + access + pipe + master + (c_dbName config) + (Database.MongoDB.delete (select [] "xerotokens")) let myUser = User (Just (read "6272a90f2b05a74cf1000001" :: ObjectId)) From 5ce72e5d951beaf8997fcff20e8e3646fda5e41f Mon Sep 17 00:00:00 2001 From: Rene Vergara Date: Mon, 14 Aug 2023 08:59:45 -0500 Subject: [PATCH 2/2] Update test suite --- test/Spec.hs | 128 +-------------------------------------------------- 1 file changed, 1 insertion(+), 127 deletions(-) diff --git a/test/Spec.hs b/test/Spec.hs index e493d88..5cd7576 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -56,7 +56,7 @@ main = do describe "hex strings" $ do prop "encoding and decoding are inverse" $ \x -> (decodeHexText . encodeHexText) x == x - describe "zToZGoTx" $ + describe "Memo parsers" $ --prop "memo parsing" testMemoParser do it "parse ZecWallet memo" $ do @@ -92,132 +92,6 @@ main = do Right m' -> m_session m' `shouldBe` U.fromString "5d3d4494-51c0-432d-8495-050419957aea" - it "converts ZecWallet 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 YWallet tx to ZGo tx" $ do - let t = - ZcashTx - "someId" - 0.5 - 50000000 - 1602000 - 18732456 - False - 5 - "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGO::ad8477d3-4fdd-4c97-90b2-76630b5f77e1" - zToZGoTx t `shouldBe` - ZGoTx - Nothing - "zs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" - "ad8477d3-4fdd-4c97-90b2-76630b5f77e1" - 5 - 18732456 - 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 - "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" - it "converts YWallet payment tx to ZGo tx" $ do - let t = - ZcashTx - "someId" - 0.5 - 50000000 - 1602000 - 18732456 - False - 5 - "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGOp::ad8477d3-4fdd-4c97-90b2-76630b5f77e1" - zToZGoTx t `shouldBe` - ZGoTx - Nothing - "" - "ad8477d3-4fdd-4c97-90b2-76630b5f77e1" - 5 - 18732456 - 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