tor-proto: Use tor-rtcompat macros for testing, not tokio.

Closes #222.
This commit is contained in:
Nick Mathewson 2021-11-15 12:55:08 -05:00
parent 787a995458
commit f92ad644c9
7 changed files with 758 additions and 680 deletions

1
Cargo.lock generated
View File

@ -2842,6 +2842,7 @@ dependencies = [
"tor-linkspec",
"tor-llcrypto",
"tor-protover",
"tor-rtcompat",
"tracing",
"typenum",
"zeroize",

View File

@ -50,6 +50,6 @@ tokio-util = { version = "0.6", features = ["compat"], optional = true }
coarsetime = { version = "0.1.20", optional = true }
[dev-dependencies]
tokio-crate = { package = "tokio", version = "1.7.0", features = ["macros", "rt", "time"] }
tor-rtcompat = { path="../tor-rtcompat", version = "0.0.1", features = ["tokio"] }
hex-literal = "0.3.1"
hex = "0.4.3"

View File

@ -397,8 +397,6 @@ pub(crate) mod test {
use super::*;
use crate::channel::codec::test::MsgBuf;
pub(crate) use crate::channel::reactor::test::new_reactor;
use tokio_crate as tokio;
use tokio_crate::test as async_test;
use tor_cell::chancell::{msg, ChanCell};
/// Make a new fake reactor-less channel. For testing only, obviously.
@ -414,8 +412,9 @@ pub(crate) mod test {
}
}
#[async_test]
async fn send_bad() {
#[test]
fn send_bad() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
let chan = fake_channel();
let cell = ChanCell::new(7.into(), msg::Created2::new(&b"hihi"[..]).into());
@ -439,6 +438,7 @@ pub(crate) mod test {
// FIXME(eta): more difficult to test that sending works now that it has to go via reactor
// let got = output.next().await.unwrap();
// assert!(matches!(got.msg(), ChanMsg::Create2(_)));
})
}
#[test]

View File

@ -47,8 +47,6 @@ pub(crate) mod test {
use futures::task::{Context, Poll};
use hex_literal::hex;
use std::pin::Pin;
use tokio::test as async_test;
use tokio_crate as tokio;
use super::{futures_codec, ChannelCodec};
use tor_cell::chancell::{msg, ChanCell, ChanCmd, CircId};
@ -111,31 +109,37 @@ pub(crate) mod test {
futures_codec::Framed::new(mbuf, ChannelCodec::new(4))
}
#[async_test]
async fn check_encoding() -> std::result::Result<(), tor_cell::Error> {
#[test]
fn check_encoding() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
let mb = MsgBuf::new(&b""[..]);
let mut framed = frame_buf(mb);
let destroycell = msg::Destroy::new(2.into());
framed
.send(ChanCell::new(7.into(), destroycell.into()))
.await?;
.await
.unwrap();
let nocerts = msg::Certs::new_empty();
framed.send(ChanCell::new(0.into(), nocerts.into())).await?;
framed
.send(ChanCell::new(0.into(), nocerts.into()))
.await
.unwrap();
framed.flush().await?;
framed.flush().await.unwrap();
let data = framed.into_inner().into_response();
assert_eq!(&data[0..10], &hex!("00000007 04 0200000000")[..]);
assert_eq!(&data[514..], &hex!("00000000 81 0001 00")[..]);
Ok(())
});
}
#[async_test]
async fn check_decoding() -> std::result::Result<(), tor_cell::Error> {
#[test]
fn check_decoding() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
let mut dat = Vec::new();
dat.extend_from_slice(&hex!("00000007 04 0200000000")[..]);
dat.resize(514, 0);
@ -143,8 +147,8 @@ pub(crate) mod test {
let mb = MsgBuf::new(&dat[..]);
let mut framed = frame_buf(mb);
let destroy = framed.next().await.unwrap()?;
let nocerts = framed.next().await.unwrap()?;
let destroy = framed.next().await.unwrap().unwrap();
let nocerts = framed.next().await.unwrap().unwrap();
assert_eq!(destroy.circid(), CircId::from(7));
assert_eq!(destroy.msg().cmd(), ChanCmd::DESTROY);
@ -152,7 +156,6 @@ pub(crate) mod test {
assert_eq!(nocerts.msg().cmd(), ChanCmd::CERTS);
assert!(framed.into_inner().all_consumed());
Ok(())
});
}
}

