Skip to content

Commit 97ca973

Browse files
committed
Add testnet tx submission test
1 parent f9ddcda commit 97ca973

File tree

4 files changed

+45
-20
lines changed

4 files changed

+45
-20
lines changed

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Node.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import Control.Monad.Class.MonadThrow (MonadEvaluate, MonadMask, MonadThrow,
4141
import Control.Monad.Class.MonadTime.SI (DiffTime, MonadTime)
4242
import Control.Monad.Class.MonadTimer.SI (MonadDelay, MonadTimer)
4343
import Control.Monad.Fix (MonadFix)
44-
import Control.Tracer (Tracer (..), nullTracer)
44+
import Control.Tracer (Tracer (..), contramap, nullTracer)
4545

4646
import Data.Foldable as Foldable (foldl')
4747
import Data.IP (IP (..))
@@ -283,7 +283,7 @@ run blockGeneratorArgs limits ni na tracersExtra tracerBlockFetch =
283283
withAsync (blockFetch nodeKernel) $ \blockFetchLogicThread ->
284284

285285
withAsync (decisionLogicThread
286-
nullTracer
286+
(contramap show $ aDebugTracer na)
287287
(aTxDecisionPolicy na)
288288
(readPeerGSVs (nkFetchClientRegistry nodeKernel))
289289
(nkTxChannelsVar nodeKernel)

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Diffusion/Node/MiniProtocols.hs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -694,21 +694,6 @@ applications debugTracer nodeKernel
694694
channel
695695
(txSubmissionServerPeerPipelined server)
696696

697-
-- aTxSubmission2Server
698-
-- :: NodeToNodeVersion
699-
-- -> ResponderContext addrNTN
700-
-- -> Channel m bTX
701-
-- -> m ((), Maybe bTX)
702-
-- aTxSubmission2Server version ResponderContext { rcConnectionId = them } channel = do
703-
-- labelThisThread "TxSubmissionServer"
704-
-- runPipelinedPeerWithLimits
705-
-- (contramap (TraceLabelPeer them) tTxSubmission2Tracer)
706-
-- (cTxSubmission2Codec (mkCodecs version))
707-
-- blTxSubmission2
708-
-- timeLimitsTxSubmission2
709-
-- channel
710-
-- (txSubmissionServerPeerPipelined (hTxSubmissionServer version them))
711-
712697
--
713698
-- Orphaned Instances
714699
--

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet.hs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import Test.QuickCheck.Monoids
7070
import Test.Tasty
7171
import Test.Tasty.QuickCheck (testProperty)
7272

73-
import Control.Exception (AssertionFailed (..), catch, evaluate)
73+
import Control.Exception (AssertionFailed (..), catch, evaluate, fromException)
7474
import Ouroboros.Network.BlockFetch (FetchMode (..), TraceFetchClientState (..))
7575
import Ouroboros.Network.ConnectionManager.Test.Timeouts (TestProperty (..),
7676
classifyActivityType, classifyEffectiveDataFlow,
@@ -101,6 +101,7 @@ import Control.Monad.Class.MonadTest (exploreRaces)
101101
import Ouroboros.Network.PeerSelection.Bootstrap (requiresBootstrapPeers)
102102
import Ouroboros.Network.PeerSelection.LedgerPeers
103103
import Ouroboros.Network.TxSubmission.Inbound.Policy (defaultTxDecisionPolicy)
104+
import Ouroboros.Network.TxSubmission.Outbound (TxSubmissionProtocolError (..))
104105

105106
tests :: TestTree
106107
tests =
@@ -156,6 +157,10 @@ tests =
156157
(testWithIOSimPOR prop_only_bootstrap_peers_in_fallback_state 10000)
157158
, nightlyTest $ testProperty "no non trustable peers before caught up state"
158159
(testWithIOSimPOR prop_no_non_trustable_peers_before_caught_up_state 10000)
160+
, testGroup "Tx Submission"
161+
[ nightlyTest $ testProperty "no protocol errors"
162+
(testWithIOSimPOR prop_no_txSubmission_error 125000)
163+
]
159164
, testGroup "Churn"
160165
[ nightlyTest $ testProperty "no timeouts"
161166
(testWithIOSimPOR prop_churn_notimeouts 10000)
@@ -221,6 +226,10 @@ tests =
221226
[ testProperty "share a peer"
222227
unit_peer_sharing
223228
]
229+
, testGroup "Tx Submission"
230+
[ testProperty "no protocol errors"
231+
(testWithIOSim prop_no_txSubmission_error 125000)
232+
]
224233
, testGroup "Churn"
225234
[ testProperty "no timeouts"
226235
(testWithIOSim prop_churn_notimeouts 125000)
@@ -418,6 +427,35 @@ prop_inbound_governor_trace_coverage defaultBearerInfo diffScript =
418427
in tabulate "inbound governor trace" eventsSeenNames
419428
True
420429

430+
-- | This test check that we don't have any tx submission protocol error
431+
--
432+
prop_no_txSubmission_error :: SimTrace Void
433+
-> Int
434+
-> Property
435+
prop_no_txSubmission_error ioSimTrace traceNumber =
436+
let events = Trace.toList
437+
. fmap (\(WithTime t (WithName _ b)) -> (t, b))
438+
. withTimeNameTraceEvents
439+
@DiffusionTestTrace
440+
@NtNAddr
441+
. Trace.take traceNumber
442+
$ ioSimTrace
443+
444+
in counterexample (intercalate "\n" $ map show $ events)
445+
$ all (\case
446+
(_, DiffusionInboundGovernorTrace (TrMuxErrored _ err)) ->
447+
case fromException err of
448+
Just ProtocolErrorRequestBlocking -> False
449+
Just ProtocolErrorRequestedNothing -> False
450+
Just ProtocolErrorAckedTooManyTxids -> False
451+
Just (ProtocolErrorRequestedTooManyTxids _ _ _) -> False
452+
Just ProtocolErrorRequestNonBlocking -> False
453+
Just ProtocolErrorRequestedUnavailableTx -> False
454+
_ -> True
455+
_ -> True
456+
)
457+
events
458+
421459
-- | This test coverage of InboundGovernor transitions.
422460
--
423461
prop_inbound_governor_transitions_coverage :: AbsBearerInfo

ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/Testnet/Simulation/Node.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,11 @@ data SimArgs =
161161
}
162162

163163
instance Show SimArgs where
164-
show SimArgs { saSlot, saQuota } =
164+
show SimArgs { saSlot, saQuota, saTxDecisionPolicy } =
165165
unwords [ "SimArgs"
166166
, show saSlot
167167
, show saQuota
168+
, "(" ++ show saTxDecisionPolicy ++ ")"
168169
]
169170

170171
data ServiceDomainName =
@@ -228,7 +229,7 @@ instance Show NodeArgs where
228229
show NodeArgs { naSeed, naDiffusionMode, naMbTime, naBootstrapPeers, naPublicRoots,
229230
naAddr, naPeerSharing, naLocalRootPeers, naLocalSelectionTargets,
230231
naDNSTimeoutScript, naDNSLookupDelayScript, naChainSyncExitOnBlockNo,
231-
naChainSyncEarlyExit, naFetchModeScript } =
232+
naChainSyncEarlyExit, naFetchModeScript, naTxs } =
232233
unwords [ "NodeArgs"
233234
, "(" ++ show naSeed ++ ")"
234235
, show naDiffusionMode
@@ -244,6 +245,7 @@ instance Show NodeArgs where
244245
, "(" ++ show naChainSyncExitOnBlockNo ++ ")"
245246
, show naChainSyncEarlyExit
246247
, show naFetchModeScript
248+
, show naTxs
247249
]
248250

249251
data Command = JoinNetwork DiffTime

0 commit comments

Comments
 (0)