summaryrefslogtreecommitdiff
path: root/src/rust
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-12 17:24:41 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-12 17:24:41 -0400
commitf8d5fb42a392a764da9f46102583ea2dff960939 (patch)
treed7ccac57b585ddd9f110497a56d6ef203b00c7a7 /src/rust
parent73ba308d3d568eac81da358c4df29fda3f32e921 (diff)
parent4fa46fca8e71e085883dab6183df498759bc439f (diff)
downloadtor-f8d5fb42a392a764da9f46102583ea2dff960939.tar.gz
tor-f8d5fb42a392a764da9f46102583ea2dff960939.zip
Merge branch 'maint-0.3.3' into maint-0.3.4
Diffstat (limited to 'src/rust')
-rw-r--r--src/rust/protover/protoset.rs17
-rw-r--r--src/rust/protover/protover.rs4
-rw-r--r--src/rust/protover/tests/protover.rs14
3 files changed, 17 insertions, 18 deletions
diff --git a/src/rust/protover/protoset.rs b/src/rust/protover/protoset.rs
index 027dfba203..b99e1a99f7 100644
--- a/src/rust/protover/protoset.rs
+++ b/src/rust/protover/protoset.rs
@@ -174,7 +174,7 @@ impl ProtoSet {
if low == u32::MAX || high == u32::MAX {
return Err(ProtoverError::ExceedsMax);
}
- if low < last_high {
+ if low <= last_high {
return Err(ProtoverError::Overlap);
} else if low > high {
return Err(ProtoverError::LowGreaterThanHigh);
@@ -520,7 +520,6 @@ mod test {
test_protoset_contains_versions!(&[1], "1");
test_protoset_contains_versions!(&[1, 2], "1,2");
test_protoset_contains_versions!(&[1, 2, 3], "1-3");
- test_protoset_contains_versions!(&[0, 1], "0-1");
test_protoset_contains_versions!(&[1, 2, 5], "1-2,5");
test_protoset_contains_versions!(&[1, 3, 4, 5], "1,3-5");
test_protoset_contains_versions!(&[42, 55, 56, 57, 58], "42,55-58");
@@ -587,9 +586,9 @@ mod test {
#[test]
fn test_protoset_contains() {
- let protoset: ProtoSet = ProtoSet::from_slice(&[(0, 5), (7, 9), (13, 14)]).unwrap();
+ let protoset: ProtoSet = ProtoSet::from_slice(&[(1, 5), (7, 9), (13, 14)]).unwrap();
- for x in 0..6 { assert!(protoset.contains(&x), format!("should contain {}", x)); }
+ for x in 1..6 { assert!(protoset.contains(&x), format!("should contain {}", x)); }
for x in 7..10 { assert!(protoset.contains(&x), format!("should contain {}", x)); }
for x in 13..15 { assert!(protoset.contains(&x), format!("should contain {}", x)); }
@@ -599,10 +598,10 @@ mod test {
}
#[test]
- fn test_protoset_contains_0_3() {
- let protoset: ProtoSet = ProtoSet::from_slice(&[(0, 3)]).unwrap();
+ fn test_protoset_contains_1_3() {
+ let protoset: ProtoSet = ProtoSet::from_slice(&[(1, 3)]).unwrap();
- for x in 0..4 { assert!(protoset.contains(&x), format!("should contain {}", x)); }
+ for x in 1..4 { assert!(protoset.contains(&x), format!("should contain {}", x)); }
}
macro_rules! assert_protoset_from_vec_contains_all {
@@ -622,8 +621,8 @@ mod test {
}
#[test]
- fn test_protoset_from_vec_0_315() {
- assert_protoset_from_vec_contains_all!(0, 1, 2, 3, 15);
+ fn test_protoset_from_vec_1_315() {
+ assert_protoset_from_vec_contains_all!(1, 2, 3, 15);
}
#[test]
diff --git a/src/rust/protover/protover.rs b/src/rust/protover/protover.rs
index d6ed2739fe..d6a5ad34be 100644
--- a/src/rust/protover/protover.rs
+++ b/src/rust/protover/protover.rs
@@ -852,10 +852,10 @@ mod test {
#[test]
fn test_protoentry_all_supported_unsupported_low_version() {
- let protocols: UnvalidatedProtoEntry = "Cons=0-1".parse().unwrap();
+ let protocols: UnvalidatedProtoEntry = "HSIntro=2-3".parse().unwrap();
let unsupported: Option<UnvalidatedProtoEntry> = protocols.all_supported();
assert_eq!(true, unsupported.is_some());
- assert_eq!("Cons=0", &unsupported.unwrap().to_string());
+ assert_eq!("HSIntro=2", &unsupported.unwrap().to_string());
}
#[test]
diff --git a/src/rust/protover/tests/protover.rs b/src/rust/protover/tests/protover.rs
index 2db01a1634..59a4b5a8a0 100644
--- a/src/rust/protover/tests/protover.rs
+++ b/src/rust/protover/tests/protover.rs
@@ -106,10 +106,10 @@ fn protocol_all_supported_with_unsupported_versions() {
#[test]
fn protocol_all_supported_with_unsupported_low_version() {
- let protocols: UnvalidatedProtoEntry = "Cons=0-1".parse().unwrap();
+ let protocols: UnvalidatedProtoEntry = "HSIntro=2-3".parse().unwrap();
let unsupported: Option<UnvalidatedProtoEntry> = protocols.all_supported();
assert_eq!(true, unsupported.is_some());
- assert_eq!("Cons=0", &unsupported.unwrap().to_string());
+ assert_eq!("HSIntro=2", &unsupported.unwrap().to_string());
}
#[test]
@@ -354,18 +354,18 @@ fn protover_all_supported_should_exclude_some_versions_and_entire_protocols() {
#[test]
fn protover_all_supported_should_not_dos_anyones_computer() {
- let proto: UnvalidatedProtoEntry = "Sleen=0-2147483648".parse().unwrap();
+ let proto: UnvalidatedProtoEntry = "Sleen=1-2147483648".parse().unwrap();
let result: String = proto.all_supported().unwrap().to_string();
- assert_eq!(result, "Sleen=0-2147483648".to_string());
+ assert_eq!(result, "Sleen=1-2147483648".to_string());
}
#[test]
fn protover_all_supported_should_not_dos_anyones_computer_max_versions() {
- let proto: UnvalidatedProtoEntry = "Sleen=0-4294967294".parse().unwrap();
+ let proto: UnvalidatedProtoEntry = "Sleen=1-4294967294".parse().unwrap();
let result: String = proto.all_supported().unwrap().to_string();
- assert_eq!(result, "Sleen=0-4294967294".to_string());
+ assert_eq!(result, "Sleen=1-4294967294".to_string());
}
#[test]
@@ -388,7 +388,7 @@ fn protover_unvalidatedprotoentry_should_err_entirely_unparseable_things() {
#[test]
fn protover_all_supported_over_maximum_limit() {
- let proto: Result<UnvalidatedProtoEntry, ProtoverError> = "Sleen=0-4294967295".parse();
+ let proto: Result<UnvalidatedProtoEntry, ProtoverError> = "Sleen=1-4294967295".parse();
assert_eq!(Err(ProtoverError::ExceedsMax), proto);
}