Skip to content

Commit

Permalink
Remove ConfTx and ConfSn as we are locally confirming
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Jun 16, 2021
1 parent abe3316 commit c402b2d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
2 changes: 0 additions & 2 deletions hydra-node/src/Hydra/HeadLogic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ deriving instance Tx tx => Show (ClientResponse tx)
data HydraMessage tx
= ReqTx tx
| AckTx Party tx
| ConfTx
| ReqSn SnapshotNumber [tx]
| AckSn Party SnapshotNumber
| ConfSn
| Ping Party
deriving (Eq, Show)

Expand Down
4 changes: 0 additions & 4 deletions hydra-node/src/Hydra/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ instance (ToCBOR tx, ToCBOR (UTxO tx)) => ToCBOR (HydraMessage tx) where
toCBOR = \case
ReqTx tx -> toCBOR ("ReqTx" :: Text) <> toCBOR tx
AckTx party tx -> toCBOR ("AckTx" :: Text) <> toCBOR party <> toCBOR tx
ConfTx -> toCBOR ("ConfTx" :: Text)
ReqSn sn txs -> toCBOR ("ReqSn" :: Text) <> toCBOR sn <> toCBOR txs
AckSn party sn -> toCBOR ("AckSn" :: Text) <> toCBOR party <> toCBOR sn
ConfSn -> toCBOR ("ConfSn" :: Text)
Ping party -> toCBOR ("Ping" :: Text) <> toCBOR party

instance (ToCBOR tx, ToCBOR (UTxO tx)) => ToCBOR (Snapshot tx) where
Expand All @@ -90,10 +88,8 @@ instance (FromCBOR tx, FromCBOR (UTxO tx)) => FromCBOR (HydraMessage tx) where
fromCBOR >>= \case
("ReqTx" :: Text) -> ReqTx <$> fromCBOR
"AckTx" -> AckTx <$> fromCBOR <*> fromCBOR
"ConfTx" -> pure ConfTx
"ReqSn" -> ReqSn <$> fromCBOR <*> fromCBOR
"AckSn" -> AckSn <$> fromCBOR <*> fromCBOR
"ConfSn" -> pure ConfSn
"Ping" -> Ping <$> fromCBOR
msg -> fail $ show msg <> " is not a proper CBOR-encoded HydraMessage"

Expand Down
7 changes: 4 additions & 3 deletions hydra-node/test/Hydra/Network/HeartbeatSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ spec = describe "Heartbeat" $ do
receivedHeartbeats `shouldBe` [Ping 2]

it "stop sending heartbeat message given action sends a message" $ do
let sentHeartbeats = runSimOrThrow $ do
let someMessage = AckSn 1 1
sentHeartbeats = runSimOrThrow $ do
sentMessages <- newTVarIO ([] :: [HydraMessage MockTx])

withHeartbeat 1 (dummyNetwork sentMessages) noop $ \Network{broadcast} -> do
threadDelay 0.6
broadcast ConfSn
broadcast someMessage
threadDelay 1

atomically $ readTVar sentMessages

sentHeartbeats `shouldBe` [ConfSn, Ping 1]
sentHeartbeats `shouldBe` [someMessage, Ping 1]

noop :: Monad m => b -> m ()
noop = const $ pure ()
2 changes: 0 additions & 2 deletions hydra-node/test/Hydra/NetworkSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ instance Arbitrary (HydraMessage MockTx) where
oneof
[ ReqTx <$> arbitrary
, AckTx <$> arbitraryNatural <*> arbitrary
, pure ConfTx
, ReqSn <$> arbitraryNatural <*> arbitrary
, AckSn <$> arbitraryNatural <*> arbitraryNatural
, pure ConfSn
, Ping <$> arbitraryNatural
]

Expand Down

0 comments on commit c402b2d

Please sign in to comment.