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