@@ -70,7 +70,7 @@ import Test.QuickCheck.Monoids
7070import Test.Tasty
7171import Test.Tasty.QuickCheck (testProperty )
7272
73- import Control.Exception (AssertionFailed (.. ), catch , evaluate )
73+ import Control.Exception (AssertionFailed (.. ), catch , evaluate , fromException )
7474import Ouroboros.Network.BlockFetch (FetchMode (.. ), TraceFetchClientState (.. ))
7575import Ouroboros.Network.ConnectionManager.Test.Timeouts (TestProperty (.. ),
7676 classifyActivityType , classifyEffectiveDataFlow ,
@@ -101,6 +101,7 @@ import Control.Monad.Class.MonadTest (exploreRaces)
101101import Ouroboros.Network.PeerSelection.Bootstrap (requiresBootstrapPeers )
102102import Ouroboros.Network.PeerSelection.LedgerPeers
103103import Ouroboros.Network.TxSubmission.Inbound.Policy (defaultTxDecisionPolicy )
104+ import Ouroboros.Network.TxSubmission.Outbound (TxSubmissionProtocolError (.. ))
104105
105106tests :: TestTree
106107tests =
@@ -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--
423461prop_inbound_governor_transitions_coverage :: AbsBearerInfo
0 commit comments