-
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
Enable Integration Tests for Jörmungandr (Part III: Command-Line tests) #496
Conversation
Stdout mnemonics <- generateMnemonicsViaCLI [] | ||
let payldCrt = payloadWith "!st created" (T.words $ T.pack mnemonics) | ||
mnemonics <- mnemonicToText @15 . entropyToMnemonic <$> genEntropy | ||
let payldCrt = payloadWith "!st created" mnemonics |
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.
I've "inlined" this CLI call since there's no reason the API scenarios would require something from the CLI (and this complexifies calling these specs for now reasons). We do have dedicated CLI specs for testing mnemonic generation so, all good.
instance KnownCommand (HttpBridge n) where | ||
commandName = "cardano-wallet-http-bridge" | ||
|
||
main :: forall t. (t ~ HttpBridge 'Testnet) => IO () |
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.
And this is where the magic happens and where we finally get to choose which CLI the specs should run on.
err `shouldBe` "Please enter a passphrase: **************\nOk.\n" | ||
txJson <- expectValidJSON (Proxy @(ApiTransaction t)) out | ||
verify txJson | ||
[ expectCliFieldBetween amount (feeMin + amt, feeMax + amt) | ||
[ expectCliFieldBetween amount (feeMin + (2*amt), feeMax + (2*amt)) |
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.
So, this was left unnoticed because the fee amounts are much bigger on the bridge scenarios and make the amount completely insignificant. This isn't the case with Jörmungandr where the amount and fee are more of less of the same order of magnitude!
b642f83
to
d310442
Compare
e8e1e4e
to
2631f81
Compare
deleteWalletViaCLI :: (CmdResult r, HasType Port s) => s -> String -> IO r | ||
deleteWalletViaCLI ctx walId = cardanoWalletCLI | ||
deleteWalletViaCLI | ||
:: forall t r s. (CmdResult r, KnownCommand t, HasType Port s) |
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.
Maybe we could use a constraint synonym to reduce noise.
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.
Yeah, thought of it but some functions have slightly different constraints, and I thought that introducing sometimes an alias, and sometimes not will create more noise than help. In the end, it will mean one other type of constraint to load into our brain when reading :/
let process = proc' (commandName @t) args | ||
withCreateProcess process $ \_ _ _ ph -> do | ||
expectPathEventuallyExist db | ||
expectPathEventuallyExist (db <> "-shm") |
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.
I know this is copy&pasted from somewhere else, but will comment here anyway.
I don't think we need to assert that the -shm
and -wal
files exist. They are meant to be temporary files, and are a sqlite implementation detail. We just need to assert the db file was created.
Also if the -wal
file exists after exit then that means we have not closed the database connection properly. Hmm.
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.
I asked a question in the past about this on a review (about what where those -shm and -wal expected to be). I agree that we could reduce this to test whether the db file exists as the rest seems more like an "implementation detail" from SQLite & Persistent (as far as I understand...)
This allows for running the same scenarios using different command line interfaces
…implement 'KnownCommand' for it
Remains: the port tests which are a bit trickier. Will do in a separate commit
Rationale is that these files are rather internal to the way the database works. So, there's no reason we should be even considering them. As long as the db file exists, we are fine.
2631f81
to
9d929a4
Compare
Issue Number
#358
Overview
KnownCommand
to allow abstracting the name of the command-line interface from the CLI DSL and scenarioscardano-wallet
executable intocardano-wallet-http-bridge
Server
specs forhttp-bridge
and created a specific one for JormungandrTo be done:
.travis.yaml
deployment scriptComments
KtorZ/cli-optparse-applicative
spoiler: Most of this PR is about
@t
.