Skip to content

Commit

Permalink
WIP: Fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Jul 25, 2020
1 parent 0dfd9a5 commit 376376a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/core-integration/src/Test/Integration/Framework/DSL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,10 @@ getSlotParams
getSlotParams ctx = do
r1 <- request @ApiNetworkInformation ctx
Link.getNetworkInfo Default Empty
let (ApiT currentEpoch) = getFromResponse (#networkTip . #epochNumber) r1
let ApiT currentEpoch =
view #epochNumber
$ fromMaybe (error "getSlotParams: tip is Nothing")
$ getFromResponse #networkTip r1

let endpoint = ( "GET", "v2/network/parameters" )
r2 <- request @ApiNetworkParameters ctx endpoint Default Empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import Control.Monad
( when )
import Control.Monad.IO.Class
( liftIO )
import Data.Foldable
( traverse_ )
import Data.Time.Clock
( getCurrentTime )
import Test.Hspec
Expand Down Expand Up @@ -56,8 +58,9 @@ spec = do
r <- request @ApiNetworkInformation ctx
Link.getNetworkInfo Default Empty
expectResponseCode @IO HTTP.status200 r
i <- getFromResponse id r
verify r
[ expectField #nextEpoch ((.> now) . epochStartTime)
[ expectField #nextEpoch (\x -> (epochStartTime <$> x) .> Just now)
, expectField (#syncProgress . #getApiT) (`shouldBe` Ready)
]
return r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@ import Cardano.Wallet.Primitive.Types
( EpochNo (..) )
import Control.Monad
( when )
import Data.Function
( (&) )
import Data.Generics.Internal.VL.Lens
( (^.) )
import Data.Generics.Product.Typed
( typed )
import Data.Maybe
( fromJust )
import Data.Proxy
( Proxy (..) )
import System.Command
Expand Down Expand Up @@ -56,7 +60,7 @@ spec = do
it "CLI_NETWORK - cardano-wallet network information" $ \ctx -> do
info <- getNetworkInfoViaCLI ctx
let nextEpochNum =
info ^. (#nextEpoch . #epochNumber . #getApiT)
(fromJust (info ^. #nextEpoch)) ^. #epochNumber . #getApiT
nextEpochNum `shouldBe` (currentEpochNo info) + 1

it "NETWORK_PARAMS - network parameters" $ \ctx -> do
Expand Down Expand Up @@ -107,4 +111,4 @@ spec = do

currentEpochNo :: ApiNetworkInformation -> EpochNo
currentEpochNo netInfo =
netInfo ^. (#networkTip . #epochNumber . #getApiT)
(fromJust (netInfo ^. #networkTip)) ^. #epochNumber . #getApiT

0 comments on commit 376376a

Please sign in to comment.