Skip to content

Commit

Permalink
Fix compilation and broadcast to self
Browse files Browse the repository at this point in the history
The end-to-end test is still not passing though as nodes 2 and 3 are not
seeing the tx confirmed
  • Loading branch information
ch1bo committed Jun 7, 2021
1 parent 74a76a2 commit 67fe5b8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
10 changes: 5 additions & 5 deletions hydra-node/exe/hydra-node/Main.hs
Expand Up @@ -7,17 +7,17 @@ import Cardano.Prelude hiding (Option, option)
import Control.Concurrent.STM (newBroadcastTChanIO, writeTChan)
import Hydra.API.Server (runAPIServer)
import Hydra.Chain.ZeroMQ (createMockChainClient)
import qualified Hydra.Ledger.Mock as Ledger
import Hydra.Logging
import Hydra.Logging.Messages (HydraLog (..))
import Hydra.Logging.Monitoring (withMonitoring)
import Hydra.HeadLogic (
Environment (..),
Event (..),
HeadParameters (..),
SnapshotStrategy (..),
createHeadState,
)
import qualified Hydra.Ledger.Mock as Ledger
import Hydra.Logging
import Hydra.Logging.Messages (HydraLog (..))
import Hydra.Logging.Monitoring (withMonitoring)
import Hydra.Network.Ouroboros (withOuroborosHydraNetwork)
import Hydra.Node (
EventQueue (..),
Expand All @@ -35,7 +35,7 @@ main = do
withMonitoring monitoringPort tracer' $ \tracer -> do
let env = Environment nodeId
eq <- createEventQueue
let headState = createHeadState [] (HeadParameters 3) SnapshotStrategy
let headState = createHeadState [] (HeadParameters 3 []) SnapshotStrategy
hh <- createHydraHead headState Ledger.mockLedger
oc <- createMockChainClient eq (contramap MockChain tracer)
withOuroborosHydraNetwork (show host, port) peers (putEvent eq . NetworkEvent) $ \hn -> do
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/src/Hydra/HeadLogic.hs
Expand Up @@ -166,7 +166,7 @@ update ::
Outcome tx
update Environment{party} ledger (HeadState p st) ev = case (st, ev) of
(InitState, ClientEvent (Init parties)) ->
newState p InitState [OnChainEffect (InitTx $ makeAllTokens parties)]
newState (p{parties}) InitState [OnChainEffect (InitTx $ makeAllTokens parties)]
(InitState, OnChainEvent (InitTx tokens)) ->
newState p (CollectingState tokens mempty) [ClientEffect ReadyToCommit]
--
Expand Down
4 changes: 3 additions & 1 deletion hydra-node/src/Hydra/Network/Ouroboros.hs
Expand Up @@ -98,7 +98,9 @@ withOuroborosHydraNetwork localHost remoteHosts networkCallback between = do
race_ (listen iomgr hydraServer) $ do
between $
HydraNetwork
{ broadcast = atomically . writeTChan bchan
{ broadcast = \e -> do
atomically $ writeTChan bchan e
networkCallback (MessageReceived e)
}
where
resolveSockAddr (hostname, port) = do
Expand Down
3 changes: 3 additions & 0 deletions hydra-node/test/Hydra/NetworkSpec.hs
Expand Up @@ -62,6 +62,9 @@ spec = describe "Networking layer" $ do
failAfter 1 $ takeMVar node1received `shouldReturn` MessageReceived requestTx
failAfter 1 $ takeMVar node2received `shouldReturn` MessageReceived requestTx

it "broadcasts messages to itself" $ do
pendingWith "not tested yet"

describe "0MQ Network" $
it "broadcasts messages between 3 connected peers" $ do
pendingWith "missing network callback"
Expand Down
2 changes: 1 addition & 1 deletion local-cluster/test/Test/EndToEndSpec.hs
Expand Up @@ -44,7 +44,7 @@ spec = describe "End-to-end test using a mocked chain though" $ do
-- NOTE(SN): uses MockTx and its UTxO type [MockTx]
waitForResponse 3 [n1, n2, n3] "HeadIsOpen []"
sendRequest n1 "NewTx (ValidTx 42)"
waitForResponse 3 [n1, n2, n3] "TxConfirmed (ValidTx 42)"
waitForResponse 10 [n1, n2, n3] "TxConfirmed (ValidTx 42)"
sendRequest n1 "Close"
waitForResponse 3 [n1] "HeadIsClosed 3s [ValidTx 42]"
waitForResponse (contestationPeriod + 3) [n1] "HeadIsFinalized [ValidTx 42]"
Expand Down

0 comments on commit 67fe5b8

Please sign in to comment.