on 2nd thought: do not copy_ledger() for this test
This commit is contained in:
parent
ead0eb2754
commit
039ed01abf
|
@ -352,21 +352,21 @@ pub fn read_ledger(ledger_path: &str) -> io::Result<impl Iterator<Item = io::Res
|
|||
Ok(LedgerReader { data })
|
||||
}
|
||||
|
||||
/// copy ledger is doesn't fix up the "from" ledger
|
||||
pub fn copy_ledger(from: &str, to: &str) -> io::Result<()> {
|
||||
let mut to = LedgerWriter::new(to, true)?;
|
||||
|
||||
let from = Path::new(&from);
|
||||
|
||||
// for a copy, we read "readonly" from data
|
||||
let data = File::open(from.join("data"))?;
|
||||
|
||||
for entry in (LedgerReader { data }) {
|
||||
let entry = entry?;
|
||||
to.write_entry(&entry)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
///// copy ledger is doesn't fix up the "from" ledger
|
||||
//pub fn copy_ledger(from: &str, to: &str) -> io::Result<()> {
|
||||
// let mut to = LedgerWriter::new(to, true)?;
|
||||
//
|
||||
// let from = Path::new(&from);
|
||||
//
|
||||
// // for a copy, we read "readonly" from data
|
||||
// let data = File::open(from.join("data"))?;
|
||||
//
|
||||
// for entry in (LedgerReader { data }) {
|
||||
// let entry = entry?;
|
||||
// to.write_entry(&entry)?;
|
||||
// }
|
||||
// Ok(())
|
||||
//}
|
||||
|
||||
// a Block is a slice of Entries
|
||||
pub trait Block {
|
||||
|
@ -783,31 +783,31 @@ mod tests {
|
|||
let _ignored = remove_dir_all(&ledger_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_copy_ledger() {
|
||||
use logger;
|
||||
logger::setup();
|
||||
|
||||
let from = tmp_ledger_path("test_ledger_copy_from");
|
||||
let entries = make_tiny_test_entries(10);
|
||||
|
||||
let mut writer = LedgerWriter::new(&from, true).unwrap();
|
||||
writer.write_entries(entries.clone()).unwrap();
|
||||
|
||||
let to = tmp_ledger_path("test_ledger_copy_to");
|
||||
|
||||
copy_ledger(&from, &to).unwrap();
|
||||
|
||||
let mut read_entries = vec![];
|
||||
for x in read_ledger(&to).unwrap() {
|
||||
let entry = x.unwrap();
|
||||
trace!("entry... {:?}", entry);
|
||||
read_entries.push(entry);
|
||||
}
|
||||
assert_eq!(read_entries, entries);
|
||||
|
||||
std::fs::remove_dir_all(from).unwrap();
|
||||
std::fs::remove_dir_all(to).unwrap();
|
||||
}
|
||||
// #[test]
|
||||
// fn test_copy_ledger() {
|
||||
// use logger;
|
||||
// logger::setup();
|
||||
//
|
||||
// let from = tmp_ledger_path("test_ledger_copy_from");
|
||||
// let entries = make_tiny_test_entries(10);
|
||||
//
|
||||
// let mut writer = LedgerWriter::new(&from, true).unwrap();
|
||||
// writer.write_entries(entries.clone()).unwrap();
|
||||
//
|
||||
// let to = tmp_ledger_path("test_ledger_copy_to");
|
||||
//
|
||||
// copy_ledger(&from, &to).unwrap();
|
||||
//
|
||||
// let mut read_entries = vec![];
|
||||
// for x in read_ledger(&to).unwrap() {
|
||||
// let entry = x.unwrap();
|
||||
// trace!("entry... {:?}", entry);
|
||||
// read_entries.push(entry);
|
||||
// }
|
||||
// assert_eq!(read_entries, entries);
|
||||
//
|
||||
// std::fs::remove_dir_all(from).unwrap();
|
||||
// std::fs::remove_dir_all(to).unwrap();
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ extern crate solana;
|
|||
|
||||
use solana::crdt::{Crdt, NodeInfo, TestNode};
|
||||
use solana::fullnode::FullNode;
|
||||
use solana::ledger::{copy_ledger, LedgerWriter};
|
||||
use solana::ledger::LedgerWriter;
|
||||
use solana::logger;
|
||||
use solana::mint::Mint;
|
||||
use solana::ncp::Ncp;
|
||||
|
@ -17,8 +17,9 @@ use solana::thin_client::ThinClient;
|
|||
use solana::timing::duration_as_s;
|
||||
use std::cmp::max;
|
||||
use std::env;
|
||||
use std::fs::remove_dir_all;
|
||||
use std::fs::{copy, create_dir_all, remove_dir_all};
|
||||
use std::net::UdpSocket;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::thread::sleep;
|
||||
|
@ -90,9 +91,19 @@ fn genesis(name: &str, num: i64) -> (Mint, String) {
|
|||
}
|
||||
|
||||
fn tmp_copy_ledger(from: &str, name: &str) -> String {
|
||||
let to = tmp_ledger_path(name);
|
||||
copy_ledger(from, &to).unwrap();
|
||||
to
|
||||
let tostr = tmp_ledger_path(name);
|
||||
|
||||
{
|
||||
let to = Path::new(&tostr);
|
||||
let from = Path::new(&from);
|
||||
|
||||
create_dir_all(to).unwrap();
|
||||
|
||||
copy(from.join("data"), to.join("data")).unwrap();
|
||||
copy(from.join("index"), to.join("index")).unwrap();
|
||||
}
|
||||
|
||||
tostr
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in New Issue