Removed temp test code
This commit is contained in:
parent
a2c0508792
commit
0bef355494
@ -330,6 +330,7 @@ mod tests {
|
||||
use std::str::FromStr;
|
||||
use std::net::*;
|
||||
use hash::*;
|
||||
use tests::helpers::*;
|
||||
|
||||
#[test]
|
||||
fn endpoint_parse() {
|
||||
@ -380,57 +381,22 @@ mod tests {
|
||||
assert_eq!(r[2][..], id1[..]);
|
||||
}
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::env;
|
||||
use std::fs::{remove_dir_all};
|
||||
// TODO: use common impl
|
||||
pub struct RandomTempPath {
|
||||
path: PathBuf
|
||||
}
|
||||
|
||||
impl RandomTempPath {
|
||||
pub fn new() -> RandomTempPath {
|
||||
let mut dir = env::temp_dir();
|
||||
dir.push(H32::random().hex());
|
||||
RandomTempPath {
|
||||
path: dir.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_path(&self) -> &PathBuf {
|
||||
&self.path
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.path.to_str().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for RandomTempPath {
|
||||
fn drop(&mut self) {
|
||||
if let Err(e) = remove_dir_all(self.as_path()) {
|
||||
panic!("failed to remove temp directory, probably something failed to destroyed ({})", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn table_save_load() {
|
||||
let temp_path = RandomTempPath::new();
|
||||
let temp_path = RandomTempPath::create_dir();
|
||||
let node1 = Node::from_str("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770").unwrap();
|
||||
let node2 = Node::from_str("enode://b979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@22.99.55.44:7770").unwrap();
|
||||
let id1 = H512::from_str("a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c").unwrap();
|
||||
let id2 = H512::from_str("b979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c").unwrap();
|
||||
{
|
||||
let mut table = NodeTable::new(Some(temp_path.as_str().to_owned()));
|
||||
let mut table = NodeTable::new(Some(temp_path.as_path().to_str().unwrap().to_owned()));
|
||||
table.add_node(node1);
|
||||
table.add_node(node2);
|
||||
table.note_failure(&id2);
|
||||
}
|
||||
|
||||
{
|
||||
let table = NodeTable::new(Some(temp_path.as_str().to_owned()));
|
||||
let table = NodeTable::new(Some(temp_path.as_path().to_str().unwrap().to_owned()));
|
||||
let r = table.nodes();
|
||||
assert_eq!(r[0][..], id1[..]);
|
||||
assert_eq!(r[1][..], id2[..]);
|
||||
|
Loading…
Reference in New Issue
Block a user