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

Removed NonP2P code #5007

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions ouroboros-network-framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

### Breaking changes

* `Ouroboros.Network.Subscription` removed.
* `Ouroboros.Network.ErrorPolicy` removed.
* APIs removed from `Ouroboros.Network.Socket`:
* `NetworkMutableState` & friends,
* `withServerNode` and `withServerNode'`,
* `NetworkServerTracers`,
* `fromSnocket`,
* `beginConnection`
* `Ouroboros.Network.Server.Socket` replaced with a simpler server
implementation in `Test.Ouroboros.Network.Server` (in `ouroboros-network:testlib` component).

### Non-breaking changes

## 0.15.0.0 -- 2025-01-02
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-network-framework/demo/connection-manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Protocol.Handshake.Version (Acceptable (..),
Queryable (..))
import Ouroboros.Network.RethrowPolicy
import Ouroboros.Network.Server qualified as Server
import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit (..))
import Ouroboros.Network.Server2 qualified as Server
import Ouroboros.Network.Snocket (Snocket, socketSnocket)
import Ouroboros.Network.Snocket qualified as Snocket
import Ouroboros.Network.Util.ShowProxy
Expand Down
49 changes: 22 additions & 27 deletions ouroboros-network-framework/demo/ping-pong.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ import Text.Printf (printf)

import Network.Mux qualified as Mx

import Ouroboros.Network.ErrorPolicy
import Ouroboros.Network.IOManager
import Ouroboros.Network.Mux
import Ouroboros.Network.Snocket
import Ouroboros.Network.Snocket qualified as Snocket
import Ouroboros.Network.Socket
import Ouroboros.Network.Util.ShowProxy (ShowProxy (..))

import Ouroboros.Network.Protocol.Handshake (HandshakeArguments (..))
import Ouroboros.Network.Protocol.Handshake.Codec
import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Protocol.Handshake.Version
import Test.Ouroboros.Network.Server qualified as Test.Server

import Network.TypedProtocol.PingPong.Client as PingPong
import Network.TypedProtocol.PingPong.Codec.CBOR as PingPong
Expand Down Expand Up @@ -156,24 +157,21 @@ clientPingPong pipelined =
serverPingPong :: IO Void
serverPingPong =
withIOManager $ \iomgr -> do
networkState <- newNetworkMutableState
_ <- async $ cleanNetworkMutableState networkState
withServerNode
Test.Server.with
(Snocket.localSnocket iomgr)
makeLocalBearer
mempty
nullNetworkServerTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
defaultLocalSocketAddr
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
(HandshakeCallbacks acceptableVersion queryVersion)
HandshakeArguments {
haHandshakeTracer = nullTracer,
haHandshakeCodec = unversionedHandshakeCodec,
haVersionDataCodec = unversionedProtocolDataCodec,
haAcceptVersion = acceptableVersion,
haQueryVersion = queryVersion,
haTimeLimits = noTimeLimitsHandshake
}
(unversionedProtocol (SomeResponderApplication app))
nullErrorPolicies
$ \_ serverAsync ->
wait serverAsync -- block until async exception
$ \_ serverAsync -> wait serverAsync -- block until server finishes
where
app :: OuroborosApplicationWithMinimalCtx
Mx.ResponderMode LocalAddress LBS.ByteString IO Void ()
Expand Down Expand Up @@ -251,24 +249,21 @@ clientPingPong2 =
serverPingPong2 :: IO Void
serverPingPong2 =
withIOManager $ \iomgr -> do
networkState <- newNetworkMutableState
_ <- async $ cleanNetworkMutableState networkState
withServerNode
Test.Server.with
(Snocket.localSnocket iomgr)
makeLocalBearer
mempty
nullNetworkServerTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
defaultLocalSocketAddr
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
(HandshakeCallbacks acceptableVersion queryVersion)
HandshakeArguments {
haHandshakeTracer = nullTracer,
haHandshakeCodec = unversionedHandshakeCodec,
haVersionDataCodec = unversionedProtocolDataCodec,
haAcceptVersion = acceptableVersion,
haQueryVersion = queryVersion,
haTimeLimits = noTimeLimitsHandshake
}
(unversionedProtocol (SomeResponderApplication app))
nullErrorPolicies
$ \_ serverAsync ->
wait serverAsync -- block until async exception
$ \_ serverAsync -> wait serverAsync -- block until async exception
where
app :: OuroborosApplicationWithMinimalCtx
Mx.ResponderMode addr LBS.ByteString IO Void ()
Expand Down
8 changes: 3 additions & 5 deletions ouroboros-network-framework/io-tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import Test.Tasty

