@@ -841,10 +841,10 @@ prop_receivedTxIds_generator (ArbReceivedTxIds _ someTxsToAck _peeraddr _ps st)
841
841
-- by `prop_receivedTxIdsImpl`, `prop_collectTxsImpl` and
842
842
-- `prop_makeDecisions_acknowledged`.
843
843
--
844
- prop_acknowledgeTxIds :: ArbReceivedTxIds
844
+ prop_acknowledgeTxIds :: ArbDecisionContextWithReceivedTxIds
845
845
-> 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
848
848
(numTxIdsToAck, _, txs, TXS. RefCountDiff { TXS. txIdsToAck }, ps') ->
849
849
counterexample " number of tx ids to ack must agree with RefCountDiff"
850
850
( fromIntegral numTxIdsToAck
@@ -877,12 +877,13 @@ prop_acknowledgeTxIds (ArbReceivedTxIds _mempoolHasTxFun _txs _peeraddr ps st) =
877
877
878
878
-- | Verify that `hasTxIdsToAcknowledge` and `acknowledgeTxIds` are compatible.
879
879
--
880
+ --
880
881
prop_hasTxIdsToAcknowledge
881
- :: ArbReceivedTxIds
882
+ :: ArbDecisionContextWithReceivedTxIds
882
883
-> Property
883
- prop_hasTxIdsToAcknowledge (ArbReceivedTxIds _mempoolHasTxFun _txs _peeraddr ps st ) =
884
+ prop_hasTxIdsToAcknowledge (ArbDecisionContextWithReceivedTxIds policy SharedDecisionContext { sdcSharedTxState = st } ps _ _ _ ) =
884
885
case ( TXS. hasTxIdsToAcknowledge st ps
885
- , TXS. acknowledgeTxIds undefined st ps
886
+ , TXS. acknowledgeTxIds policy st ps
886
887
) of
887
888
(canAck, (numTxIdsToAck, _, _, _, _)) ->
888
889
canAck === (numTxIdsToAck > 0 )
@@ -1612,7 +1613,7 @@ prop_makeDecisions_acknowledged
1612
1613
1613
1614
ackFromState :: Map PeerAddr NumTxIdsToAck
1614
1615
ackFromState =
1615
- Map. map (\ ps -> case TXS. acknowledgeTxIds undefined sharedTxState ps of
1616
+ Map. map (\ ps -> case TXS. acknowledgeTxIds policy sharedTxState ps of
1616
1617
(a, _, _, _, _) -> a)
1617
1618
. peerTxStates
1618
1619
$ sharedTxState
@@ -1666,6 +1667,7 @@ prop_makeDecisions_exhaustive
1666
1667
data ArbDecisionContextWithReceivedTxIds = ArbDecisionContextWithReceivedTxIds {
1667
1668
adcrDecisionPolicy :: TxDecisionPolicy ,
1668
1669
adcrSharedContext :: SharedDecisionContext PeerAddr TxId (Tx TxId ),
1670
+ adcrPeerTxState :: PeerTxState TxId (Tx TxId ),
1669
1671
adcrMempoolHasTx :: Fun TxId Bool ,
1670
1672
adcrTxsToAck :: [Tx TxId ],
1671
1673
-- txids to acknowledge
@@ -1681,13 +1683,14 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
1681
1683
ArbReceivedTxIds mempoolHasTx
1682
1684
txIdsToAck
1683
1685
peeraddr
1684
- _ps
1686
+ ps
1685
1687
st
1686
1688
<- arbitrary
1687
1689
1688
1690
let st' = fixupSharedTxStateForPolicy
1689
1691
(apply mempoolHasTx)
1690
1692
policy st
1693
+ ps' = fixupPeerTxStateWithPolicy policy ps
1691
1694
txIdsToAck' = take (fromIntegral (TXS. requestedTxIdsInflight $ peerTxStates st' Map. ! peeraddr)) txIdsToAck
1692
1695
peers = Map. keys (peerTxStates st')
1693
1696
@@ -1700,6 +1703,7 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
1700
1703
sdcPeerGSV = Map. fromList gsvs,
1701
1704
sdcSharedTxState = st'
1702
1705
},
1706
+ adcrPeerTxState = ps',
1703
1707
adcrMempoolHasTx = mempoolHasTx,
1704
1708
adcrTxsToAck = txIdsToAck',
1705
1709
adcrPeerAddr = peeraddr
@@ -1708,6 +1712,7 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
1708
1712
shrink ArbDecisionContextWithReceivedTxIds {
1709
1713
adcrDecisionPolicy = policy,
1710
1714
adcrSharedContext = ctx,
1715
+ adcrPeerTxState = ps,
1711
1716
adcrMempoolHasTx = mempoolHasTx,
1712
1717
adcrTxsToAck = txIdsToAck,
1713
1718
adcrPeerAddr = peeraddr
@@ -1716,6 +1721,7 @@ instance Arbitrary ArbDecisionContextWithReceivedTxIds where
1716
1721
[ ArbDecisionContextWithReceivedTxIds {
1717
1722
adcrDecisionPolicy = policy',
1718
1723
adcrSharedContext = ctx',
1724
+ adcrPeerTxState = ps,
1719
1725
adcrMempoolHasTx = mempoolHasTx',
1720
1726
adcrTxsToAck = txIdsToAck',
1721
1727
adcrPeerAddr = peeraddr
0 commit comments