mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Working with upstream
Former-commit-id: 6543387e4df9a96a443c510c9e382ace3731d2f6
This commit is contained in:
parent
c75625f179
commit
3214164070
@ -3,7 +3,6 @@ pub mod error;
|
|||||||
pub mod post;
|
pub mod post;
|
||||||
pub mod postbox;
|
pub mod postbox;
|
||||||
pub mod postoffice;
|
pub mod postoffice;
|
||||||
mod test;
|
|
||||||
|
|
||||||
// Reexports
|
// Reexports
|
||||||
pub use self::{
|
pub use self::{
|
||||||
|
@ -433,12 +433,6 @@ fn postbox_worker<S: PostSend, R: PostRecv>(
|
|||||||
|
|
||||||
// TESTS
|
// TESTS
|
||||||
|
|
||||||
#[test]
|
|
||||||
use std::{
|
|
||||||
thread,
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn connect() {
|
fn connect() {
|
||||||
let srv_addr = ([127, 0, 0, 1], 12345);
|
let srv_addr = ([127, 0, 0, 1], 12345);
|
||||||
@ -519,10 +513,10 @@ fn client_to_server() {
|
|||||||
|
|
||||||
let mut server_pb = po.new_connections().next().unwrap();
|
let mut server_pb = po.new_connections().next().unwrap();
|
||||||
|
|
||||||
client_pb.send(1337.0).unwrap();
|
client_pb.send(1337.0);
|
||||||
client_pb.send(9821.0).unwrap();
|
client_pb.send(9821.0);
|
||||||
client_pb.send(-3.2).unwrap();
|
client_pb.send(-3.2);
|
||||||
client_pb.send(17.0).unwrap();
|
client_pb.send(17.0);
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(250));
|
thread::sleep(Duration::from_millis(250));
|
||||||
|
|
||||||
@ -546,10 +540,10 @@ fn server_to_client() {
|
|||||||
|
|
||||||
let mut server_pb = po.new_connections().next().unwrap();
|
let mut server_pb = po.new_connections().next().unwrap();
|
||||||
|
|
||||||
server_pb.send(1337).unwrap();
|
server_pb.send(1337);
|
||||||
server_pb.send(9821).unwrap();
|
server_pb.send(9821);
|
||||||
server_pb.send(39999999).unwrap();
|
server_pb.send(39999999);
|
||||||
server_pb.send(17).unwrap();
|
server_pb.send(17);
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(250));
|
thread::sleep(Duration::from_millis(250));
|
||||||
|
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
use std::{
|
|
||||||
io::Write,
|
|
||||||
str::FromStr,
|
|
||||||
net::SocketAddr,
|
|
||||||
thread,
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
|
|
||||||
use mio::{net::TcpStream, Events, Poll, PollOpt, Ready, Token};
|
|
||||||
|
|
||||||
use super::{error::PostError, PostBox, PostOffice};
|
|
||||||
|
|
||||||
fn new_local_addr(n: u16) -> SocketAddr {
|
|
||||||
SocketAddr::from(([127, 0, 0, 1], 12345 + n))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn basic_run() {
|
|
||||||
let srv_addr = new_local_addr(0);
|
|
||||||
let mut server: PostOffice<String, String> = PostOffice::new(srv_addr).unwrap();
|
|
||||||
let mut client: PostBox<String, String> = PostBox::to_server(srv_addr).unwrap();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
let mut scon = server.new_connections().next().unwrap();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
scon.send(String::from("foo")).unwrap();
|
|
||||||
client.send(String::from("bar")).unwrap();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
assert_eq!("foo", client.new_messages().next().unwrap());
|
|
||||||
assert_eq!("bar", scon.new_messages().next().unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn huge_size_header() {
|
|
||||||
let srv_addr = new_local_addr(1);
|
|
||||||
|
|
||||||
let mut server: PostOffice<String, String> = PostOffice::new(srv_addr).unwrap();
|
|
||||||
let mut client = TcpStream::connect(&srv_addr).unwrap();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
let mut scon = server.new_connections().next().unwrap();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
client.write(&[0xffu8; 64]).unwrap();
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
assert_eq!(scon.new_messages().next(), None);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn disconnect() {
|
|
||||||
let srv_addr = new_local_addr(2);
|
|
||||||
|
|
||||||
let mut server = PostOffice::<_, String>::new(srv_addr)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// Create then close client
|
|
||||||
{
|
|
||||||
PostBox::<String, String>::to_server(srv_addr).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
|
||||||
|
|
||||||
let mut to_client = server
|
|
||||||
.new_connections()
|
|
||||||
.next()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
to_client.send(String::from("foo")).unwrap();
|
|
||||||
|
|
||||||
thread::sleep(Duration::from_millis(10));
|
|
||||||
|
|
||||||
match to_client.new_messages().next() {
|
|
||||||
None => {},
|
|
||||||
_ => panic!("Unexpected message!"),
|
|
||||||
}
|
|
||||||
|
|
||||||
match to_client.status() {
|
|
||||||
Some(PostError::Disconnected) => {},
|
|
||||||
s => panic!("Did not expect {:?}", s),
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,6 +19,9 @@ gfx_device_gl = { version = "0.15", optional = true }
|
|||||||
gfx_window_glutin = "0.28"
|
gfx_window_glutin = "0.28"
|
||||||
glutin = "0.19"
|
glutin = "0.19"
|
||||||
|
|
||||||
|
# ECS
|
||||||
|
specs = "0.14"
|
||||||
|
|
||||||
# Mathematics
|
# Mathematics
|
||||||
vek = "0.9"
|
vek = "0.9"
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ impl<S: Skeleton> Figure<S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Figure<S: Skeleton> {
|
pub struct Figure<S: Skeleton> {
|
||||||
bone_consts: Consts<FigureBoneData>,
|
bone_consts: Consts<FigureBoneData>,
|
||||||
@ -90,3 +90,4 @@ pub struct Figure<S: Skeleton> {
|
|||||||
impl<S: Skeleton> Component for Figure<S> {
|
impl<S: Skeleton> Component for Figure<S> {
|
||||||
type Storage = VecStorage<Self>;
|
type Storage = VecStorage<Self>;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user