Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
daniel.eades
arti
Commits
1e970af0
Commit
1e970af0
authored
Aug 30, 2021
by
daniel.eades
Browse files
fix/silence clippy lints in test modules
parent
9cf1fa36
Pipeline
#12463
passed with stage
in 3 minutes and 40 seconds
Changes
83
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
crates/tor-bytes/src/impls.rs
View file @
1e970af0
...
...
@@ -284,6 +284,7 @@ mod u8_array_impls {
#[cfg(test)]
mod
tests
{
#![allow(clippy::unwrap_used)]
use
crate
::{
Reader
,
Writer
};
use
hex_literal
::
hex
;
macro_rules!
check_encode
{
...
...
@@ -333,7 +334,7 @@ mod tests {
#[test]
fn
roundtrip_u64
()
{
check_roundtrip!
(
u64
,
0x4040111u64
,
[
0
,
0
,
0
,
0
,
4
,
4
,
1
,
17
]);
check_roundtrip!
(
u64
,
0x4040111
_
u64
,
[
0
,
0
,
0
,
0
,
4
,
4
,
1
,
17
]);
}
#[test]
...
...
crates/tor-bytes/src/reader.rs
View file @
1e970af0
...
...
@@ -269,6 +269,7 @@ impl<'a> Reader<'a> {
#[cfg(test)]
mod
tests
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
#[test]
fn
bytecursor_read_ok
()
{
...
...
crates/tor-cell/tests/testvec_chanmsg.rs
View file @
1e970af0
...
...
@@ -352,7 +352,7 @@ fn test_relay() {
// Try converting to/from raw bodies.
let
body
=
[
3_u8
;
509
];
let
cell
=
msg
::
Relay
::
from_raw
(
body
.clone
()
);
let
cell
=
msg
::
Relay
::
from_raw
(
body
);
let
body2
=
cell
.into_relay_body
();
assert_eq!
(
&
body2
[
..
],
&
body
[
..
]);
}
...
...
crates/tor-cell/tests/testvec_relaymsg.rs
View file @
1e970af0
...
...
@@ -21,7 +21,7 @@ fn unhex(s: &str) -> Vec<u8> {
}
fn
decode
(
cmd
:
RelayCmd
,
body
:
&
[
u8
])
->
Result
<
msg
::
RelayMsg
,
BytesError
>
{
let
mut
r
=
tor_bytes
::
Reader
::
from_slice
(
&
body
[
..
]
);
let
mut
r
=
tor_bytes
::
Reader
::
from_slice
(
body
);
msg
::
RelayMsg
::
decode_from_reader
(
cmd
,
&
mut
r
)
}
...
...
crates/tor-cert/src/lib.rs
View file @
1e970af0
...
...
@@ -618,6 +618,7 @@ impl tor_checkable::Timebound<Ed25519Cert> for SigCheckedCert {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
hex_literal
::
hex
;
...
...
crates/tor-chanmgr/src/builder.rs
View file @
1e970af0
...
...
@@ -108,6 +108,7 @@ impl crate::mgr::AbstractChannel for tor_proto::channel::Channel {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::{
mgr
::{
AbstractChannel
,
ChannelFactory
},
...
...
crates/tor-chanmgr/src/mgr.rs
View file @
1e970af0
...
...
@@ -232,6 +232,7 @@ impl<CF: ChannelFactory> AbstractChanMgr<CF> {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::
Error
;
...
...
crates/tor-chanmgr/src/mgr/map.rs
View file @
1e970af0
...
...
@@ -180,6 +180,7 @@ impl<C: AbstractChannel> ChannelMap<C> {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
#[derive(Eq,
PartialEq,
Debug)]
struct
FakeChannel
{
...
...
crates/tor-checkable/src/signed.rs
View file @
1e970af0
...
...
@@ -37,6 +37,7 @@ impl<T> super::SelfSigned<T> for SignatureGated<T> {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::
SelfSigned
;
use
tor_llcrypto
::
pk
::
ValidatableSignature
;
...
...
crates/tor-circmgr/src/build.rs
View file @
1e970af0
...
...
@@ -382,6 +382,7 @@ where
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
futures
::
channel
::
oneshot
;
use
std
::
sync
::
atomic
::{
AtomicU64
,
Ordering
::
SeqCst
};
...
...
@@ -616,8 +617,8 @@ mod test {
let
outcome
=
rt
.wait_for
(
builder
.build_owned
(
p1
,
&
params
,
rng
))
.await
;
let
circ
=
outcome
.unwrap
()
.into_inner
()
.unwrap
();
assert
_eq
!
(
circ
.onehop
,
true
);
assert_eq!
(
circ
.hops
[
..
]
,
[[
0x11
;
32
]
.into
()]);
assert!
(
circ
.onehop
);
assert_eq!
(
circ
.hops
,
[[
0x11
;
32
]
.into
()]);
let
rng
=
StdRng
::
from_rng
(
rand
::
thread_rng
())
.expect
(
"couldn't construct temporary rng"
);
...
...
@@ -625,7 +626,7 @@ mod test {
.wait_for
(
builder
.build_owned
(
p2
.clone
(),
&
params
,
rng
))
.await
;
let
circ
=
outcome
.unwrap
()
.into_inner
()
.unwrap
();
assert
_eq
!
(
circ
.onehop
,
false
);
assert!
(
!
circ
.onehop
);
assert_eq!
(
circ
.hops
[
..
],
[[
0x11
;
32
]
.into
(),
[
0x22
;
32
]
.into
(),
[
0x33
;
32
]
.into
()]
...
...
@@ -634,10 +635,10 @@ mod test {
{
let
mut
h
=
timeouts
.lock
()
.unwrap
();
assert_eq!
(
h
.hist
.len
(),
2
);
assert
_eq
!
(
h
.hist
[
0
]
.0
,
true
);
// completed
assert!
(
h
.hist
[
0
]
.0
);
// completed
assert_eq!
(
h
.hist
[
0
]
.1
,
0
);
// last hop completed
// TODO: test time elapsed, once wait_for is more reliable.
assert
_eq
!
(
h
.hist
[
1
]
.0
,
true
);
// completed
assert!
(
h
.hist
[
1
]
.0
);
// completed
assert_eq!
(
h
.hist
[
1
]
.1
,
2
);
// last hop completed
// TODO: test time elapsed, once wait_for is more reliable.
h
.hist
.clear
();
...
...
@@ -657,7 +658,7 @@ mod test {
{
let
mut
h
=
timeouts
.lock
()
.unwrap
();
assert_eq!
(
h
.hist
.len
(),
1
);
assert
_eq
!
(
h
.hist
[
0
]
.0
,
false
);
assert!
(
!
h
.hist
[
0
]
.0
);
assert_eq!
(
h
.hist
[
0
]
.1
,
2
);
h
.hist
.clear
();
}
...
...
@@ -672,14 +673,14 @@ mod test {
assert!
(
outcome
.is_err
());
// "wait" a while longer to make sure that we eventually
// notice the circuit completing.
for
_
in
0
..
1000u16
{
for
_
in
0
..
1000
_
u16
{
rt
.advance
(
Duration
::
from_millis
(
100
))
.await
;
}
{
let
h
=
timeouts
.lock
()
.unwrap
();
dbg!
(
&
h
.hist
);
// First we notice a circuit timeout after 2 hops
assert
_eq
!
(
h
.hist
[
0
]
.0
,
false
);
assert!
(
!
h
.hist
[
0
]
.0
);
assert_eq!
(
h
.hist
[
0
]
.1
,
2
);
// TODO: check timeout more closely.
assert!
(
h
.hist
[
0
]
.2
<
Duration
::
from_secs
(
100
));
...
...
@@ -690,7 +691,7 @@ mod test {
{
assert_eq!
(
h
.hist
.len
(),
2
);
// Then we notice a circuit completing at its third hop.
assert
_eq
!
(
h
.hist
[
1
]
.0
,
true
);
assert!
(
h
.hist
[
1
]
.0
);
assert_eq!
(
h
.hist
[
1
]
.1
,
2
);
// TODO: check timeout more closely.
assert!
(
h
.hist
[
1
]
.2
<
Duration
::
from_secs
(
100
));
...
...
crates/tor-circmgr/src/lib.rs
View file @
1e970af0
...
...
@@ -316,6 +316,7 @@ async fn continually_expire_circuits<R: Runtime>(runtime: R, circmgr: Weak<CircM
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
#[test]
...
...
@@ -326,7 +327,7 @@ mod test {
let
di
:
DirInfo
<
'_
>
=
(
&
[][
..
])
.into
();
let
p1
=
di
.circ_params
();
assert
_eq
!
(
p1
.extend_by_ed25519_id
()
,
false
);
assert!
(
!
p1
.extend_by_ed25519_id
());
assert_eq!
(
p1
.initial_send_window
(),
1000
);
// Now try with a directory and configured parameters.
...
...
@@ -342,7 +343,7 @@ mod test {
let
di
:
DirInfo
<
'_
>
=
(
&
netdir
)
.into
();
let
p2
=
di
.circ_params
();
assert_eq!
(
p2
.initial_send_window
(),
100
);
assert
_eq
!
(
p2
.extend_by_ed25519_id
()
,
true
);
assert!
(
p2
.extend_by_ed25519_id
());
// Now try with a bogus circwindow value.
let
(
consensus
,
microdescs
)
=
tor_netdir
::
testnet
::
construct_network
()
.unwrap
();
...
...
@@ -357,6 +358,6 @@ mod test {
let
di
:
DirInfo
<
'_
>
=
(
&
netdir
)
.into
();
let
p2
=
di
.circ_params
();
assert_eq!
(
p2
.initial_send_window
(),
1000
);
// Not 100_000
assert
_eq
!
(
p2
.extend_by_ed25519_id
()
,
true
);
assert!
(
p2
.extend_by_ed25519_id
());
}
}
crates/tor-circmgr/src/mgr.rs
View file @
1e970af0
...
...
@@ -1104,6 +1104,7 @@ impl<B: AbstractCircBuilder + 'static, R: Runtime> AbstractCircMgr<B, R> {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::
Error
;
use
std
::
collections
::
BTreeSet
;
...
...
crates/tor-circmgr/src/mgr/streams.rs
View file @
1e970af0
...
...
@@ -115,6 +115,7 @@ where
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
futures_await_test
::
async_test
;
...
...
crates/tor-circmgr/src/path.rs
View file @
1e970af0
...
...
@@ -127,6 +127,7 @@ impl OwnedPath {
/// path.
#[cfg(test)]
fn
assert_same_path_when_owned
(
path
:
&
TorPath
<
'_
>
)
{
#![allow(clippy::unwrap_used)]
use
std
::
convert
::
TryInto
;
use
tor_linkspec
::
ChanTarget
;
let
owned
:
OwnedPath
=
path
.try_into
()
.unwrap
();
...
...
crates/tor-circmgr/src/path/dirpath.rs
View file @
1e970af0
...
...
@@ -47,6 +47,7 @@ impl DirPathBuilder {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::
path
::
assert_same_path_when_owned
;
use
tor_netdir
::
fallback
::
FallbackDir
;
...
...
crates/tor-circmgr/src/path/exitpath.rs
View file @
1e970af0
...
...
@@ -139,6 +139,7 @@ fn relays_can_share_circuit(a: &Relay<'_>, b: &Relay<'_>, subnet_config: &Subnet
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::
path
::{
assert_same_path_when_owned
,
OwnedPath
,
TorPathInner
};
use
std
::
convert
::
TryInto
;
...
...
crates/tor-circmgr/src/timeouts/pareto.rs
View file @
1e970af0
...
...
@@ -655,6 +655,7 @@ impl ParetoEstimatorInner {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
crate
::
timeouts
::
TimeoutEstimator
;
...
...
@@ -671,6 +672,7 @@ mod test {
#[test]
fn
ms_partial_cmp
()
{
#![allow(clippy::eq_op)]
let
myriad
:
MsecDuration
=
10_000
.into
();
let
lakh
:
MsecDuration
=
100_000
.into
();
let
crore
:
MsecDuration
=
10_000_000
.into
();
...
...
crates/tor-circmgr/src/usage.rs
View file @
1e970af0
...
...
@@ -262,6 +262,7 @@ impl crate::mgr::AbstractSpec for SupportedCircUsage {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
tor_netdir
::
testnet
;
...
...
crates/tor-config/src/cmdline.rs
View file @
1e970af0
#![allow(clippy::unwrap_used)]
//! Implement a configuration source based on command-line arguments.
use
config
::{
ConfigError
,
Source
,
Value
};
...
...
@@ -127,6 +128,7 @@ fn tweak_toml_bareword(s: &str) -> Option<String> {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
#[test]
fn
bareword_expansion
()
{
...
...
crates/tor-config/src/lib.rs
View file @
1e970af0
...
...
@@ -104,6 +104,7 @@ pub fn default_config_file() -> Option<PathBuf> {
#[cfg(test)]
mod
test
{
#![allow(clippy::unwrap_used)]
use
super
::
*
;
use
tempfile
::
tempdir
;
...
...
Prev
1
2
3
4
5
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment