/
Network.hs
43 lines (38 loc) · 1.23 KB
/
Network.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
module Test.Integration.Scenario.API.Byron.Network
( spec
) where
import Prelude
import Cardano.Wallet.Api.Types
( ApiNetworkParameters (..) )
import Data.Quantity
( Quantity (..), mkPercentage )
import Data.Ratio
( (%) )
import Test.Hspec
( SpecWith, describe, it, shouldBe )
import Test.Integration.Framework.DSL
( Context (..)
, Headers (..)
, Payload (..)
, expectField
, expectResponseCode
, request
, verify
)
import qualified Cardano.Wallet.Api.Link as Link
import qualified Network.HTTP.Types.Status as HTTP
spec :: forall t. SpecWith (Context t)
spec = describe "BYRON_NETWORK" $ do
it "NETWORK_PARAMS - Able to fetch network parameters" $ \ctx -> do
r <- request @ApiNetworkParameters ctx Link.getNetworkParams Default Empty
expectResponseCode @IO HTTP.status200 r
let Right d = Quantity <$> mkPercentage (0 % 1)
-- for Byron desiredPoolNumber is 0
let nOpt = 0
verify r
[ expectField (#decentralizationLevel) (`shouldBe` d)
, expectField (#desiredPoolNumber) (`shouldBe` nOpt)]