@@ -253,7 +253,7 @@ tests =
253253 [ testProperty " no protocol errors"
254254 prop_no_txSubmission_error_iosim
255255 , testProperty " all transactions"
256- unit_txSubmission_allTransactions
256+ prop_txSubmission_allTransactions
257257 , testProperty " inflight coverage"
258258 prop_check_inflight_ratio
259259 ]
@@ -848,16 +848,34 @@ prop_no_txSubmission_error_iosim
848848 = testWithIOSim prop_no_txSubmission_error long_trace
849849
850850
851+ newtype WellSizedTx = WellSizedTx { getTx :: Tx TxId }
852+ deriving Show
853+
854+ fixupWellSizedTx :: Tx TxId -> Tx TxId
855+ fixupWellSizedTx tx@ Tx { getTxSize } = tx { getTxAdvSize = getTxSize }
856+
857+ instance Arbitrary WellSizedTx where
858+ arbitrary = WellSizedTx
859+ . fixupWellSizedTx
860+ <$> arbitrary
861+ shrink = map (WellSizedTx . fixupWellSizedTx)
862+ . shrink
863+ . getTx
864+
865+
851866-- | This test checks that even in a scenario where nodes keep disconnecting,
852867-- but eventually stay online. We manage to get all transactions.
853868--
854- unit_txSubmission_allTransactions :: ArbTxDecisionPolicy
855- -> NonEmptyList (Tx TxId )
856- -> NonEmptyList (Tx TxId )
869+ -- We exclude txs which are not advertise the right size, since they disconnect
870+ -- the nodes, and as a result not all tx-s might transfer.
871+ --
872+ prop_txSubmission_allTransactions :: ArbTxDecisionPolicy
873+ -> NonEmptyList WellSizedTx
874+ -> NonEmptyList WellSizedTx
857875 -> Property
858- unit_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
859- (NonEmpty txsA)
860- (NonEmpty txsB) =
876+ prop_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
877+ (NonEmpty txsA' )
878+ (NonEmpty txsB' ) =
861879 let localRootConfig = LocalRootConfig
862880 DoNotAdvertisePeer
863881 InitiatorAndResponderDiffusionMode
@@ -933,6 +951,9 @@ unit_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
933951 )
934952 500_000 -- ^ Running for 500k might not be enough.
935953 where
954+ txsA = getTx <$> txsA'
955+ txsB = getTx <$> txsB'
956+
936957 -- We need to make sure the transactions are unique, this simplifies
937958 -- things.
938959 --
@@ -982,11 +1003,12 @@ unit_txSubmission_allTransactions (ArbTxDecisionPolicy decisionPolicy)
9821003 (validSortedTxidsA, validSortedTxidsB) =
9831004 let f = sort
9841005 . map (\ Tx {getTxId} -> getTxId)
985- . filter (\ Tx {getTxValid} -> getTxValid)
1006+ . filter (\ Tx {getTxSize, getTxAdvSize, getTxValid} -> getTxSize == getTxAdvSize
1007+ && getTxValid)
9861008 in bimap f f (uniqueTxsA, uniqueTxsB)
9871009
988- in -- counterexample (intercalate "\n" $ map show $ Trace.toList events)
989- counterexample (Trace. ppTrace show (ppSimEvent 0 0 0 ) trace)
1010+ in counterexample (intercalate " \n " $ map show $ Trace. toList events)
1011+ -- counterexample (Trace.ppTrace show (ppSimEvent 0 0 0) trace)
9901012 $ counterexample (" accepted txids map: " ++ show sortedAcceptedTxidsMap)
9911013 $ counterexample (" A: unique txs: " ++ show uniqueTxsA)
9921014 $ counterexample (" A: valid transactions that should be accepted: " ++ show validSortedTxidsA)
0 commit comments