Add tests for memo parsing

This commit is contained in:
Rene Vergara 2022-08-29 15:35:24 -05:00
parent 11c5370962
commit e6683a0450
Signed by: pitmutt
GPG key ID: 65122AD495A7F5B2
2 changed files with 16 additions and 16 deletions

View file

@ -325,7 +325,7 @@ zToZGoTx (ZcashTx t a aZ bh bt c conf m) = do
".*ZGOp::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*" ".*ZGOp::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*"
let y = let y =
mkRegex mkRegex
".*MSG\\s(zs[a-z0-9]{76})\\sZGO::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*" ".*MSG\\s(zs[a-z0-9]{76})\\s+ZGO::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*"
let reg = matchAllText r (T.unpack m) let reg = matchAllText r (T.unpack m)
let reg2 = matchAllText p (T.unpack m) let reg2 = matchAllText p (T.unpack m)
let reg3 = matchAllText y (T.unpack m) let reg3 = matchAllText y (T.unpack m)
@ -896,7 +896,7 @@ scanZcash config pipe = do
".*ZGOp::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*" ".*ZGOp::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*"
let y = let y =
mkRegex mkRegex
".*MSG\\s(zs[a-z0-9]{76}).*ZGO::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*" ".*MSG\\s(zs[a-z0-9]{76})\\s+ZGO::([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}).*"
let k = map zToZGoTx (filter (isRelevant r) txs) let k = map zToZGoTx (filter (isRelevant r) txs)
mapM_ (access pipe master (c_dbName config) . upsertZGoTx "txs") k mapM_ (access pipe master (c_dbName config) . upsertZGoTx "txs") k
let j = map zToZGoTx (filter (isRelevant p) txs) let j = map zToZGoTx (filter (isRelevant p) txs)

View file

@ -61,14 +61,14 @@ main = do
1602000 1602000
18732456 18732456
False False
20 5
"ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply-To:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" "ZGO::5d3d4494-51c0-432d-8495-050419957aea\nReply-To:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e"
zToZGoTx t `shouldBe` zToZGoTx t `shouldBe`
ZGoTx ZGoTx
Nothing Nothing
"zs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" "zs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e"
"5d3d4494-51c0-432d-8495-050419957aea" "5d3d4494-51c0-432d-8495-050419957aea"
20 5
18732456 18732456
0.5 0.5
"someId" "someId"
@ -82,18 +82,18 @@ main = do
1602000 1602000
18732456 18732456
False False
20 5
"fjbMSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\nZGO::5d3d4494-51c0-432d-8495-050419957aea" "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGO::ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
zToZGoTx t `shouldBe` zToZGoTx t `shouldBe`
ZGoTx ZGoTx
Nothing Nothing
"zs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" "zs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e"
"5d3d4494-51c0-432d-8495-050419957aea" "ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
20 5
18732456 18732456
0.5 0.5
"someId" "someId"
"fjbMSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\nZGO::5d3d4494-51c0-432d-8495-050419957aea" "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGO::ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
it "converts ZecWallet payment tx to ZGo tx" $ do it "converts ZecWallet payment tx to ZGo tx" $ do
let t = let t =
ZcashTx ZcashTx
@ -103,14 +103,14 @@ main = do
1602000 1602000
18732456 18732456
False False
20 5
"ZGOp::5d3d4494-51c0-432d-8495-050419957aea\nReply-To:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e" "ZGOp::5d3d4494-51c0-432d-8495-050419957aea\nReply-To:\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e"
zToZGoTx t `shouldBe` zToZGoTx t `shouldBe`
ZGoTx ZGoTx
Nothing Nothing
"" ""
"5d3d4494-51c0-432d-8495-050419957aea" "5d3d4494-51c0-432d-8495-050419957aea"
20 5
18732456 18732456
0.5 0.5
"someId" "someId"
@ -124,18 +124,18 @@ main = do
1602000 1602000
18732456 18732456
False False
20 5
"fjbMSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\nZGOp::5d3d4494-51c0-432d-8495-050419957aea" "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGOp::ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
zToZGoTx t `shouldBe` zToZGoTx t `shouldBe`
ZGoTx ZGoTx
Nothing Nothing
"" ""
"5d3d4494-51c0-432d-8495-050419957aea" "ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
20 5
18732456 18732456
0.5 0.5
"someId" "someId"
"fjbMSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\nZGOp::5d3d4494-51c0-432d-8495-050419957aea" "\128737MSG\nzs1w6nkameazc5gujm69350syl5w8tgvyaphums3pw8eytzy5ym08x7dvskmykkatmwrucmgv3er8e\n\nZGOp::ad8477d3-4fdd-4c97-90b2-76630b5f77e1"
describe "PIN generator" $ do describe "PIN generator" $ do
it "should give a 7 digit" $ do it "should give a 7 digit" $ do
length (T.unpack (unsafePerformIO (generatePin 1010))) `shouldBe` 7 length (T.unpack (unsafePerformIO (generatePin 1010))) `shouldBe` 7