@@ -817,18 +817,18 @@ prop_no_txSubmission_error ioSimTrace traceNumber =
817817 . Trace. take traceNumber
818818 $ ioSimTrace
819819
820- in counterexample (intercalate " \n " $ map show $ events)
820+ in counterexample (intercalate " \n " $ map show events)
821821 $ all (\ case
822822 (_, DiffusionInboundGovernorTrace (IG. TrMuxErrored _ err)) ->
823823 case fromException err of
824- Just ProtocolErrorRequestBlocking -> False
825- Just ProtocolErrorRequestedNothing -> False
826- Just ProtocolErrorAckedTooManyTxids -> False
827- Just ( ProtocolErrorRequestedTooManyTxids _ _ _) -> False
828- Just ProtocolErrorRequestNonBlocking -> False
829- Just ProtocolErrorRequestedUnavailableTx -> False
830- _ -> True
831- _ -> True
824+ Just ProtocolErrorRequestBlocking -> False
825+ Just ProtocolErrorRequestedNothing -> False
826+ Just ProtocolErrorAckedTooManyTxids -> False
827+ Just ProtocolErrorRequestedTooManyTxids {} -> False
828+ Just ProtocolErrorRequestNonBlocking -> False
829+ Just ProtocolErrorRequestedUnavailableTx -> False
830+ _ -> True
831+ _ -> True
832832 )
833833 events
834834
@@ -953,10 +953,10 @@ prop_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
953953 -- things.
954954 --
955955 -- TODO: the generator ought to give us unique `TxId`s.
956- uniqueTxsA = map (\ (t, i) -> t { getTxId = List. foldl' (+) 0 (map ord " 0.0.0.0" ) + i })
957- ( zip txsA [0 :: TxId .. ])
958- uniqueTxsB = map (\ (t, i) -> t { getTxId = List. foldl' (+) 0 (map ord " 0.0.0.1" ) + i })
959- ( zip txsB [100 :: TxId .. ])
956+ uniqueTxsA = zipWith (\ t i -> t { getTxId = List. foldl' (+) 0 (map ord " 0.0.0.0" ) + i })
957+ txsA [0 :: TxId .. ]
958+ uniqueTxsB = zipWith (\ t i -> t { getTxId = List. foldl' (+) 0 (map ord " 0.0.0.1" ) + i })
959+ txsB [100 :: TxId .. ]
960960
961961 -- This checks the property that after running the simulation for a while
962962 -- both nodes manage to get all valid transactions.
@@ -1047,18 +1047,17 @@ prop_check_inflight_ratio bi ds@(DiffusionScript simArgs _ _) =
10471047 events :: Events DiffusionTestTrace
10481048 events = Signal. eventsFromList
10491049 . Trace. toList
1050- . fmap ( (\ (WithTime t (WithName _ b)) -> (t, b))
1051- )
1050+ . fmap (\ (WithTime t (WithName _ b)) -> (t, b))
10521051 . withTimeNameTraceEvents
10531052 @ DiffusionTestTrace
10541053 @ NtNAddr
1055- . Trace. take 500000
1054+ . Trace. take 500_000
10561055 $ runSimTrace
1057- $ sim
1056+ sim
10581057
10591058 inflightTxsMap =
10601059 foldr'
1061- (\ (_, m) r -> Map. unionWith ( max ) m r
1060+ (\ (_, m) r -> Map. unionWith max m r
10621061 )
10631062 Map. empty
10641063 $ Signal. eventsToList
@@ -1067,7 +1066,7 @@ prop_check_inflight_ratio bi ds@(DiffusionScript simArgs _ _) =
10671066 DiffusionTxLogic (TraceSharedTxState _ d) -> Just (inflightTxs d)
10681067 _ -> Nothing
10691068 )
1070- $ events
1069+ events
10711070
10721071 txDecisionPolicy = saTxDecisionPolicy simArgs
10731072
@@ -1076,7 +1075,7 @@ prop_check_inflight_ratio bi ds@(DiffusionScript simArgs _ _) =
10761075 ++ show @ (Ratio Int ) (fromIntegral m / fromIntegral (txInflightMultiplicity txDecisionPolicy))
10771076 )
10781077 (Map. elems inflightTxsMap))
1079- $ True
1078+ True
10801079
10811080-- | This test coverage of InboundGovernor transitions.
10821081--
@@ -2028,7 +2027,7 @@ unit_4191 = testWithIOSim prop_diffusion_dns_can_recover long_trace absInfo scri
20282027 , [ JoinNetwork 6.710_144_927_536
20292028 , Kill 7.454_545_454_545
20302029 , JoinNetwork 10.763_157_894_736
2031- , Reconfigure 0.415_384_615_384 [(1 ,1 ,Map. fromList [] )
2030+ , Reconfigure 0.415_384_615_384 [(1 ,1 ,Map. empty )
20322031 , (1 ,1 ,Map. empty)]
20332032 , Reconfigure 15.550_561_797_752 [(1 ,1 ,Map. empty)
20342033 , (1 ,1 ,Map. fromList [(RelayAccessDomain " test2" 15 ,LocalRootConfig DoAdvertisePeer InitiatorAndResponderDiffusionMode IsNotTrustable )])]
@@ -3856,7 +3855,7 @@ prop_unit_4258 =
38563855 (SimArgs 1 10 defaultTxDecisionPolicy)
38573856 (singletonTimedScript Map. empty)
38583857 [( NodeArgs (- 3 ) InitiatorAndResponderDiffusionMode
3859- ( Map. fromList [] )
3858+ Map. empty
38603859 PraosMode
38613860 (Script (UseBootstrapPeers [RelayAccessDomain " bootstrap" 0 ] :| [] ))
38623861 (TestAddress (IPAddr (read " 0.0.0.4" ) 9 ))
@@ -4334,33 +4333,35 @@ unit_peer_sharing =
43344333 . map (\ as -> case as of
43354334 [] -> -- this should be a test failure!
43364335 error " invariant violation: no traces for one of the nodes"
4337- WithName { wnName } : _ -> (wnName, mapMaybe (\ a -> case a of
4336+ WithName { wnName } : _ -> ( wnName
4337+ , mapMaybe (\ a -> case wtEvent (wnEvent a) of
43384338 DiffusionPeerSelectionTrace b -> Just b
43394339 _ -> Nothing )
4340- . map (wtEvent . wnEvent)
4341- $ as))
4340+ as
4341+ )
4342+ )
43424343 $ events'
43434344
43444345 events' = Trace. toList
4345- . splitWithNameTrace
4346- . fmap (\ (WithTime t (WithName name b))
4347- -> WithName name (WithTime t b))
4348- . withTimeNameTraceEvents
4349- @ DiffusionTestTrace
4350- @ NtNAddr
4351- -- We need roughly 1200 because:
4352- -- * first peer sharing request will be issued after
4353- -- `policyPeerSharAcitvationDelay = 300`
4354- -- * this request will not bring any new peers, because non of the peers
4355- -- are yet mature
4356- -- * inbound connections become mature at 900s (15 mins)
4357- -- * next peer share request happens after 900s, e.g. around 1200s.
4358- . Trace. takeWhile (\ se -> case se of
4359- SimEvent {seTime} -> seTime < Time 1250
4360- SimPOREvent {seTime} -> seTime < Time 1250
4361- _ -> False
4362- )
4363- $ runSimTrace sim
4346+ . splitWithNameTrace
4347+ . fmap (\ (WithTime t (WithName name b))
4348+ -> WithName name (WithTime t b))
4349+ . withTimeNameTraceEvents
4350+ @ DiffusionTestTrace
4351+ @ NtNAddr
4352+ -- We need roughly 1200 because:
4353+ -- * first peer sharing request will be issued after
4354+ -- `policyPeerSharAcitvationDelay = 300`
4355+ -- * this request will not bring any new peers, because none of
4356+ -- the peers are yet mature
4357+ -- * inbound connections become mature at 900s (15 mins)
4358+ -- * next peer share request happens after 900s, e.g. around 1200s.
4359+ . Trace. takeWhile (\ se -> case se of
4360+ SimEvent {seTime} -> seTime < Time 1250
4361+ SimPOREvent {seTime} -> seTime < Time 1250
4362+ _ -> False
4363+ )
4364+ $ runSimTrace sim
43644365
43654366 verify :: NtNAddr
43664367 -> [TracePeerSelection extraDebugState extraFlags
@@ -4681,7 +4682,7 @@ splitIntoStreams :: Ord k
46814682 -> [a ]
46824683 -> [[a ]]
46834684splitIntoStreams f = Map. elems
4684- . Map. fromListWith (\ a b -> b ++ a )
4685+ . Map. fromListWith (flip (++) )
46854686 . map (\ a -> (fromJust (f a), [a]))
46864687 . filter (isJust . f)
46874688
@@ -5213,7 +5214,7 @@ toBearerInfo abi =
52135214 biOutboundAttenuation = attenuation (abiOutboundAttenuation abi),
52145215 biInboundWriteFailure = abiInboundWriteFailure abi,
52155216 biOutboundWriteFailure = abiOutboundWriteFailure abi,
5216- biAcceptFailures = ( \ (errDelay, ioErr) -> ( delay errDelay, ioErr)) <$> abiAcceptFailure abi,
5217+ biAcceptFailures = first delay <$> abiAcceptFailure abi,
52175218 biSDUSize = toSduSize (abiSDUSize abi)
52185219 }
52195220
0 commit comments