summaryrefslogtreecommitdiffstats
path: root/net/tests
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-08-19 15:36:47 +0200
committerJustus Winter <justus@sequoia-pgp.org>2019-08-19 15:36:47 +0200
commit63637840a92f237b21369f2b8cb2c202d33613fc (patch)
tree0ee483ea20eae9bc63297ac8a2c75f4d56ccea4e /net/tests
parentbcd5ab8751c14f4ac48a2ea8b7d90163eb306b5f (diff)
net: Drop the sync variant.
- The sync wrapper hide the async nature of the implementation, and while this may seem convenient, it may cause subtle problems if it is invoked from a different event loop. - Furthermore, 'async' is a reserved keyword in the 2018 edition, requiring awkward escaping. - Fixes #307.
Diffstat (limited to 'net/tests')
-rw-r--r--net/tests/hkp.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/tests/hkp.rs b/net/tests/hkp.rs
index 65e5e83f..7e08f215 100644
--- a/net/tests/hkp.rs
+++ b/net/tests/hkp.rs
@@ -2,6 +2,7 @@ extern crate futures;
extern crate http;
extern crate hyper;
extern crate rand;
+extern crate tokio_core;
extern crate url;
use futures::Stream;
@@ -17,6 +18,7 @@ use rand::rngs::OsRng;
use std::io::Cursor;
use std::net::{SocketAddr, IpAddr, Ipv4Addr};
use std::thread;
+use tokio_core::reactor::Core;
extern crate sequoia_openpgp as openpgp;
extern crate sequoia_core;
@@ -142,6 +144,7 @@ fn start_server() -> SocketAddr {
#[test]
fn get() {
+ let mut core = Core::new().unwrap();
let ctx = Context::configure()
.ephemeral()
.network_policy(NetworkPolicy::Insecure)
@@ -153,7 +156,7 @@ fn get() {
let mut keyserver =
KeyServer::new(&ctx, &format!("hkp://{}", addr)).unwrap();
let keyid = KeyID::from_hex(ID).unwrap();
- let key = keyserver.get(&keyid).unwrap();
+ let key = core.run(keyserver.get(&keyid)).unwrap();
assert_eq!(key.fingerprint(),
Fingerprint::from_hex(FP).unwrap());
@@ -161,6 +164,7 @@ fn get() {
#[test]
fn send() {
+ let mut core = Core::new().unwrap();
let ctx = Context::configure()
.ephemeral()
.network_policy(NetworkPolicy::Insecure)
@@ -173,5 +177,5 @@ fn send() {
KeyServer::new(&ctx, &format!("hkp://{}", addr)).unwrap();
let key = TPK::from_reader(Reader::new(Cursor::new(RESPONSE),
None)).unwrap();
- keyserver.send(&key).unwrap();
+ core.run(keyserver.send(&key)).unwrap();
}