View File

@ -421,8 +421,6 @@ pub(super) mod test {
#![allow(clippy::unwrap_used)]
use hex_literal::hex;
use std::time::{Duration, SystemTime};
use tokio::test as async_test;
use tokio_crate as tokio;
use super::*;
use crate::channel::codec::test::MsgBuf;
@ -456,8 +454,9 @@ pub(super) mod test {
add_padded(buf, NETINFO_PREFIX);
}
#[async_test]
async fn connect_ok() -> Result<()> {
#[test]
fn connect_ok() -> Result<()> {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let mut buf = Vec::new();
// versions cell
buf.extend_from_slice(VERSIONS);
@ -484,6 +483,7 @@ pub(super) mod test {
let _unverified = handshake.connect().await?;
Ok(())
})
}
async fn connect_err<T: Into<Vec<u8>>>(input: T) -> Error {
@ -492,8 +492,9 @@ pub(super) mod test {
handshake.connect().await.err().unwrap()
}
#[async_test]
async fn connect_badver() {
#[test]
fn connect_badver() {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let err = connect_err(&b"HTTP://"[..]).await;
assert!(matches!(err, Error::ChanProto(_)));
assert_eq!(
@ -507,10 +508,12 @@ pub(super) mod test {
format!("{}", err),
"channel protocol violation: No shared link protocols"
);
})
}
#[async_test]
async fn connect_cellparse() {
#[test]
fn connect_cellparse() {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let mut buf = Vec::new();
buf.extend_from_slice(VERSIONS);
// Here's a certs cell that will fail.
@ -520,10 +523,12 @@ pub(super) mod test {
err,
Error::CellErr(tor_cell::Error::BytesErr(tor_bytes::Error::Truncated))
));
})
}
#[async_test]
async fn connect_duplicates() {
#[test]
fn connect_duplicates() {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let mut buf = Vec::new();
buf.extend_from_slice(VERSIONS);
buf.extend_from_slice(NOCERTS);
@ -548,10 +553,12 @@ pub(super) mod test {
format!("{}", err),
"channel protocol violation: Duplicate authchallenge cell"
);
})
}
#[async_test]
async fn connect_missing_certs() {
#[test]
fn connect_missing_certs() {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let mut buf = Vec::new();
buf.extend_from_slice(VERSIONS);
add_netinfo(&mut buf);
@ -561,10 +568,12 @@ pub(super) mod test {
format!("{}", err),
"channel protocol violation: Missing certs cell"
);
})
}
#[async_test]
async fn connect_misplaced_cell() {
#[test]
fn connect_misplaced_cell() {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let mut buf = Vec::new();
buf.extend_from_slice(VERSIONS);
// here's a create cell.
@ -575,6 +584,7 @@ pub(super) mod test {
format!("{}", err),
"channel protocol violation: Unexpected cell type CREATE"
);
})
}
fn make_unverified(certs: msg::Certs) -> UnverifiedChannel<MsgBuf> {
@ -823,8 +833,9 @@ pub(super) mod test {
pub(crate) const PEER_RSA: &[u8] = &hex!("2f1fb49bb332a9eec617e41e911c33fb3890aef3");
}
#[async_test]
async fn test_finish() {
#[test]
fn test_finish() {
tor_rtcompat::test_with_one_runtime!(|_rt| async move {
let ed25519_id = [3_u8; 32].into();
let rsa_id = [4_u8; 20].into();
let peer_addr = "127.1.1.2:443".parse().unwrap();
@ -840,5 +851,6 @@ pub(super) mod test {
let (_chan, _reactor) = ver.finish().await.unwrap();
// TODO: check contents of netinfo cell
})
}
}

View File

@ -393,13 +393,10 @@ impl Reactor {
pub(crate) mod test {
#![allow(clippy::unwrap_used)]
use super::*;
use crate::circuit::CircParameters;
use futures::sink::SinkExt;
use futures::stream::StreamExt;
use tokio::test as async_test;
use tokio_crate as tokio;
use tokio_crate::runtime::Handle;
use crate::circuit::CircParameters;
use futures::task::SpawnExt;
type CodecResult = std::result::Result<ChanCell, tor_cell::Error>;
@ -431,19 +428,23 @@ pub(crate) mod test {
}
// Try shutdown from inside run_once..
#[async_test]
async fn shutdown() {
#[test]
fn shutdown() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
let (chan, mut reactor, _output, _input) = new_reactor();
chan.terminate();
let r = reactor.run_once().await;
assert!(matches!(r, Err(ReactorError::Shutdown)));
})
}
// Try shutdown while reactor is running.
#[async_test]
async fn shutdown2() {
#[test]
fn shutdown2() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
// TODO: Ask a rust person if this is how to do this.
use futures::future::FutureExt;
use futures::join;
@ -463,15 +464,20 @@ pub(crate) mod test {
// Now let's see. The reactor should not _still_ be running.
assert!(rr_s);
})
}
#[async_test]
async fn new_circ_closed() {
#[test]
fn new_circ_closed() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let (chan, mut reactor, mut output, _input) = new_reactor();
let (ret, reac) = futures::join!(chan.new_circ(), reactor.run_once());
let (pending, circr) = ret.unwrap();
Handle::current().spawn(circr.run());
rt.spawn(async {
let _ignore = circr.run().await;
})
.unwrap();
assert!(reac.is_ok());
let id = pending.peek_circid();
@ -488,17 +494,22 @@ pub(crate) mod test {
let cell = output.next().await.unwrap();
assert_eq!(cell.circid(), id);
assert!(matches!(cell.msg(), ChanMsg::Destroy(_)));
})
}
// Test proper delivery of a created cell that doesn't make a channel
#[async_test]
async fn new_circ_create_failure() {
#[test]
fn new_circ_create_failure() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
use tor_cell::chancell::msg;
let (chan, mut reactor, mut output, mut input) = new_reactor();
let (ret, reac) = futures::join!(chan.new_circ(), reactor.run_once());
let (pending, circr) = ret.unwrap();
Handle::current().spawn(circr.run());
rt.spawn(async {
let _ignore = circr.run().await;
})
.unwrap();
assert!(reac.is_ok());
let circparams = CircParameters::default();
@ -532,11 +543,13 @@ pub(crate) mod test {
reactor.run_once().await.unwrap();
let ent = reactor.circs.get_mut(id);
assert!(matches!(ent, Some(CircEnt::DestroySent(_))));
})
}
// Try incoming cells that shouldn't arrive on channels.
#[async_test]
async fn bad_cells() {
#[test]
fn bad_cells() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
use tor_cell::chancell::msg;
let (_chan, mut reactor, _output, mut input) = new_reactor();
@ -601,10 +614,12 @@ pub(crate) mod test {
format!("{}", e),
"channel protocol violation: CREATED cell received, but we never send CREATEs"
);
})
}
#[async_test]
async fn deliver_relay() {
#[test]
fn deliver_relay() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
use crate::circuit::celltypes::ClientCircChanMsg;
use futures::channel::oneshot;
use tor_cell::chancell::msg;
@ -682,10 +697,12 @@ pub(crate) mod test {
format!("{}", e),
"channel protocol violation: Too many cells received on destroyed circuit"
);
})
}
#[async_test]
async fn deliver_destroy() {
#[test]
fn deliver_destroy() {
tor_rtcompat::test_with_all_runtimes!(|_rt| async move {
use crate::circuit::celltypes::*;
use futures::channel::oneshot;
use tor_cell::chancell::msg;
@ -744,5 +761,6 @@ pub(crate) mod test {
format!("{}", e),
"channel protocol violation: Destroy for nonexistent circuit"
);
})
}
}

