From 555b93821271b28fb9b6bd4aec32a833c5279565 Mon Sep 17 00:00:00 2001 From: kderme Date: Thu, 18 Oct 2018 16:20:33 +0300 Subject: [PATCH] [CBR-468] Add sliding windows tx requests --- .../src/Cardano/Wallet/Kernel/DB/Sqlite.hs | 12 ++-- .../Cardano/Wallet/Kernel/DB/TxMeta/Types.hs | 1 + .../Wallet/WalletLayer/Kernel/Transactions.hs | 62 +++++++++++++++---- .../test/unit/Test/Spec/GetTransactions.hs | 6 +- wallet-new/test/unit/TxMetaStorageSpecs.hs | 52 ++++++++-------- 5 files changed, 89 insertions(+), 44 deletions(-) diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs index d7f376647f7..13443b2f2c9 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/Sqlite.hs @@ -543,11 +543,11 @@ getTxMeta conn txid walletId accountIx = do getTxMetasById :: Sqlite.Connection -> Txp.TxId -> IO (Maybe Kernel.TxMeta) getTxMetasById conn txId = safeHead . fst <$> getTxMetas conn (Offset 0) - (Limit 10) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing + (Limit 10) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing False getAllTxMetas :: Sqlite.Connection -> IO [Kernel.TxMeta] getAllTxMetas conn = fst <$> getTxMetas conn (Offset 0) - (Limit $ fromIntegral (maxBound :: Int)) Everything Nothing NoFilterOp NoFilterOp Nothing + (Limit $ fromIntegral (maxBound :: Int)) Everything Nothing NoFilterOp NoFilterOp Nothing False getTxMetas :: Sqlite.Connection -> Offset @@ -557,8 +557,9 @@ getTxMetas :: Sqlite.Connection -> FilterOperation Txp.TxId -> FilterOperation Core.Timestamp -> Maybe Sorting + -> Bool -> IO ([Kernel.TxMeta], Maybe Int) -getTxMetas conn (Offset offset) (Limit limit) accountFops mbAddress fopTxId fopTimestamp mbSorting = do +getTxMetas conn (Offset offset) (Limit limit) accountFops mbAddress fopTxId fopTimestamp mbSorting countTotal = do res <- Sqlite.runDBAction $ runBeamSqlite conn $ do -- The following 3 queries are disjointed and both fetches, respectively, @@ -597,10 +598,13 @@ getTxMetas conn (Offset offset) (Limit limit) accountFops mbAddress fopTxId fopT Left e -> throwIO $ Kernel.StorageFailure (toException e) Right Nothing -> return ([], Just 0) Right (Just (meta, inputs, outputs)) -> do - eiCount <- limitExecutionTimeTo (25 :: Second) (\ _ -> ()) $ ignoreLeft $ Sqlite.runDBAction $ runBeamSqlite conn $ + eiCount <- if countTotal + then limitExecutionTimeTo (25 :: Second) (\ _ -> ()) $ + ignoreLeft $ Sqlite.runDBAction $ runBeamSqlite conn $ case mbAddress of Nothing -> SQL.runSelectReturningOne $ SQL.select metaQueryC Just addr -> SQL.runSelectReturningOne $ SQL.select $ metaQueryWithAddrC addr + else return $ Right Nothing let mapWithInputs = transform $ map (\inp -> (_inputTableTxId inp, inp)) inputs let mapWithOutputs = transform $ map (\out -> (_outputTableTxId out, out)) outputs let txMeta = toValidKernelTxMeta mapWithInputs mapWithOutputs $ NonEmpty.toList meta diff --git a/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs b/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs index 6807b3bed02..052963757cc 100644 --- a/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs +++ b/wallet-new/src/Cardano/Wallet/Kernel/DB/TxMeta/Types.hs @@ -299,6 +299,7 @@ data MetaDBHandle = MetaDBHandle { -> FilterOperation Txp.TxId -- Filters on the TxId of the Tx. -> FilterOperation Core.Timestamp -- Filters on the creation timestamp of the Tx. -> Maybe Sorting -- Sorting of the results. + -> Bool -- whether we want to count total Entries (ignoring pagination Offset and Limit) -> IO ([TxMeta], Maybe Int) -- the result in the form (results, totalEntries). -- totalEntries may be Nothing, because counting can -- be an expensive operation. diff --git a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs index d395ccb3788..794cf943108 100644 --- a/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs +++ b/wallet-new/src/Cardano/Wallet/WalletLayer/Kernel/Transactions.hs @@ -48,18 +48,56 @@ getTransactions wallet mbWalletId mbAccountIndex mbAddress params fop sop = lift db <- liftIO $ Kernel.getWalletSnapshot wallet sc <- liftIO $ Node.getSlotCount (wallet ^. Kernel.walletNode) currentSlot <- liftIO $ Node.getTipSlotId (wallet ^. Kernel.walletNode) - (meta, mbTotalEntries) <- liftIO $ TxMeta.getTxMetas - (wallet ^. Kernel.walletMeta) - (TxMeta.Offset . fromIntegral $ (cp - 1) * pp) - (TxMeta.Limit . fromIntegral $ pp) - accountFops - (unV1 <$> mbAddress) - (castFiltering $ mapIx unV1 <$> F.findMatchingFilterOp fop) - (castFiltering $ mapIx unV1 <$> F.findMatchingFilterOp fop) - mbSorting - txs <- withExceptT GetTxUnknownHdAccount $ - mapM (metaToTx db sc currentSlot) meta - return $ respond params txs mbTotalEntries + -- things we read from sqlite, may fail to be transformed to Txs. So we + -- keep querying in a loop. + -- loop invariants: + -- + length accTxs == accTxsLength + -- + accTxsLength < pp + -- + accTrials <= trialsThreshold + -- + localLimit <= localLimitThreshold + let go :: Int -> Int -> Int -> ([V1.Transaction], Int) -> Maybe Int -> IO (Either GetTxError (WalletResponse [V1.Transaction])) + go accTrials localOffset localLimit (accTxs, accTxsLength) accTotalEntries = do + (newMetas, newTotalEntries) <- TxMeta.getTxMetas + (wallet ^. Kernel.walletMeta) + (TxMeta.Offset . fromIntegral $ (cp - 1) * pp + localOffset) + (TxMeta.Limit . fromIntegral $ localLimit) + accountFops + (unV1 <$> mbAddress) + (castFiltering $ mapIx unV1 <$> F.findMatchingFilterOp fop) + (castFiltering $ mapIx unV1 <$> F.findMatchingFilterOp fop) + mbSorting + (accTrials == 0) -- we only count total results in first loop. + let newMetasLength = length newMetas + -- txs which don't have account in acid-state are filtered out. + newTxs <- catMaybes <$> mapM (\m -> rightToMaybe <$> (runExceptT $ metaToTx db sc currentSlot m)) newMetas + -- txs which are invalid are filtered out. + let newValidTxs = filter isValid newTxs + let newValidTxsLength = length newValidTxs + + let txs = accTxs <> newValidTxs + let txsLength = accTxsLength + length newValidTxs + let mbTotalEntries = if accTrials == 0 then newTotalEntries else accTotalEntries + let newLocalOffset = localOffset + localLimit + let trials = accTrials + 1 + if trials > trialsThreshold || txsLength >= pp || localLimit > localLimitThreshold + || newMetasLength < localLimit + then return $ Right $ respond params (take pp txs) mbTotalEntries + else do + let newLocalLimit = if newValidTxsLength == 0 + then 2 * localLimit + else localLimit + go trials newLocalOffset newLocalLimit (txs, txsLength) mbTotalEntries + ExceptT $ liftIO $ go 0 0 pp ([], 0) Nothing + +trialsThreshold :: Int +trialsThreshold = 7 + +localLimitThreshold :: Int +localLimitThreshold = 1000 + +isValid :: V1.Transaction -> Bool +isValid tx = not (V1.txDirection tx == V1.IncomingTransaction + && ((V1.txStatus tx == V1.Applying) || (V1.txStatus tx == V1.WontApply))) toTransaction :: MonadIO m => Kernel.PassiveWallet diff --git a/wallet-new/test/unit/Test/Spec/GetTransactions.hs b/wallet-new/test/unit/Test/Spec/GetTransactions.hs index b42daecc89d..164c15fb37e 100644 --- a/wallet-new/test/unit/Test/Spec/GetTransactions.hs +++ b/wallet-new/test/unit/Test/Spec/GetTransactions.hs @@ -221,7 +221,7 @@ spec = do case decodeTextAddress wId of Left _ -> expectationFailure "decodeTextAddress failed" Right rootAddr -> do - let meta = testMeta {_txMetaWalletId = rootAddr, _txMetaAccountIx = accIdx} + let meta = testMeta {_txMetaWalletId = rootAddr, _txMetaAccountIx = accIdx, _txMetaIsOutgoing = True} _ <- liftIO $ WalletLayer.createAddress layer (V1.NewAddress Nothing @@ -229,7 +229,7 @@ spec = do (V1.WalletId wId) ) putTxMeta (pwallet ^. Kernel.walletMeta) meta - (result, mbCount) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp Nothing + (result, mbCount) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp Nothing True map Isomorphic result `shouldMatchList` [Isomorphic meta] let check WalletResponse{..} = do let PaginationMetadata{..} = metaPagination wrMeta @@ -296,7 +296,7 @@ spec = do Right False -> expectationFailure "txid not found in Acid State from Kernel" Right True -> pure () _ <- liftIO (WalletLayer.createAddress layer (V1.NewAddress Nothing accIdx (V1.WalletId wId))) - (result, mbCount) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp Nothing + (result, mbCount) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp Nothing True map Isomorphic result `shouldMatchList` [Isomorphic meta] let check WalletResponse{..} = do let PaginationMetadata{..} = metaPagination wrMeta diff --git a/wallet-new/test/unit/TxMetaStorageSpecs.hs b/wallet-new/test/unit/TxMetaStorageSpecs.hs index 393cb831dde..97fbb6c2d60 100644 --- a/wallet-new/test/unit/TxMetaStorageSpecs.hs +++ b/wallet-new/test/unit/TxMetaStorageSpecs.hs @@ -296,7 +296,7 @@ txMetaStorageSpecs = do case (metaRes1, metaRes2) of (Just m1, Nothing) -> do Isomorphic m1 `shouldBe` Isomorphic meta1 - ([m], count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing + ([m], count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing True Isomorphic m `shouldBe` Isomorphic m1 count `shouldBe` (Just 1) (_, _) -> expectationFailure "only the first get should succeed" @@ -322,7 +322,7 @@ txMetaStorageSpecs = do case (metaRes1, metaRes2) of (Just m1, Nothing) -> do Isomorphic m1 `shouldBe` Isomorphic meta1 - ([m], count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing + ([m], count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing True Isomorphic m `shouldBe` Isomorphic m1 count `shouldBe` (Just 1) (_, _) -> expectationFailure "only the first get should succeed" @@ -344,7 +344,7 @@ txMetaStorageSpecs = do (Just m1, Just m2) -> do Isomorphic m1 `shouldBe` Isomorphic meta1 Isomorphic m2 `shouldBe` Isomorphic meta2 - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing True map Isomorphic result `shouldContain` [Isomorphic m1] map Isomorphic result `shouldContain` [Isomorphic m2] count `shouldBe` (Just 2) @@ -368,7 +368,7 @@ txMetaStorageSpecs = do (Just m1, Just m2) -> do Isomorphic m1 `shouldBe` Isomorphic meta1 Isomorphic m2 `shouldBe` Isomorphic meta2 - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing (FilterByIndex txId) NoFilterOp Nothing True map Isomorphic result `shouldContain` [Isomorphic m1] map Isomorphic result `shouldContain` [Isomorphic m2] count `shouldBe` (Just 2) @@ -390,7 +390,7 @@ txMetaStorageSpecs = do (Just m1, Just m2) -> do Isomorphic m1 `shouldBe` Isomorphic meta1 Isomorphic m2 `shouldBe` Isomorphic meta2 - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) (AccountFops walletId (Just accountIx)) Nothing NoFilterOp NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) (AccountFops walletId (Just accountIx)) Nothing NoFilterOp NoFilterOp Nothing True map Isomorphic result `shouldContain` [Isomorphic m1] map Isomorphic result `shouldContain` [Isomorphic m2] count `shouldBe` (Just 2) @@ -401,7 +401,7 @@ txMetaStorageSpecs = do run $ withTemporaryDb $ \hdl -> do let metas = map unSTB testMetasSTB forM_ metas (putTxMeta hdl) - (result, _) <- getTxMetas hdl (Offset 0) (Limit 100) Everything Nothing NoFilterOp NoFilterOp Nothing + (result, _) <- getTxMetas hdl (Offset 0) (Limit 100) Everything Nothing NoFilterOp NoFilterOp Nothing False map Isomorphic result `shouldMatchList` map Isomorphic metas it "pagination correctly limit the results" $ monadicIO $ do @@ -409,7 +409,7 @@ txMetaStorageSpecs = do run $ withTemporaryDb $ \hdl -> do let metas = map unSTB testMetasSTB forM_ metas (putTxMeta hdl) - (result, _) <- getTxMetas hdl (Offset 0) (Limit 5) Everything Nothing NoFilterOp NoFilterOp Nothing + (result, _) <- getTxMetas hdl (Offset 0) (Limit 5) Everything Nothing NoFilterOp NoFilterOp Nothing False length result `shouldBe` 5 it "pagination correctly sorts (ascending) the results" $ monadicIO $ do @@ -417,7 +417,7 @@ txMetaStorageSpecs = do run $ withTemporaryDb $ \hdl -> do let metas = map unSTB testMetasSTB forM_ metas (putTxMeta hdl) - (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp (Just $ Sorting SortByAmount Ascending) + (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp (Just $ Sorting SortByAmount Ascending) False map Isomorphic result `shouldBe` sortByAmount Ascending (map Isomorphic metas) it "pagination correctly sorts (descending) the results" $ monadicIO $ do @@ -425,7 +425,7 @@ txMetaStorageSpecs = do run $ withTemporaryDb $ \hdl -> do let metas = map unSTB testMetasSTB forM_ metas (putTxMeta hdl) - (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp (Just $ Sorting SortByCreationAt Descending) + (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp (Just $ Sorting SortByCreationAt Descending) False map Isomorphic result `shouldBe` sortByCreationAt Descending (map Isomorphic metas) it "implicit sorting is by creation time descenting" $ monadicIO $ do @@ -433,7 +433,7 @@ txMetaStorageSpecs = do run $ withTemporaryDb $ \hdl -> do let metas = map unSTB testMetasSTB forM_ metas (putTxMeta hdl) - (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp Nothing + (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 10) Everything Nothing NoFilterOp NoFilterOp Nothing False map Isomorphic result `shouldBe` sortByCreationAt Descending (map Isomorphic metas) it "metadb counts total Entries properly" $ monadicIO $ do @@ -441,7 +441,7 @@ txMetaStorageSpecs = do run $ withTemporaryDb $ \hdl -> do let metas = map unSTB testMetasSTB forM_ metas (putTxMeta hdl) - (_, total) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing NoFilterOp NoFilterOp Nothing + (_, total) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything Nothing NoFilterOp NoFilterOp Nothing True total `shouldBe` (Just 10) it "filtering walletid works ok" $ monadicIO $ do @@ -452,7 +452,7 @@ txMetaStorageSpecs = do Nothing -> error "txMeta was found with less elements than it should" Just (metasW, accFop, expectedResults) -> do forM_ metasW (putTxMeta hdl) - (result, total) <- (getTxMetas hdl) (Offset 0) (Limit 20) accFop Nothing NoFilterOp NoFilterOp Nothing + (result, total) <- (getTxMetas hdl) (Offset 0) (Limit 20) accFop Nothing NoFilterOp NoFilterOp Nothing True map Isomorphic result `shouldMatchList` map Isomorphic expectedResults total `shouldBe` (Just $ length expectedResults) @@ -464,7 +464,7 @@ txMetaStorageSpecs = do Nothing -> error "txMeta was found with less elements than it should" Just (metasF, accFop, fopTimestamp, expectedResults) -> do forM_ metasF (putTxMeta hdl) - (result, total) <- (getTxMetas hdl) (Offset 0) (Limit 10) accFop Nothing NoFilterOp fopTimestamp Nothing + (result, total) <- (getTxMetas hdl) (Offset 0) (Limit 10) accFop Nothing NoFilterOp fopTimestamp Nothing True map Isomorphic result `shouldMatchList` map Isomorphic expectedResults total `shouldBe` (Just $ length expectedResults) @@ -476,7 +476,7 @@ txMetaStorageSpecs = do Nothing -> expectationFailure "txMeta was found with less elements than it should" Just (metasF, accFop, fopTimestamp, expectedResults) -> do forM_ metasF (putTxMeta hdl) - (result, total) <- (getTxMetas hdl) (Offset 0) (Limit 1) accFop Nothing NoFilterOp fopTimestamp Nothing + (result, total) <- (getTxMetas hdl) (Offset 0) (Limit 1) accFop Nothing NoFilterOp fopTimestamp Nothing True map Isomorphic expectedResults `shouldContain` map Isomorphic result total `shouldBe` (Just $ length expectedResults) @@ -488,7 +488,7 @@ txMetaStorageSpecs = do Nothing -> error "txMeta was found with less elements than it should" Just (addr, m) -> do forM_ metas (putTxMeta hdl) - (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) NoFilterOp NoFilterOp Nothing + (result, _) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) NoFilterOp NoFilterOp Nothing False map Isomorphic result `shouldContain` [Isomorphic m] it "returns meta with the correct address in Inputs or Outputs (SQL union)" $ monadicIO $ do @@ -499,7 +499,7 @@ txMetaStorageSpecs = do Nothing -> error "txMeta was found with less elements than it should" Just (metasA, addr, m1, m2) -> do forM_ metasA (putTxMeta hdl) - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) NoFilterOp NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) NoFilterOp NoFilterOp Nothing True let iso = map Isomorphic result count `shouldSatisfy` (justbeq 2) iso `shouldContain` [Isomorphic m1] @@ -514,7 +514,7 @@ txMetaStorageSpecs = do Just (metasA, addr, m1, m2) -> do -- m2 has addr in both inputs and outputs. forM_ metasA (putTxMeta hdl) - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) NoFilterOp NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) NoFilterOp NoFilterOp Nothing True let iso = map Isomorphic result count `shouldSatisfy` (justbeq 2) iso `shouldContain` [Isomorphic m1] @@ -531,8 +531,8 @@ txMetaStorageSpecs = do Nothing -> expectationFailure "txMeta was found with less elements than it should" Just (metasA, addr, m1, m2) -> do forM_ metasA (putTxMeta hdl) - (result1, count1) <- (getTxMetas hdl) (Offset 0) (Limit 1) Everything (Just addr) NoFilterOp NoFilterOp Nothing - (result2, count2) <- (getTxMetas hdl) (Offset 1) (Limit 4) Everything (Just addr) NoFilterOp NoFilterOp Nothing + (result1, count1) <- (getTxMetas hdl) (Offset 0) (Limit 1) Everything (Just addr) NoFilterOp NoFilterOp Nothing True + (result2, count2) <- (getTxMetas hdl) (Offset 1) (Limit 4) Everything (Just addr) NoFilterOp NoFilterOp Nothing True let result = result1 <> result2 let iso = map Isomorphic result length result1 `shouldBe` 1 @@ -552,7 +552,7 @@ txMetaStorageSpecs = do Just (metasA, addr, m1, _) -> do let txid = _txMetaId m1 forM_ metasA (putTxMeta hdl) - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) (FilterByIndex txid) NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) (FilterByIndex txid) NoFilterOp Nothing True count `shouldBe` (Just 1) -- here it`s exactly one because we filter on TxId. map Isomorphic result `shouldBe` [Isomorphic m1] @@ -565,7 +565,7 @@ txMetaStorageSpecs = do Just (metasA, addr, m1, _) -> do let txid = _txMetaId m1 forM_ metasA (putTxMeta hdl) - (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) (FilterByIndex txid) NoFilterOp Nothing + (result, count) <- (getTxMetas hdl) (Offset 0) (Limit 5) Everything (Just addr) (FilterByIndex txid) NoFilterOp Nothing True count `shouldBe` (Just 1) map Isomorphic result `shouldBe` [Isomorphic m1] @@ -578,8 +578,8 @@ txMetaStorageSpecs = do Nothing -> expectationFailure "txMeta was found with less elements than it should" Just (metasA, addr, m1, m2) -> do forM_ metasA (putTxMeta hdl) - (result1, count1) <- (getTxMetas hdl) (Offset 0) (Limit 1) Everything (Just addr) NoFilterOp NoFilterOp (Just $ Sorting SortByCreationAt Descending) - (result2, count2) <- (getTxMetas hdl) (Offset 1) (Limit 4) Everything (Just addr) NoFilterOp NoFilterOp (Just $ Sorting SortByCreationAt Descending) + (result1, count1) <- (getTxMetas hdl) (Offset 0) (Limit 1) Everything (Just addr) NoFilterOp NoFilterOp (Just $ Sorting SortByCreationAt Descending) True + (result2, count2) <- (getTxMetas hdl) (Offset 1) (Limit 4) Everything (Just addr) NoFilterOp NoFilterOp (Just $ Sorting SortByCreationAt Descending) True let result = filter (\m -> _txMetaId m `elem` map _txMetaId [m1, m2] ) (result1 <> result2) length result1 `shouldBe` 1 length result `shouldBe` 2 @@ -598,8 +598,8 @@ txMetaStorageSpecs = do Nothing -> expectationFailure "txMeta was found with less elements than it should" Just (metasA, addr, m1, m2) -> do forM_ metasA (putTxMeta hdl) - (result1, count1) <- (getTxMetas hdl) (Offset 0) (Limit 1) Everything (Just addr) NoFilterOp NoFilterOp Nothing - (result2, count2) <- (getTxMetas hdl) (Offset 1) (Limit 4) Everything (Just addr) NoFilterOp NoFilterOp Nothing + (result1, count1) <- (getTxMetas hdl) (Offset 0) (Limit 1) Everything (Just addr) NoFilterOp NoFilterOp Nothing True + (result2, count2) <- (getTxMetas hdl) (Offset 1) (Limit 4) Everything (Just addr) NoFilterOp NoFilterOp Nothing True let result = filter (\m -> _txMetaId m `elem` map _txMetaId [m1, m2] ) (result1 <> result2) length result1 `shouldBe` 1 length result `shouldBe` 2 @@ -626,6 +626,7 @@ txMetaStorageSpecs = do (FilterByPredicate Equal _txMetaId) (FilterByPredicate GreaterThanEqual _txMetaCreationAt) (Just $ Sorting SortByCreationAt Descending) + True map Isomorphic result `shouldMatchList` [Isomorphic m] total `shouldBe` (Just 1) @@ -645,6 +646,7 @@ txMetaStorageSpecs = do (FilterByPredicate Equal _txMetaId) (FilterByPredicate GreaterThan _txMetaCreationAt) (Just $ Sorting SortByCreationAt Descending) + True map Isomorphic result `shouldBe` [] total `shouldBe` (Just 0)