1
//! Consensus methods
2

            
3
use crate::internal_prelude::*;
4

            
5
mod ip_summary;
6
mod method;
7
mod microdesc;
8
mod tracked_method;
9

            
10
pub use method::*;
11
pub use microdesc::*;
12
pub use tracked_method::*;
13

            
14
/// Supported consensus methods
15
///
16
/// Not guaranteed to be minimal, but guaranteed to be well-formed,
17
/// sorted and non-overlapping.
18
///
19
/// See <https://spec.torproject.org/dir-spec/computing-consensus.html#consensus-method-list>
20
/// for where these values come from.
21
///
22
/// In tor-dirauth, we use literal numeric constants for consensus method values,
23
/// rather than trying to give each consensus method a named `const`.
24
pub const SUPPORTED_METHODS: &[RangeInclusive<ConsensusMethod>] = {
25
    use ConsensusMethod as M;
26
    &[
27
        // This list is where the set of supported methods is defined.
28
        // Only values listed here can be made into a `SupportedConsensusMethod`.
29
        //
30
        M(100)..=M(100),
31
    ]
32
};
33

            
34
#[cfg(test)]
35
mod test {
36
    // @@ begin test lint list maintained by maint/add_warning @@
37
    #![allow(clippy::bool_assert_comparison)]
38
    #![allow(clippy::clone_on_copy)]
39
    #![allow(clippy::dbg_macro)]
40
    #![allow(clippy::mixed_attributes_style)]
41
    #![allow(clippy::print_stderr)]
42
    #![allow(clippy::print_stdout)]
43
    #![allow(clippy::single_char_pattern)]
44
    #![allow(clippy::unwrap_used)]
45
    #![allow(clippy::unchecked_time_subtraction)]
46
    #![allow(clippy::useless_vec)]
47
    #![allow(clippy::needless_pass_by_value)]
48
    #![allow(clippy::string_slice)] // See arti#2571
49
    //! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
50
    use super::*;
51

            
52
    #[test]
53
    fn supported_well_formed() {
54
        for r in SUPPORTED_METHODS {
55
            assert!(r.start() <= r.end());
56
        }
57
        for pair in SUPPORTED_METHODS.windows(2) {
58
            assert!(pair[0].end() < pair[1].start());
59
        }
60
    }
61
}