Skip to content

Commit

Permalink
Merge #697
Browse files Browse the repository at this point in the history
697: Remove inconsistent `insertedAtTime` lens. r=piotr-iohk a=jonathanknowles

# Issue Number

None.

# Overview

This lens is not quite correct, as the setter updates the slot ID to `(1, 1)` regardless of what time is specified. Using the setter could lead to inconsistency between the slot ID and the time.

Luckily, since we only need the getter functionality, we can remove the lens and replicate the functionality with simple function composition.

Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
  • Loading branch information
iohk-bors[bot] and jonathanknowles committed Sep 11, 2019
2 parents 603edfc + 5323971 commit f52aee8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
13 changes: 0 additions & 13 deletions lib/core-integration/src/Test/Integration/Framework/DSL.hs
Expand Up @@ -57,7 +57,6 @@ module Test.Integration.Framework.DSL
, direction
, feeEstimator
, inputs
, insertedAtTime
, passphraseLastUpdate
, state
, status
Expand Down Expand Up @@ -125,7 +124,6 @@ module Test.Integration.Framework.DSL
import Cardano.Wallet.Api.Types
( AddressAmount
, ApiAddress
, ApiBlockData (..)
, ApiT (..)
, ApiTransaction
, ApiTxInput (..)
Expand All @@ -146,7 +144,6 @@ import Cardano.Wallet.Primitive.Types
, Hash (..)
, HistogramBar (..)
, PoolId (..)
, SlotId (..)
, SortOrder (..)
, TxIn (..)
, TxOut (..)
Expand Down Expand Up @@ -704,16 +701,6 @@ direction =
_set :: HasType (ApiT Direction) s => (s, Direction) -> s
_set (s, v) = set typed (ApiT v) s

insertedAtTime :: HasType (Maybe ApiBlockData) s => Lens' s (Maybe UTCTime)
insertedAtTime =
lens _get _set
where
_get :: HasType (Maybe ApiBlockData) s => s -> (Maybe UTCTime)
_get = fmap (time) . view typed
_set :: HasType (Maybe ApiBlockData) s => (s, (Maybe UTCTime)) -> s
_set (s, v) = set typed (fn <$> v) s
where fn t = ApiBlockData (t) (ApiT (SlotId 1 1))

inputs :: HasType [ApiTxInput t] s => Lens' s [ApiTxInput t]
inputs =
lens _get _set
Expand Down
Expand Up @@ -57,7 +57,6 @@ import Test.Integration.Framework.DSL
, fixtureWallet
, fixtureWalletWith
, getWalletEp
, insertedAtTime
, json
, listAddresses
, listAllTransactions
Expand Down Expand Up @@ -1106,7 +1105,7 @@ spec = do
, replicate 10 2
]
txs <- listAllTransactions ctx w
let [Just t2, Just t1] = map (view insertedAtTime) txs
let [Just t2, Just t1] = fmap (fmap time . insertedAt) txs
let matrix :: [TestCase [ApiTransaction t]] =
[ TestCase -- 1
{ query = toQueryString
Expand Down

0 comments on commit f52aee8

Please sign in to comment.