@@ -1233,6 +1233,8 @@ mod tests {
12331233 #[ cfg( feature = "quorum_validation" ) ]
12341234 use crate :: hash_types:: QuorumVVecHash ;
12351235 #[ cfg( feature = "quorum_validation" ) ]
1236+ use crate :: sml:: llmq_type:: network:: NetworkLLMQExt ;
1237+ #[ cfg( feature = "quorum_validation" ) ]
12361238 use crate :: transaction:: special_transaction:: quorum_commitment:: QuorumEntry ;
12371239
12381240 #[ cfg( feature = "quorum_validation" ) ]
@@ -1704,6 +1706,9 @@ mod tests {
17041706 . expect ( "expected to apply diff" ) ;
17051707 }
17061708
1709+ let rotation_llmq_type = Network :: Mainnet . isd_llmq_type ( ) ;
1710+ let expected_count = rotation_llmq_type. active_quorum_count ( ) as usize ;
1711+
17071712 masternode_list_engine
17081713 . feed_qr_info :: < fn ( & BlockHash ) -> Result < u32 , ClientDataRetrievalError > > (
17091714 qr_info. clone ( ) ,
@@ -1713,31 +1718,45 @@ mod tests {
17131718 )
17141719 . expect ( "first feed_qr_info should succeed" ) ;
17151720
1716- let cycle_counts_after_first: Vec < ( _ , usize ) > = masternode_list_engine
1717- . rotated_quorums_per_cycle
1718- . iter ( )
1719- . map ( |( k, v) | ( * k, v. len ( ) ) )
1720- . collect ( ) ;
1721+ let snapshot_after_first: BTreeMap < BlockHash , BTreeMap < u16 , QuorumHash > > =
1722+ masternode_list_engine
1723+ . rotated_quorums_per_cycle
1724+ . iter ( )
1725+ . map ( |( k, v) | {
1726+ let index_map =
1727+ v. iter ( ) . map ( |( idx, q) | ( * idx, q. quorum_entry . quorum_hash ) ) . collect ( ) ;
1728+ ( * k, index_map)
1729+ } )
1730+ . collect ( ) ;
17211731
17221732 masternode_list_engine
17231733 . feed_qr_info :: < fn ( & BlockHash ) -> Result < u32 , ClientDataRetrievalError > > (
17241734 qr_info, true , true , None ,
17251735 )
17261736 . expect ( "second feed_qr_info should succeed" ) ;
17271737
1728- let cycle_counts_after_second: Vec < ( _ , usize ) > = masternode_list_engine
1729- . rotated_quorums_per_cycle
1730- . iter ( )
1731- . map ( |( k, v) | ( * k, v. len ( ) ) )
1732- . collect ( ) ;
1738+ let snapshot_after_second: BTreeMap < BlockHash , BTreeMap < u16 , QuorumHash > > =
1739+ masternode_list_engine
1740+ . rotated_quorums_per_cycle
1741+ . iter ( )
1742+ . map ( |( k, v) | {
1743+ let index_map =
1744+ v. iter ( ) . map ( |( idx, q) | ( * idx, q. quorum_entry . quorum_hash ) ) . collect ( ) ;
1745+ ( * k, index_map)
1746+ } )
1747+ . collect ( ) ;
17331748
17341749 assert_eq ! (
1735- cycle_counts_after_first , cycle_counts_after_second ,
1736- "repeated feed_qr_info must not accumulate entries in the cycle map"
1750+ snapshot_after_first , snapshot_after_second ,
1751+ "repeated feed_qr_info must not change the cycle map"
17371752 ) ;
17381753
1739- for ( _cycle_hash, count) in & cycle_counts_after_second {
1740- assert ! ( * count > 0 , "cycle map entry must not be empty after feed" ) ;
1754+ for ( cycle_hash, index_map) in & snapshot_after_second {
1755+ assert_eq ! (
1756+ index_map. len( ) ,
1757+ expected_count,
1758+ "cycle {cycle_hash} must have exactly {expected_count} quorums after feed"
1759+ ) ;
17411760 }
17421761 }
17431762}
0 commit comments