Skip to content

Commit 91304d1

Browse files
committed
Add missing tx policies
1 parent b2e3db6 commit 91304d1

File tree

1 file changed

+14
-8
lines changed
  • ouroboros-network/sim-tests-lib/Test/Ouroboros/Network/TxSubmission

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,10 @@ prop_receivedTxIds_generator (ArbReceivedTxIds _ someTxsToAck _peeraddr _ps st)
841841
-- by `prop_receivedTxIdsImpl`, `prop_collectTxsImpl` and
842842
-- `prop_makeDecisions_acknowledged`.
843843
--
844-
prop_acknowledgeTxIds :: ArbReceivedTxIds
844+
prop_acknowledgeTxIds :: ArbDecisionContextWithReceivedTxIds
845845
-> Property
846-
prop_acknowledgeTxIds (ArbReceivedTxIds _mempoolHasTxFun _txs _peeraddr ps st) =
847-
case TXS.acknowledgeTxIds undefined st ps of
846+
prop_acknowledgeTxIds (ArbDecisionContextWithReceivedTxIds policy SharedDecisionContext { sdcSharedTxState = st } ps _ _ _) =
847+
case TXS.acknowledgeTxIds policy st ps of
848848
(numTxIdsToAck, _, txs, TXS.RefCountDiff { TXS.txIdsToAck }, ps') ->
849849
counterexample "number of tx ids to ack must agree with RefCountDiff"
850850
( fromIntegral numTxIdsToAck
@@ -877,12 +877,13 @@ prop_acknowledgeTxIds (ArbReceivedTxIds _mempoolHasTxFun _txs _peeraddr ps st) =
877877

878878
-- | Verify that `hasTxIdsToAcknowledge` and `acknowledgeTxIds` are compatible.
879879
--
880+
--
880881
prop_hasTxIdsToAcknowledge
881-
:: ArbReceivedTxIds
882+
:: ArbDecisionContextWithReceivedTxIds
882883
-> Property
883-
prop_hasTxIdsToAcknowledge (ArbReceivedTxIds _mempoolHasTxFun _txs _peeraddr ps st) =
884+
prop_hasTxIdsToAcknowledge (ArbDecisionContextWithReceivedTxIds policy SharedDecisionContext { sdcSharedTxState = st } ps _ _ _) =
884885
case ( TXS.hasTxIdsToAcknowledge st ps
885-
, TXS.acknowledgeTxIds undefined st ps
886+
, TXS.acknowledgeTxIds policy st ps
886887
) of
887888
(canAck, (numTxIdsToAck, _, _, _, _)) ->
888889
canAck === (numTxIdsToAck > 0)
@@ -1612,7 +1613,7 @@ prop_makeDecisions_acknowledged
16121613

16131614
ackFromState :: Map PeerAddr NumTxIdsToAck
16141615
ackFromState =
1615-
Map.map (\ps -> case TXS.acknowledgeTxIds undefined sharedTxState ps of
1616+
Map.map (\ps -> case TXS.acknowledgeTxIds policy sharedTxState ps of
16161617
(a, _, _, _, _) -> a)
16171618
. peerTxStates
16181619
$ sharedTxState
@@ -1666,6 +1667,7 @@ prop_makeDecisions_exhaustive
16661667
data ArbDecisionContextWithReceivedTxIds = ArbDecisionContextWithReceivedTxIds {
16671668
adcrDecisionPolicy :: TxDecisionPolicy,
16681669
adcrSharedContext :: SharedDecisionContext PeerAddr TxId (Tx TxId),
1670+
adcrPeerTxState :: PeerTxState TxId (Tx TxId),
16691671
adcrMempoolHasTx :: Fun TxId Bool,
16701672
adcrTxsToAck :: [Tx TxId],
16711673
-- txids to acknowledge
@@ -1681,13 +1683,14 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
16811683
ArbReceivedTxIds mempoolHasTx
16821684
txIdsToAck
16831685
peeraddr
1684-
_ps
1686+
ps
16851687
st
16861688
<- arbitrary
16871689

16881690
let st' = fixupSharedTxStateForPolicy
16891691
(apply mempoolHasTx)
16901692
policy st
1693+
ps' = fixupPeerTxStateWithPolicy policy ps
16911694
txIdsToAck' = take (fromIntegral (TXS.requestedTxIdsInflight $ peerTxStates st' Map.! peeraddr)) txIdsToAck
16921695
peers = Map.keys (peerTxStates st')
16931696

@@ -1700,6 +1703,7 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
17001703
sdcPeerGSV = Map.fromList gsvs,
17011704
sdcSharedTxState = st'
17021705
},
1706+
adcrPeerTxState = ps',
17031707
adcrMempoolHasTx = mempoolHasTx,
17041708
adcrTxsToAck = txIdsToAck',
17051709
adcrPeerAddr = peeraddr
@@ -1708,6 +1712,7 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
17081712
shrink ArbDecisionContextWithReceivedTxIds {
17091713
adcrDecisionPolicy = policy,
17101714
adcrSharedContext = ctx,
1715+
adcrPeerTxState = ps,
17111716
adcrMempoolHasTx = mempoolHasTx,
17121717
adcrTxsToAck = txIdsToAck,
17131718
adcrPeerAddr = peeraddr
@@ -1716,6 +1721,7 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
17161721
[ ArbDecisionContextWithReceivedTxIds {
17171722
adcrDecisionPolicy = policy',
17181723
adcrSharedContext = ctx',
1724+
adcrPeerTxState = ps,
17191725
adcrMempoolHasTx = mempoolHasTx',
17201726
adcrTxsToAck = txIdsToAck',
17211727
adcrPeerAddr = peeraddr

0 commit comments

Comments
 (0)