-
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
Fix slow ApiSharedWallet unit tests #2664
Conversation
The generators were doing crypto operations - which are really slow and generally not required for test cases.
It was ignoring the scale parameter and therefore generating excessively long names.
nameLength <- choose (walletNameMinLength, walletNameMaxLength) | ||
WalletName . T.pack <$> replicateM nameLength arbitraryPrintableChar | ||
len <- Test.QuickCheck.scale (min walletNameMaxLength) $ sized $ \n -> | ||
chooseInt (walletNameMinLength, walletNameMinLength `max` n) |
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.
👍🏻
genMockXPub = fromMaybe impossible . xpubFromBytes . BS.pack <$> genBytes | ||
where | ||
genBytes = vectorOf 64 arbitrary | ||
impossible = error "incorrect length in genMockXPub" |
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.
👍🏻
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, we can generate here random bytes 💯
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.
great catches!
bors r+ |
2664: Fix slow ApiSharedWallet unit tests r=paweljakubas a=rvl ### Issue Number Found during ADP-902 ### Overview The `Cardano.Wallet.Api.Types` tests are running very slowly. Also the unit tests were sometimes timing out in CI. Profiling showed that the `Arbitrary` instance of `ApiSharedWallet` was the slowest part. This change improves the speed of this generator. Now it is the OpenAPI validation which is the slowest part. ### Comments We may also be able to reduce the size of arbitrary `ApiSharedWallet` values, so that validation gets faster. Because it's still not especially quick. Something like the `instance Arbitrary WalletName` change in this PR could probably be applied. Co-authored-by: Rodney Lorrimar <[email protected]>
Build failed:
|
bors r+ |
Build succeeded: |
Issue Number
Found during ADP-902
Overview
The
Cardano.Wallet.Api.Types
tests are running very slowly. Also the unit tests were sometimes timing out in CI.Profiling showed that the
Arbitrary
instance ofApiSharedWallet
was the slowest part.This change improves the speed of this generator.
Now it is the OpenAPI validation which is the slowest part.
Comments
We may also be able to reduce the size of arbitrary
ApiSharedWallet
values, so that validation gets faster. Because it's still not especially quick. Something like theinstance Arbitrary WalletName
change in this PR could probably be applied.