import Test.Ouroboros.Network.Driver qualified as Driver
import Test.Ouroboros.Network.RawBearer qualified as RawBearer
import Test.Ouroboros.Network.Server2.IO qualified as Server2
import Test.Ouroboros.Network.Server.IO qualified as Server
import Test.Ouroboros.Network.Socket qualified as Socket
import Test.Ouroboros.Network.Subscription qualified as Subscription

main :: IO ()
main = withUtf8 $ defaultMain tests

tests :: TestTree
tests =
testGroup "ouroboros-network-framework:io-tests" $
testGroup "ouroboros-network-framework:io-tests"
[ Driver.tests
, Server2.tests
, Server.tests
, Socket.tests
, Subscription.tests
, RawBearer.tests
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{-# OPTIONS_GHC -Wno-x-partial #-}
#endif

module Test.Ouroboros.Network.Server2.IO (tests) where
module Test.Ouroboros.Network.Server.IO (tests) where

import Control.Monad.Class.MonadThrow
import System.Random (mkStdGen)
Expand All @@ -34,7 +34,7 @@ import Test.Ouroboros.Network.Orphans ()
tests :: TestTree
tests =
testGroup "Ouroboros.Network"
[ testGroup "Server2"
[ testGroup "Server"
[ testProperty "unidirectional IO" prop_unidirectional_IO
, testProperty "bidirectional IO" prop_bidirectional_IO
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import Network.TypedProtocol.ReqResp.Type qualified as ReqResp

import Ouroboros.Network.Context
import Ouroboros.Network.Driver
import Ouroboros.Network.ErrorPolicy
import Ouroboros.Network.IOManager
import Ouroboros.Network.Snocket
import Ouroboros.Network.Socket
Expand All @@ -61,11 +60,13 @@ import Network.Mux.Bearer qualified as Mx
import Network.Mux.Timeout qualified as Mx
import Network.Mux.Types qualified as Mx

import Ouroboros.Network.Protocol.Handshake
import Ouroboros.Network.Protocol.Handshake.Codec
import Ouroboros.Network.Protocol.Handshake.Unversioned
import Ouroboros.Network.Protocol.Handshake.Version

import Test.Ouroboros.Network.Orphans ()
import Test.Ouroboros.Network.Server qualified as Test.Server

import Test.QuickCheck
import Test.Tasty (DependencyType (..), TestTree, after, testGroup)
Expand Down Expand Up @@ -196,7 +197,6 @@ prop_socket_send_recv initiatorAddr responderAddr configureSock f xs =

cv <- newEmptyTMVarIO
sv <- newEmptyTMVarIO
networkState <- newNetworkMutableState

{- The siblingVar is used by the initiator and responder to wait on each other before exiting.
- Without this wait there is a risk that one side will finish first causing the Muxbearer to
Expand Down Expand Up @@ -238,20 +238,21 @@ prop_socket_send_recv initiatorAddr responderAddr configureSock f xs =

let snocket = socketSnocket iomgr
res <-
withServerNode
Test.Server.with
snocket
Mx.makeSocketBearer
((. Just) <$> configureSock)
networkTracers
networkState
(AcceptedConnectionsLimit maxBound maxBound 0)
responderAddr
unversionedHandshakeCodec
noTimeLimitsHandshake
unversionedProtocolDataCodec
(HandshakeCallbacks acceptableVersion queryVersion)
HandshakeArguments {
haHandshakeTracer = nullTracer,
haHandshakeCodec = unversionedHandshakeCodec,
haVersionDataCodec = unversionedProtocolDataCodec,
haAcceptVersion = acceptableVersion,
haQueryVersion = queryVersion,
haTimeLimits = noTimeLimitsHandshake

}
(unversionedProtocol (SomeResponderApplication responderApp))
nullErrorPolicies
$ \_ _ -> do
void $ connectToNode
snocket
Expand All @@ -272,14 +273,6 @@ prop_socket_send_recv initiatorAddr responderAddr configureSock f xs =
return (res == mapAccumL f 0 xs)

where
networkTracers = NetworkServerTracers {
nstMuxTracer = activeMuxTracer,
nstHandshakeTracer = nullTracer,
nstErrorPolicyTracer = showTracing stdoutTracer,
nstAcceptPolicyTracer = nullTracer
}


waitSibling :: StrictTVar IO Int -> IO ()
waitSibling cntVar = do
atomically $ modifyTVar cntVar (\a -> a - 1)
Expand Down
Loading
Loading