Fixed some tests

This commit is contained in:
arkpar 2016-02-16 17:54:34 +01:00
parent d95e971030
commit a4ea0737b2
3 changed files with 10 additions and 8 deletions

View File

@ -493,8 +493,8 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
};
match TcpStream::connect(&address) {
Ok(socket) => socket,
Err(_) => {
warn!("Cannot connect to node");
Err(e) => {
warn!("Can't connect to node: {:?}", e);
return;
}
}
@ -769,9 +769,9 @@ impl<Message> IoHandler<NetworkIoMessage<Message>> for Host<Message> where Messa
/// Initialize networking
fn initialize(&self, io: &IoContext<NetworkIoMessage<Message>>) {
io.register_stream(TCP_ACCEPT).expect("Error registering TCP listener");
io.register_stream(DISCOVERY).expect("Error registering UDP listener");
io.register_timer(IDLE, MAINTENANCE_TIMEOUT).expect("Error registering Network idle timer");
if self.discovery.is_some() {
io.register_stream(DISCOVERY).expect("Error registering UDP listener");
io.register_timer(DISCOVERY_REFRESH, 7200).expect("Error registering discovery timer");
io.register_timer(DISCOVERY_ROUND, 300).expect("Error registering discovery timer");
}

View File

@ -92,16 +92,18 @@ fn net_service() {
#[test]
fn net_connect() {
let key1 = KeyPair::create().unwrap();
let mut config1 = NetworkConfiguration::new_with_port(30344);
let mut config1 = NetworkConfiguration::new_with_port(30354);
config1.use_secret = Some(key1.secret().clone());
config1.nat_enabled = false;
config1.boot_nodes = vec![ ];
let mut config2 = NetworkConfiguration::new_with_port(30345);
config2.boot_nodes = vec![ format!("enode://{}@127.0.0.1:30344", key1.public().hex()) ];
let mut config2 = NetworkConfiguration::new_with_port(30355);
config2.boot_nodes = vec![ format!("enode://{}@127.0.0.1:30354", key1.public().hex()) ];
config2.nat_enabled = false;
let mut service1 = NetworkService::<TestProtocolMessage>::start(config1).unwrap();
let mut service2 = NetworkService::<TestProtocolMessage>::start(config2).unwrap();
let handler1 = TestProtocol::register(&mut service1);
let handler2 = TestProtocol::register(&mut service2);
while !handler1.got_packet() && !handler2.got_packet() {
while !handler1.got_packet() && !handler2.got_packet() && (service1.stats().sessions() == 0 || service2.stats().sessions() == 0) {
thread::sleep(Duration::from_millis(50));
}
assert!(service1.stats().sessions() >= 1);

View File

@ -66,7 +66,7 @@ impl<T> Hashable for T where T: BytesConvertable {
#[test]
fn sha3_empty() {
assert_eq!((&[0u8; 0]).sha3(), SHA3_EMPTY);
assert_eq!([0u8; 0].sha3(), SHA3_EMPTY);
}
#[test]
fn sha3_as() {