Skip to content
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

Merged
merged 7 commits into from
Jul 3, 2019

Conversation

KtorZ
Copy link
Member

@KtorZ KtorZ commented Jul 2, 2019

Issue Number

#358

Overview

  • I have introduce a new class-constraints KnownCommand to allow abstracting the name of the command-line interface from the CLI DSL and scenarios
  • I have renamed cardano-wallet executable into cardano-wallet-http-bridge
  • I isolated the Server specs for http-bridge and created a specific one for Jormungandr
  • I have enabled most of the integration tests specs, except the Ports one (require a slightly more complex setup)

To be done:

  • Enable the Port tests
  • Review .travis.yaml deployment script

Comments

⚠️ Base branch is KtorZ/cli-optparse-applicative ⚠️

spoiler: Most of this PR is about @t.

@KtorZ KtorZ self-assigned this Jul 2, 2019
@KtorZ KtorZ changed the base branch from master to KtorZ/cli-optparse-applicative July 2, 2019 16:33
Stdout mnemonics <- generateMnemonicsViaCLI []
let payldCrt = payloadWith "!st created" (T.words $ T.pack mnemonics)
mnemonics <- mnemonicToText @15 . entropyToMnemonic <$> genEntropy
let payldCrt = payloadWith "!st created" mnemonics
Copy link
Member Author

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 ()
Copy link
Member Author

@KtorZ KtorZ Jul 2, 2019

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))
Copy link
Member Author

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!

@jonathanknowles jonathanknowles changed the base branch from KtorZ/cli-optparse-applicative to master July 3, 2019 07:19
@jonathanknowles jonathanknowles force-pushed the KtorZ/cli-integration-tests-multiple-backend branch from b642f83 to d310442 Compare July 3, 2019 07:34
@KtorZ KtorZ force-pushed the KtorZ/cli-integration-tests-multiple-backend branch from e8e1e4e to 2631f81 Compare July 3, 2019 08:35
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)
Copy link
Contributor

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.

Copy link
Member Author

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")
Copy link
Contributor

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.

Copy link
Member Author

@KtorZ KtorZ Jul 3, 2019

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...)

KtorZ and others added 7 commits July 3, 2019 14:11
This allows for running the same scenarios using different command line interfaces
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.
@KtorZ KtorZ force-pushed the KtorZ/cli-integration-tests-multiple-backend branch from 2631f81 to 9d929a4 Compare July 3, 2019 12:13
@KtorZ KtorZ merged commit 52eb698 into master Jul 3, 2019
@KtorZ KtorZ deleted the KtorZ/cli-integration-tests-multiple-backend branch July 4, 2019 16:15
@KtorZ KtorZ mentioned this pull request Jul 4, 2019
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants