Skip to content

Commit

Permalink
Additional check verifyMetadataSource in SETTINGS_02
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Oct 26, 2020
1 parent b9e06c6 commit 330efae
Showing 1 changed file with 10 additions and 1 deletion.
Expand Up @@ -33,7 +33,7 @@ import Cardano.Wallet.Primitive.AddressDerivation.Icarus
import Cardano.Wallet.Primitive.AddressDerivation.Shelley
( ShelleyKey )
import Cardano.Wallet.Primitive.Types
( Coin (..), PoolMetadataSource, Settings )
( Coin (..), PoolMetadataSource (..), Settings )
import Data.Generics.Internal.VL.Lens
( view )
import Data.Maybe
Expand Down Expand Up @@ -93,14 +93,17 @@ spec = describe "SHELLEY_SETTINGS" $ do
timeout = 120

updateMetadataSource ctx toNone
verifyMetadataSource ctx FetchNone
eventuallyUsingDelay delay timeout "1. There is no metadata" $
getMetadata >>= (`shouldSatisfy` all isNothing)

updateMetadataSource ctx toDirect
verifyMetadataSource ctx FetchDirect
eventuallyUsingDelay delay timeout "2. There is metadata" $
getMetadata >>= (`shouldSatisfy` all isJust)

updateMetadataSource ctx toNone
verifyMetadataSource ctx FetchNone
eventuallyUsingDelay delay timeout "3. There is no metadata" $
getMetadata >>= (`shouldSatisfy` all isNothing)

Expand All @@ -116,6 +119,12 @@ updateMetadataSource ctx t = do
}
} |]

verifyMetadataSource :: Context t -> PoolMetadataSource -> IO ()
verifyMetadataSource ctx s = do
r <- request @(ApiT Settings) ctx Link.getSettings Default Empty
expectResponseCode @IO HTTP.status200 r
expectField (#getApiT . #poolMetadataSource) (`shouldBe` s) r

arbitraryStake :: Maybe Coin
arbitraryStake = Just $ ada 10_000
where ada = Coin . (1000*1000*)

0 comments on commit 330efae

Please sign in to comment.