-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More integration tests for CLI (including minor fixes in CLI) #278
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,17 @@ module Test.Integration.Framework.DSL | |
, json | ||
, tearDown | ||
, fixtureWallet | ||
|
||
-- * CLI | ||
, cardanoWalletCLI | ||
, cardanoWalletLauncherCLI | ||
, generateMnemonicsViaCLI | ||
, createWalletViaCLI | ||
, deleteWalletViaCLI | ||
, getWalletViaCLI | ||
, listAddressesViaCLI | ||
, listWalletsViaCLI | ||
, updateWalletViaCLI | ||
) where | ||
|
||
import Prelude hiding | ||
|
@@ -112,6 +123,19 @@ import Language.Haskell.TH.Quote | |
( QuasiQuoter ) | ||
import Numeric.Natural | ||
( Natural ) | ||
import System.Command | ||
( CmdResult, command ) | ||
import System.Exit | ||
( ExitCode (..) ) | ||
import System.IO | ||
( hClose, hFlush, hPutStr ) | ||
import System.Process | ||
( CreateProcess (..) | ||
, StdStream (..) | ||
, proc | ||
, waitForProcess | ||
, withCreateProcess | ||
) | ||
import Test.Hspec.Expectations.Lifted | ||
( shouldBe, shouldContain, shouldNotBe ) | ||
import Test.Integration.Faucet | ||
|
@@ -438,3 +462,54 @@ wantedErrorButSuccess | |
-> m void | ||
wantedErrorButSuccess = | ||
fail . ("expected an error but got a successful response: " <>) . show | ||
|
||
|
||
--- | ||
--- CLI | ||
--- | ||
cardanoWalletLauncherCLI :: CmdResult r => [String] -> IO r | ||
cardanoWalletLauncherCLI = command [] "cardano-wallet-launcher" | ||
|
||
cardanoWalletCLI :: CmdResult r => [String] -> IO r | ||
cardanoWalletCLI = command [] "cardano-wallet" | ||
|
||
generateMnemonicsViaCLI :: CmdResult r => [String] -> IO r | ||
generateMnemonicsViaCLI args = cardanoWalletCLI (["mnemonic", "generate"] ++ args) | ||
|
||
createWalletViaCLI :: [String] -> String -> String -> String -> IO ExitCode | ||
createWalletViaCLI args mnemonics mnemonics2 passphrase = do | ||
let fullArgs = ["wallet", "create", "--port", "1337"] ++ args | ||
let process = (proc "cardano-wallet" fullArgs) | ||
{ std_in = CreatePipe, std_out = CreatePipe, std_err = CreatePipe } | ||
withCreateProcess process $ \stdIn _ _ h -> do | ||
case stdIn of | ||
Nothing -> return () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should "throw". Since we use |
||
Just i -> do | ||
hPutStr i mnemonics | ||
hPutStr i mnemonics2 | ||
hPutStr i (passphrase ++ "\n") | ||
hPutStr i (passphrase ++ "\n") | ||
hFlush i | ||
hClose i | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My man ❤️ |
||
|
||
waitForProcess h | ||
|
||
|
||
deleteWalletViaCLI :: CmdResult r => String -> IO r | ||
deleteWalletViaCLI walId = cardanoWalletCLI ["wallet", "delete", "--port", | ||
"1337", walId ] | ||
|
||
getWalletViaCLI :: CmdResult r => String -> IO r | ||
getWalletViaCLI walId = cardanoWalletCLI ["wallet", "get", "--port", "1337" | ||
, walId ] | ||
|
||
listAddressesViaCLI :: CmdResult r => String -> IO r | ||
listAddressesViaCLI walId = cardanoWalletCLI ["address", "list", "--port", | ||
"1337", walId] | ||
|
||
listWalletsViaCLI :: CmdResult r => IO r | ||
listWalletsViaCLI = cardanoWalletCLI ["wallet", "list", "--port", "1337" ] | ||
|
||
updateWalletViaCLI :: CmdResult r => [String] -> IO r | ||
updateWalletViaCLI args = cardanoWalletCLI (["wallet", "update", "--port", | ||
"1337"] ++ args) |
161 changes: 161 additions & 0 deletions
161
lib/http-bridge/test/integration/Test/Integration/Framework/TestData.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
module Test.Integration.Framework.TestData | ||
( -- * Mnemonics | ||
chineseMnemonics9 | ||
, chineseMnemonics18 | ||
, frenchMnemonics12 | ||
, frenchMnemonics21 | ||
, invalidMnemonics12 | ||
, invalidMnemonics15 | ||
, japaneseMnemonics12 | ||
, japaneseMnemonics15 | ||
, mnemonics3 | ||
, mnemonics6 | ||
, mnemonics9 | ||
, mnemonics12 | ||
, mnemonics15 | ||
, mnemonics18 | ||
, mnemonics21 | ||
, mnemonics24 | ||
, specMnemonicSentence | ||
, specMnemonicSecondFactor | ||
|
||
-- * Wallets | ||
, arabicWalletName | ||
, falseWalletIds | ||
, kanjiWalletName | ||
, polishWalletName | ||
, russianWalletName | ||
, wildcardsWalletName | ||
|
||
|
||
-- * Helpers | ||
, addressPoolGapMax | ||
, addressPoolGapMin | ||
, passphraseMaxLength | ||
, passphraseMinLength | ||
) where | ||
|
||
import Prelude | ||
|
||
import Data.Text | ||
( Text ) | ||
|
||
falseWalletIds :: [(String, String)] | ||
falseWalletIds = | ||
[ ("40 chars hex", replicate 40 '1') | ||
, ("40 chars non-hex", replicate 40 'ś') | ||
, ("39 chars hex", replicate 39 '1') | ||
, ("41 chars hex", replicate 41 '1') | ||
] | ||
|
||
mnemonics3 :: [Text] | ||
mnemonics3 = ["diamond", "flee", "window"] | ||
|
||
mnemonics6 :: [Text] | ||
mnemonics6 = ["tornado", "canvas", "peasant", "spike", "enrich", "dilemma"] | ||
|
||
mnemonics9 :: [Text] | ||
mnemonics9 = ["subway", "tourist", "abstract", "roast", "border", "curious", | ||
"exercise", "work", "narrow"] | ||
|
||
mnemonics12 :: [Text] | ||
mnemonics12 = ["agent", "siren", "roof", "water", "giant", "pepper", | ||
"obtain", "oxygen", "treat", "vessel", "hip", "garlic"] | ||
|
||
mnemonics15 :: [Text] | ||
mnemonics15 = ["network", "empty", "cause", "mean", "expire", "private", | ||
"finger", "accident", "session", "problem", "absurd", "banner", "stage", | ||
"void", "what"] | ||
|
||
mnemonics18 :: [Text] | ||
mnemonics18 = ["whisper", "control", "diary", "solid", "cattle", "salmon", | ||
"whale", "slender", "spread", "ice", "shock", "solve", "panel", | ||
"caution", "upon", "scatter", "broken", "tonight"] | ||
|
||
mnemonics21 :: [Text] | ||
mnemonics21 = ["click", "puzzle", "athlete", "morning", "fold", "retreat", | ||
"across", "timber", "essay", "drill", "finger", "erase", "galaxy", | ||
"spoon", "swift", "eye", "awesome", "shrimp", "depend", "zebra", "token"] | ||
|
||
mnemonics24 :: [Text] | ||
mnemonics24 = ["decade", "distance", "denial", "jelly", "wash", "sword", | ||
"olive", "perfect", "jewel", "renew", "wrestle", "cupboard", "record", | ||
"scale", "pattern", "invite", "other", "fruit", "gloom", "west", "oak", | ||
"deal", "seek", "hand"] | ||
|
||
invalidMnemonics12 :: [Text] | ||
invalidMnemonics12 = ["word","word","word","word","word","word","word", | ||
"word","word","word","word","hill"] | ||
|
||
invalidMnemonics15 :: [Text] | ||
invalidMnemonics15 = ["word","word","word","word","word","word","word", | ||
"word","word","word","word","word","word","word","word"] | ||
|
||
specMnemonicSentence :: [Text] | ||
specMnemonicSentence = ["squirrel", "material", "silly", "twice", "direct", | ||
"slush", "pistol", "razor", "become", "junk", "kingdom", "flee", | ||
"squirrel", "silly", "twice"] | ||
|
||
specMnemonicSecondFactor :: [Text] | ||
specMnemonicSecondFactor = ["squirrel", "material", "silly", "twice", | ||
"direct", "slush", "pistol", "razor", "become"] | ||
|
||
japaneseMnemonics12 :: [Text] | ||
japaneseMnemonics12 = ["そうだん", "ひよう", "にもつ", "やさしい", "きふく", | ||
"ねつい", "だったい", "けんてい", "けいろ", "ざつがく", "ほうもん", "すこし"] | ||
|
||
japaneseMnemonics15 :: [Text] | ||
japaneseMnemonics15 = ["うめる", "せんく", "えんぎ", "はんぺん", "おくりがな", | ||
"さんち", "きなが", "といれ", "からい", "らくだ", "うえる", "ふめん", "せびろ", | ||
"られつ", "なにわ"] | ||
|
||
chineseMnemonics9 :: [Text] | ||
chineseMnemonics9 = ["钢", "看", "磁", "塑", "凤", "魏", "世", "腐", "恶" ] | ||
|
||
chineseMnemonics18 :: [Text] | ||
chineseMnemonics18 = ["盗", "精", "序", "郎", "赋", "姿", "委", "善", "酵", | ||
"祥", "赛", "矩", "蜡", "注", "韦", "效", "义", "冻"] | ||
|
||
frenchMnemonics12 :: [Text] | ||
frenchMnemonics12 = ["palmarès", "supplier", "visuel", "gardien", "adorer", | ||
"cordage", "notifier", "réglage", "employer", "abandon", "scénario", | ||
"proverbe"] | ||
|
||
frenchMnemonics21 :: [Text] | ||
frenchMnemonics21 = ["pliage", "exhorter", "brasier", "chausson", "bloquer", | ||
"besace", "sorcier", "absurde", "neutron", "forgeron", "geyser", | ||
"moulin", "cynique", "cloche", "baril", "infliger", "rompre", "typique", | ||
"renifler", "creuser", "matière"] | ||
|
||
russianWalletName :: Text | ||
russianWalletName = "АаБбВвГгДдЕеЁёЖжЗз ИиЙйКкЛлМмНнО оПпРрСсТтУуФф ХхЦцЧчШшЩщЪъ ЫыЬьЭэЮюЯяІ ѢѲѴѵѳѣі" | ||
|
||
polishWalletName :: Text | ||
polishWalletName = "aąbcćdeęfghijklłmnoóprsś\r\ntuvwyzżźAĄBCĆDEĘFGHIJKLŁMNOP\rRSŚTUVWYZŻŹ" | ||
|
||
kanjiWalletName :: Text | ||
kanjiWalletName = "亜哀挨愛曖悪握圧扱宛嵐安案暗以衣位囲医依委威為畏胃尉異移萎偉椅彙意違維慰\ | ||
\遺緯域育一壱逸茨芋引印因咽姻員院淫陰飲隠韻右宇羽雨唄鬱畝浦運雲永泳英映栄\n営詠影鋭衛易疫益液駅悦越謁\ | ||
\閲円延沿炎怨宴媛援園煙猿遠鉛塩演縁艶汚王凹\r\n央応往押旺欧殴桜翁奥横岡屋億憶臆虞乙俺卸音恩温穏下化火加\ | ||
\可仮何花佳価果河苛科架夏家荷華菓貨渦過嫁暇禍靴寡歌箇稼課蚊牙瓦我画芽賀雅餓介回灰会快戒改怪拐悔海界\ | ||
\皆械絵開階塊楷解潰壊懐諧貝外劾害崖涯街慨蓋該概骸垣柿各角拡革格核殻郭覚較隔閣確獲嚇穫学岳楽額顎掛潟\ | ||
\括活喝渇割葛滑褐轄且株釜鎌刈干刊甘汗缶\r" | ||
|
||
arabicWalletName :: Text | ||
arabicWalletName = "ثم نفس سقطت وبالتحديد،, جزيرتي باستخدام أن دنو. إذ هنا؟ الستار وتنصيب كان. أهّل ايطاليا، بريطانيا-فرنسا قد أخذ. سليمان، إتفاقية بين ما, يذكر الحدود أي بعد, معاملة بولندا، الإطلاق عل إيو." | ||
|
||
wildcardsWalletName :: Text | ||
wildcardsWalletName = "`~`!@#$%^&*()_+-=<>,./?;':\"\"'{}[]\\|❤️ 💔 💌 💕 💞 \ | ||
\💓 💗 💖 💘 💝 💟 💜 💛 💚 💙0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟🇺🇸🇷🇺🇸 🇦🇫🇦🇲🇸" | ||
|
||
passphraseMinLength :: Int | ||
passphraseMinLength = 10 | ||
|
||
passphraseMaxLength :: Int | ||
passphraseMaxLength = 255 | ||
|
||
addressPoolGapMin :: Int | ||
addressPoolGapMin = 10 | ||
|
||
addressPoolGapMax :: Int | ||
addressPoolGapMax = 100 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet :o