Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network.hs listen test slightly improving test coverage #153

Merged
merged 1 commit into from
Apr 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion test/integration/Cardano/Wallet/Network/HttpBridgeSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were so many possibilities. So many things you could do with this Block. And you choose to print it!

I am so disappointed :trollface:


sign :: Tx -> [TxWitness] -> SignedTx
sign tx witnesses = SignedTx . toBS $ encodeSignedTx (tx, witnesses)

Expand Down