From 73c6e64bf3483cf368c5435978e11d2f84f75c93 Mon Sep 17 00:00:00 2001 From: Piotr Stachyra Date: Thu, 4 Apr 2019 16:42:22 +0200 Subject: [PATCH] Network.hs listen test slightly improving test coverage --- .../Cardano/Wallet/Network/HttpBridgeSpec.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/integration/Cardano/Wallet/Network/HttpBridgeSpec.hs b/test/integration/Cardano/Wallet/Network/HttpBridgeSpec.hs index 17b4f902ed5..188ed3f22f5 100644 --- a/test/integration/Cardano/Wallet/Network/HttpBridgeSpec.hs +++ b/test/integration/Cardano/Wallet/Network/HttpBridgeSpec.hs @@ -12,7 +12,7 @@ import Cardano.Launcher import Cardano.Wallet.Binary ( TxWitness (..), encodeSignedTx ) import Cardano.Wallet.Network - ( NetworkLayer (..) ) + ( NetworkLayer (..), listen ) import Cardano.Wallet.Network.HttpBridge ( HttpBridgeError (..) ) import Cardano.Wallet.Primitive.Types @@ -38,12 +38,14 @@ import Control.Monad.Trans.Except import Test.Hspec ( Spec , afterAll + , anyException , beforeAll , describe , it , shouldContain , shouldReturn , shouldSatisfy + , shouldThrow ) import qualified Cardano.Wallet.Network.HttpBridge as HttpBridge @@ -102,6 +104,10 @@ spec = do _ -> error (msg res) action `shouldReturn` () + it "listen throws exception when bridge isn't up" $ \network -> do + let action = do + listen network actionDummy + action `shouldThrow` anyException describe "Submitting signed transactions" $ beforeAll startBridge $ afterAll closeBridge $ do @@ -140,6 +146,10 @@ spec = do (show err) `shouldContain` "Transaction failed verification: transaction has more witnesses than inputs" where + actionDummy :: [Block] -> IO () + actionDummy b = do + putStr (show b) + sign :: Tx -> [TxWitness] -> SignedTx sign tx witnesses = SignedTx . toBS $ encodeSignedTx (tx, witnesses)