/ node / bft / tests / components / pending.rs
pending.rs
 1  // Copyright (c) 2025 ADnet Contributors
 2  // This file is part of the AlphaOS library.
 3  
 4  // Licensed under the Apache License, Version 2.0 (the "License");
 5  // you may not use this file except in compliance with the License.
 6  // You may obtain a copy of the License at:
 7  
 8  // http://www.apache.org/licenses/LICENSE-2.0
 9  
10  // Unless required by applicable law or agreed to in writing, software
11  // distributed under the License is distributed on an "AS IS" BASIS,
12  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  // See the License for the specific language governing permissions and
14  // limitations under the License.
15  
16  use crate::common::{CurrentNetwork, primary::new_test_committee, utils::sample_ledger};
17  use alphaos_node_bft::helpers::max_redundant_requests;
18  use alphavm::prelude::{Network, TestRng};
19  
20  #[test]
21  fn test_max_redundant_requests() {
22      let num_nodes: u16 = CurrentNetwork::MAX_CERTIFICATES.first().unwrap().1;
23  
24      // Initialize the RNG.
25      let mut rng = TestRng::default();
26      // Initialize the accounts and the committee.
27      let (accounts, committee) = new_test_committee(num_nodes, &mut rng);
28      // Sample a ledger.
29      let ledger = sample_ledger(&accounts, &committee, &mut rng);
30      // Ensure the maximum number of redundant requests is correct and consistent across iterations.
31      assert_eq!(max_redundant_requests(ledger, 0).unwrap(), 6, "Update me if the formula changes");
32  }