fix tests

This commit is contained in:
Nikolay Volf 2016-06-20 14:20:13 +03:00
parent deb20c6249
commit c6616431b0
6 changed files with 51 additions and 51 deletions

View File

@ -302,7 +302,7 @@ pub fn generate_dummy_empty_blockchain() -> GuardedTempResult<BlockChain> {
pub fn get_temp_journal_db() -> GuardedTempResult<Box<JournalDB>> {
let temp = RandomTempPath::new();
let journal_db = journaldb::new(temp.as_str(), journaldb::Algorithm::EarlyMerge);
let journal_db = journaldb::new(temp.as_str(), journaldb::Algorithm::EarlyMerge, None);
GuardedTempResult {
_temp: temp,
result: Some(journal_db)
@ -319,7 +319,7 @@ pub fn get_temp_state() -> GuardedTempResult<State> {
}
pub fn get_temp_journal_db_in(path: &Path) -> Box<JournalDB> {
journaldb::new(path.to_str().unwrap(), journaldb::Algorithm::EarlyMerge)
journaldb::new(path.to_str().unwrap(), journaldb::Algorithm::EarlyMerge, None)
}
pub fn get_temp_state_in(path: &Path) -> State {

View File

@ -75,7 +75,7 @@ impl ArchiveDB {
fn new_temp() -> ArchiveDB {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
Self::new(dir.to_str().unwrap())
Self::new(dir.to_str().unwrap(), None)
}
fn payload(&self, key: &H256) -> Option<Bytes> {
@ -328,7 +328,7 @@ mod tests {
let bar = H256::random();
let foo = {
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
jdb.emplace(bar.clone(), b"bar".to_vec());
@ -337,13 +337,13 @@ mod tests {
};
{
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
jdb.remove(&foo);
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
}
{
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
assert!(jdb.exists(&foo));
assert!(jdb.exists(&bar));
jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap();
@ -356,7 +356,7 @@ mod tests {
dir.push(H32::random().hex());
let foo = {
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -370,7 +370,7 @@ mod tests {
};
{
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
jdb.remove(&foo);
jdb.commit(3, &b"3".sha3(), Some((2, b"2".sha3()))).unwrap();
assert!(jdb.exists(&foo));
@ -385,7 +385,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let (foo, _, _) = {
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar");
@ -400,7 +400,7 @@ mod tests {
};
{
let mut jdb = ArchiveDB::new(dir.to_str().unwrap());
let mut jdb = ArchiveDB::new(dir.to_str().unwrap(), None);
jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap();
assert!(jdb.exists(&foo));
}
@ -411,14 +411,14 @@ mod tests {
let temp = ::devtools::RandomTempPath::new();
let key = {
let mut jdb = ArchiveDB::new(temp.as_str());
let mut jdb = ArchiveDB::new(temp.as_str(), None);
let key = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap();
key
};
{
let jdb = ArchiveDB::new(temp.as_str());
let jdb = ArchiveDB::new(temp.as_str(), None);
let state = jdb.state(&key);
assert!(state.is_some());
}

View File

@ -107,7 +107,7 @@ impl EarlyMergeDB {
fn new_temp() -> EarlyMergeDB {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
Self::new(dir.to_str().unwrap())
Self::new(dir.to_str().unwrap(), None)
}
fn morph_key(key: &H256, index: u8) -> Bytes {
@ -714,7 +714,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -742,7 +742,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -770,7 +770,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -808,7 +808,7 @@ mod tests {
let bar = H256::random();
let foo = {
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
jdb.emplace(bar.clone(), b"bar".to_vec());
@ -818,14 +818,14 @@ mod tests {
};
{
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.remove(&foo);
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
}
{
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
assert!(jdb.exists(&foo));
assert!(jdb.exists(&bar));
jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap();
@ -840,7 +840,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 4
let foo = jdb.insert(b"foo");
@ -869,7 +869,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 4
let foo = jdb.insert(b"foo");
@ -918,7 +918,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
@ -949,7 +949,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 4
let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -989,7 +989,7 @@ mod tests {
let foo = b"foo".sha3();
{
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 1
jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -1010,7 +1010,7 @@ mod tests {
assert!(jdb.exists(&foo));
// incantation to reopen the db
}; { let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
}; { let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.remove(&foo);
jdb.commit(4, &b"4".sha3(), Some((2, b"2".sha3()))).unwrap();
@ -1018,14 +1018,14 @@ mod tests {
assert!(jdb.exists(&foo));
// incantation to reopen the db
}; { let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
}; { let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.commit(5, &b"5".sha3(), Some((3, b"3".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
assert!(jdb.exists(&foo));
// incantation to reopen the db
}; { let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
}; { let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.commit(6, &b"6".sha3(), Some((4, b"4".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -1038,7 +1038,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let (foo, bar, baz) = {
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar");
@ -1056,7 +1056,7 @@ mod tests {
};
{
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap());
let mut jdb = EarlyMergeDB::new(dir.to_str().unwrap(), None);
jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
assert!(jdb.exists(&foo));

View File

@ -135,7 +135,7 @@ impl OverlayRecentDB {
pub fn new_temp() -> OverlayRecentDB {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
Self::new(dir.to_str().unwrap())
Self::new(dir.to_str().unwrap(), None)
}
#[cfg(test)]
@ -526,7 +526,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -554,7 +554,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -582,7 +582,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.commit(0, &b"0".sha3(), None).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -620,7 +620,7 @@ mod tests {
let bar = H256::random();
let foo = {
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
jdb.emplace(bar.clone(), b"bar".to_vec());
@ -630,14 +630,14 @@ mod tests {
};
{
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.remove(&foo);
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
}
{
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
assert!(jdb.exists(&foo));
assert!(jdb.exists(&bar));
jdb.commit(2, &b"2".sha3(), Some((1, b"1".sha3()))).unwrap();
@ -652,7 +652,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 4
let foo = jdb.insert(b"foo");
@ -681,7 +681,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 4
let foo = jdb.insert(b"foo");
@ -730,7 +730,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
jdb.commit(1, &b"1".sha3(), Some((0, b"0".sha3()))).unwrap();
@ -761,7 +761,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 4
let foo = jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -801,7 +801,7 @@ mod tests {
let foo = b"foo".sha3();
{
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 1
jdb.insert(b"foo");
jdb.commit(0, &b"0".sha3(), None).unwrap();
@ -822,7 +822,7 @@ mod tests {
assert!(jdb.exists(&foo));
// incantation to reopen the db
}; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
}; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.remove(&foo);
jdb.commit(4, &b"4".sha3(), Some((2, b"2".sha3()))).unwrap();
@ -830,14 +830,14 @@ mod tests {
assert!(jdb.exists(&foo));
// incantation to reopen the db
}; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
}; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.commit(5, &b"5".sha3(), Some((3, b"3".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
assert!(jdb.exists(&foo));
// incantation to reopen the db
}; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
}; { let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.commit(6, &b"6".sha3(), Some((4, b"4".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
@ -850,7 +850,7 @@ mod tests {
let mut dir = ::std::env::temp_dir();
dir.push(H32::random().hex());
let (foo, bar, baz) = {
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
// history is 1
let foo = jdb.insert(b"foo");
let bar = jdb.insert(b"bar");
@ -868,7 +868,7 @@ mod tests {
};
{
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap());
let mut jdb = OverlayRecentDB::new(dir.to_str().unwrap(), None);
jdb.commit(2, &b"2b".sha3(), Some((1, b"1b".sha3()))).unwrap();
assert!(jdb.can_reconstruct_refs());
assert!(jdb.exists(&foo));

View File

@ -82,7 +82,7 @@ impl RefCountedDB {
fn new_temp() -> RefCountedDB {
let mut dir = env::temp_dir();
dir.push(H32::random().hex());
Self::new(dir.to_str().unwrap())
Self::new(dir.to_str().unwrap(), None)
}
}

View File

@ -234,10 +234,10 @@ mod tests {
let path = RandomTempPath::create_dir();
let smoke = Database::open_default(path.as_path().to_str().unwrap()).unwrap();
assert!(smoke.is_empty());
test_db(&DatabaseConfig { prefix_size: None, max_open_files: 256 });
test_db(&DatabaseConfig { prefix_size: Some(1), max_open_files: 256 });
test_db(&DatabaseConfig { prefix_size: Some(8), max_open_files: 256 });
test_db(&DatabaseConfig { prefix_size: Some(32), max_open_files: 256 });
test_db(&DatabaseConfig { prefix_size: None, max_open_files: 256, cache_size: None, });
test_db(&DatabaseConfig { prefix_size: Some(1), max_open_files: 256, cache_size: None, });
test_db(&DatabaseConfig { prefix_size: Some(8), max_open_files: 256, cache_size: None, });
test_db(&DatabaseConfig { prefix_size: Some(32), max_open_files: 256, cache_size: None, });
}
}