-
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
Sqlite: enable db property tests and fix failures #300
Conversation
@rvl These are my conclusions (hope will help you hammer out the solution) :
the test fails for
so we have cleanDB doing its job, as a result when the key is chosen for the test case (by
ie.,
|
d08f5f5
to
ee6ad17
Compare
@paweljakubas Thanks for the debugging and fixes. |
ee6ad17
to
689cf6e
Compare
, Wallet (..) | ||
, migrateAll | ||
, unWalletKey | ||
) |
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.
Okay ^.^ , I had kept this one separate as an "exception", but I admit this is more consistent and aligned with our style.
insertCheckpoint wid cp | ||
{ createWallet = \(PrimaryKey wid) cp meta -> withWriteLock $ | ||
ExceptT $ runQuery conn $ do | ||
res <- handleConstraint (ErrWalletAlreadyExists wid) $ |
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.
Are we sure that any constraint errors are actually because of already existing wallet id?
res <- handleConstraint (ErrWalletAlreadyExists wid) $ | ||
insert_ (mkWalletEntity wid meta) | ||
when (isRight res) $ | ||
insertCheckpoint wid cp |
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, in case a wallet already exists (isLeft res
), this returns a success 🤔 ?
Okay actually not. I was confused initially because we aren't in an 'Either' or 'ExceptT' monad here.
@@ -182,7 +179,7 @@ instance Arbitrary TxMeta where | |||
arbitrary = TxMeta | |||
<$> elements [Pending, InLedger, Invalidated] | |||
<*> elements [Incoming, Outgoing] | |||
<*> (SlotId <$> arbitrary <*> choose (0, 21600)) | |||
<*> (SlotId <$> choose (0, 1000) <*> choose (0, 21599)) |
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.
👍
arbitrary = initWallet <$> arbitrary | ||
|
||
instance Eq (SeqState DummyTarget) where | ||
_ == _ = True |
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.
What's the rationale for this instance? And what is the justification for it to be always true ?
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 believe (cannot say in the name of Rodney) it is because it is transparent in the context of tests we deliver here
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.
It feels somewhat wrong though. Why would any SeqState
be equal? I wonder where this enters into play.
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.
yes, we need to add :
191 instance Eq (SeqState DummyTarget) where
192 (SeqState int1 ext1 pen1) == (SeqState int2 ext2 pen2) =
193 (int1 == int2) && (ext1 == ext2) && (pen1 == pen2)
or just :
deriving instance Eq (SeqState DummyTarget)
@@ -13,6 +13,7 @@ | |||
|
|||
module Cardano.Wallet.Primitive.AddressDiscoverySpec | |||
( spec | |||
, DummyTarget |
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.
Hmmm... Not really sure about this. The test and instance from AddressDiscovery
are quite specific and tailored for the properties of that module. They only use a single account key for instance. I guess it's okay for the DBSpec, but I'd rather not do that yet, and stick with our current approach of not sharing instances between spec files. This is an open-gate for messiness later.
We may discuss how we can better share generators between spec files without making spec files depend on each others. It becomes quite hard then to follow which arbitrary instance comes from where....
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.
moved to DBspec needed bits, and here export DummyTarget
to MVarSpec and SliteSpec.
-- | Delete transactions that belong to a wallet and aren't referred to by | ||
-- either Pending or TxMeta. | ||
deleteLooseTransactions | ||
-- | Delete unused TxMeta values for a wallet. |
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.
Comment is a bit of a lie here 😬 ... the function doesn't care much about whether the meta is used or unused, it just cleans them all.
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.
fixed. also take care of indenting in this file. Some functions had 2-character indents in this file
689cf6e
to
5b66760
Compare
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.
A lot of work and effort was put into this PR. LGTM!
5b66760
to
ce69389
Compare
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.
LGTM 👍
Nice investigation work.
- putMany was keeping the old TxMeta entries, rather than replacing them. - Clean up imports.
Relates to issue #154
Overview