View File

@ -614,15 +614,14 @@ mod test {
use futures::io::{AsyncReadExt, AsyncWriteExt};
use futures::sink::SinkExt;
use futures::stream::StreamExt;
use futures::task::SpawnExt;
use hex_literal::hex;
use rand::thread_rng;
use std::time::Duration;
use tokio::runtime::Handle;
use tokio_crate as tokio;
use tokio_crate::test as async_test;
use tor_cell::chancell::{msg as chanmsg, ChanCell};
use tor_cell::relaycell::{msg as relaymsg, RelayCell, StreamId};
use tor_llcrypto::pk;
use tor_rtcompat::{Runtime, SleepProvider};
use tracing::trace;
fn rmsg_to_ccmsg<ID>(id: ID, msg: relaymsg::RelayMsg) -> ClientCircChanMsg
@ -680,23 +679,28 @@ mod test {
)
}
fn working_fake_channel() -> (
fn working_fake_channel<R: Runtime>(
rt: &R,
) -> (
Channel,
Receiver<ChanCell>,
Sender<std::result::Result<ChanCell, tor_cell::Error>>,
) {
let (channel, chan_reactor, rx, tx) = new_reactor();
Handle::current().spawn(chan_reactor.run());
rt.spawn(async {
let _ignore = chan_reactor.run().await;
})
.unwrap();
(channel, rx, tx)
}
async fn test_create(fast: bool) {
async fn test_create<R: Runtime>(rt: &R, fast: bool) {
// We want to try progressing from a pending circuit to a circuit
// via a crate_fast handshake.
use crate::crypto::handshake::{fast::CreateFastServer, ntor::NtorServer, ServerHandshake};
let (chan, mut rx, _sink) = working_fake_channel();
let (chan, mut rx, _sink) = working_fake_channel(rt);
let circid = 128.into();
let (created_send, created_recv) = oneshot::channel();
let (_circmsg_send, circmsg_recv) = mpsc::channel(64);
@ -705,7 +709,10 @@ mod test {
let (pending, reactor) =
PendingClientCirc::new(circid, chan, created_recv, circmsg_recv, unique_id);
Handle::current().spawn(reactor.run());
rt.spawn(async {
let _ignore = reactor.run().await;
})
.unwrap();
// Future to pretend to be a relay on the other end of the circuit.
let simulate_relay_fut = async move {
@ -756,13 +763,17 @@ mod test {
*/
}
#[async_test]
async fn test_create_fast() {
test_create(true).await
#[test]
fn test_create_fast() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
test_create(&rt, true).await;
})
}
#[async_test]
async fn test_create_ntor() {
test_create(false).await
#[test]
fn test_create_ntor() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
test_create(&rt, false).await;
})
}
// An encryption layer that doesn't do any crypto. Can be used
@ -811,7 +822,8 @@ mod test {
// Helper: set up a 3-hop circuit with no encryption, where the
// next inbound message seems to come from hop next_msg_from
async fn newcirc_ext(
async fn newcirc_ext<R: Runtime>(
rt: &R,
chan: Channel,
next_msg_from: HopNum,
) -> (ClientCirc, mpsc::Sender<ClientCircChanMsg>) {
@ -823,7 +835,10 @@ mod test {
let (pending, reactor) =
PendingClientCirc::new(circid, chan, created_recv, circmsg_recv, unique_id);
Handle::current().spawn(reactor.run());
rt.spawn(async {
let _ignore = reactor.run().await;
})
.unwrap();
let PendingClientCirc {
circ,
@ -850,15 +865,19 @@ mod test {
// Helper: set up a 3-hop circuit with no encryption, where the
// next inbound message seems to come from hop next_msg_from
async fn newcirc(chan: Channel) -> (ClientCirc, mpsc::Sender<ClientCircChanMsg>) {
newcirc_ext(chan, 2.into()).await
async fn newcirc<R: Runtime>(
rt: &R,
chan: Channel,
) -> (ClientCirc, mpsc::Sender<ClientCircChanMsg>) {
newcirc_ext(rt, chan, 2.into()).await
}
// Try sending a cell via send_relay_cell
#[async_test]
async fn send_simple() {
let (chan, mut rx, _sink) = working_fake_channel();
let (circ, _send) = newcirc(chan).await;
#[test]
fn send_simple() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let (chan, mut rx, _sink) = working_fake_channel(&rt);
let (circ, _send) = newcirc(&rt, chan).await;
let begindir = RelayCell::new(0.into(), RelayMsg::BeginDir);
circ.control
.unbounded_send(CtrlMsg::SendRelayCell {
@ -877,6 +896,7 @@ mod test {
_ => panic!(),
};
assert!(matches!(m.msg(), RelayMsg::BeginDir));
})
}
// NOTE(eta): this test is commented out because it basically tested implementation details
@ -945,12 +965,13 @@ mod test {
}
*/
#[async_test]
async fn extend() {
#[test]
fn extend() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
use crate::crypto::handshake::{ntor::NtorServer, ServerHandshake};
let (chan, mut rx, _sink) = working_fake_channel();
let (circ, mut sink) = newcirc(chan).await;
let (chan, mut rx, _sink) = working_fake_channel(&rt);
let (circ, mut sink) = newcirc(&rt, chan).await;
let params = CircParameters::default();
let extend_fut = async move {
@ -983,11 +1004,16 @@ mod test {
// Did we really add another hop?
assert_eq!(circ.n_hops(), 4);
})
}
async fn bad_extend_test_impl(reply_hop: HopNum, bad_reply: ClientCircChanMsg) -> Error {
let (chan, _rx, _sink) = working_fake_channel();
let (circ, mut sink) = newcirc_ext(chan, reply_hop).await;
async fn bad_extend_test_impl<R: Runtime>(
rt: &R,
reply_hop: HopNum,
bad_reply: ClientCircChanMsg,
) -> Error {
let (chan, _rx, _sink) = working_fake_channel(rt);
let (circ, mut sink) = newcirc_ext(rt, chan, reply_hop).await;
let params = CircParameters::default();
let extend_fut = async move {
@ -1006,12 +1032,13 @@ mod test {
outcome.unwrap_err()
}
#[async_test]
async fn bad_extend_wronghop() {
#[test]
fn bad_extend_wronghop() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let extended2 = relaymsg::Extended2::new(vec![]).into();
let cc = rmsg_to_ccmsg(0, extended2);
let error = bad_extend_test_impl(1.into(), cc).await;
let error = bad_extend_test_impl(&rt, 1.into(), cc).await;
// This case shows up as a CircDestroy, since a message sent
// from the wrong hop won't even be delivered to the extend
// code's meta-handler. Instead the unexpected message will cause
@ -1020,44 +1047,52 @@ mod test {
Error::CircuitClosed => {}
x => panic!("got other error: {}", x),
}
})
}
#[async_test]
async fn bad_extend_wrongtype() {
#[test]
fn bad_extend_wrongtype() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let extended = relaymsg::Extended::new(vec![7; 200]).into();
let cc = rmsg_to_ccmsg(0, extended);
let error = bad_extend_test_impl(2.into(), cc).await;
let error = bad_extend_test_impl(&rt, 2.into(), cc).await;
match error {
Error::CircProto(s) => {
assert_eq!(s, "wanted EXTENDED2; got EXTENDED")
}
_ => panic!(),
}
})
}
#[async_test]
async fn bad_extend_destroy() {
#[test]
fn bad_extend_destroy() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let cc = ClientCircChanMsg::Destroy(chanmsg::Destroy::new(4.into()));
let error = bad_extend_test_impl(2.into(), cc).await;
let error = bad_extend_test_impl(&rt, 2.into(), cc).await;
match error {
Error::CircuitClosed => {}
_ => panic!(),
}
})
}
#[async_test]
async fn bad_extend_crypto() {
#[test]
fn bad_extend_crypto() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let extended2 = relaymsg::Extended2::new(vec![99; 256]).into();
let cc = rmsg_to_ccmsg(0, extended2);
let error = bad_extend_test_impl(2.into(), cc).await;
let error = bad_extend_test_impl(&rt, 2.into(), cc).await;
assert!(matches!(error, Error::BadHandshake));
})
}
#[async_test]
async fn begindir() {
let (chan, mut rx, _sink) = working_fake_channel();
let (circ, mut sink) = newcirc(chan).await;
#[test]
fn begindir() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let (chan, mut rx, _sink) = working_fake_channel(&rt);
let (circ, mut sink) = newcirc(&rt, chan).await;
let begin_and_send_fut = async move {
// Here we'll say we've got a circuit, and we want to
@ -1117,10 +1152,12 @@ mod test {
};
let (_stream, _) = futures::join!(begin_and_send_fut, reply_fut);
});
}
// Set up a circuit and stream that expects some incoming SENDMEs.
async fn setup_incoming_sendme_case(
async fn setup_incoming_sendme_case<R: Runtime>(
rt: &R,
n_to_send: usize,
) -> (
ClientCirc,
@ -1131,8 +1168,8 @@ mod test {
Receiver<ChanCell>,
Sender<std::result::Result<ChanCell, tor_cell::Error>>,
) {
let (chan, mut rx, sink2) = working_fake_channel();
let (circ, mut sink) = newcirc(chan).await;
let (chan, mut rx, sink2) = working_fake_channel(rt);
let (circ, mut sink) = newcirc(rt, chan).await;
let circ_clone = Arc::new(circ.clone());
let begin_and_send_fut = async move {
@ -1195,10 +1232,11 @@ mod test {
(circ, stream, sink, streamid, cells_received, rx, sink2)
}
#[async_test]
async fn accept_valid_sendme() {
#[test]
fn accept_valid_sendme() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
let (circ, _stream, mut sink, streamid, cells_received, _rx, _sink2) =
setup_incoming_sendme_case(300 * 498 + 3).await;
setup_incoming_sendme_case(&rt, 300 * 498 + 3).await;
assert_eq!(cells_received, 301);
@ -1225,7 +1263,8 @@ mod test {
let reply_with_sendme_fut = async move {
// make and send a circuit-level sendme.
let c_sendme =
relaymsg::Sendme::new_tag(hex!("6400000000000000000000000000000000000000")).into();
relaymsg::Sendme::new_tag(hex!("6400000000000000000000000000000000000000"))
.into();
sink.send(rmsg_to_ccmsg(0_u16, c_sendme)).await.unwrap();
// Make and send a stream-level sendme.
@ -1239,7 +1278,7 @@ mod test {
// FIXME(eta): this is a hacky way of waiting for the reactor to run before doing the below
// query; should find some way to properly synchronize to avoid flakiness
tokio::time::sleep(Duration::from_millis(100)).await;
rt.sleep(Duration::from_millis(100)).await;
// Now make sure that the circuit is still happy, and its
// window is updated.
{
@ -1253,20 +1292,23 @@ mod test {
let (window, _tags) = rx.await.unwrap().unwrap();
assert_eq!(window, 1000 - 201);
}
})
}
#[async_test]
async fn invalid_circ_sendme() {
#[test]
fn invalid_circ_sendme() {
tor_rtcompat::test_with_all_runtimes!(|rt| async move {
// Same setup as accept_valid_sendme() test above but try giving
// a sendme with the wrong tag.
let (circ, _stream, mut sink, _streamid, _cells_received, _rx, _sink2) =
setup_incoming_sendme_case(300 * 498 + 3).await;
setup_incoming_sendme_case(&rt, 300 * 498 + 3).await;
let reply_with_sendme_fut = async move {
// make and send a circuit-level sendme with a bad tag.
let c_sendme =
relaymsg::Sendme::new_tag(hex!("FFFF0000000000000000000000000000000000FF")).into();
relaymsg::Sendme::new_tag(hex!("FFFF0000000000000000000000000000000000FF"))
.into();
sink.send(rmsg_to_ccmsg(0_u16, c_sendme)).await.unwrap();
sink
};
@ -1277,7 +1319,8 @@ mod test {
// FIXME(eta): we aren't testing the error message like we used to; however, we can at least
// check whether the reactor dies as a result of receiving invalid data.
while !circ.control.is_closed() {
tokio::time::sleep(Duration::from_millis(100)).await;
// TODO: Don't sleep in tests.
rt.sleep(Duration::from_millis(100)).await;
tries += 1;
if tries > 10 {
panic!("reactor continued running after invalid sendme");
@ -1285,6 +1328,7 @@ mod test {
}
// TODO: check that the circuit is shut down too
})
}
#[test]