Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

ArchiveDB and other small fixes #5867

Merged
merged 4 commits into from
Jun 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethcore/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ mod tests {
let mut batch = DBTransaction::new();

// blocks [ 3a(c) 2a(c) 2b 1b 1a(c) 0 ]
// balance [ 5 5 4 3 2 2 ]
// balance [ 5 5 4 3 2 2 ]
let mut s = state_db.boxed_clone_canon(&root_parent);
s.add_to_account_cache(address, Some(Account::new_basic(2.into(), 0.into())), false);
s.journal_under(&mut batch, 0, &h0).unwrap();
Expand Down
1 change: 1 addition & 0 deletions ethstore/src/dir/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ mod test {
assert!(check_vault_name("vault_with_underscores"));
assert!(check_vault_name("vault-with-dashes"));
assert!(check_vault_name("vault-with-digits-123"));
assert!(check_vault_name("vault中文名字"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea to check that unicode works fully :)

}

#[test]
Expand Down
15 changes: 15 additions & 0 deletions util/src/journaldb/archivedb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,21 @@ mod tests {
jdb.commit_batch(3, &b"3".sha3(), Some((0, b"0".sha3()))).unwrap();
assert!(jdb.contains(&h));
jdb.commit_batch(4, &b"4".sha3(), Some((1, b"1".sha3()))).unwrap();
assert!(jdb.contains(&h));
}

#[test]
#[should_panic]
fn multiple_owed_removal_not_allowed() {
let mut jdb = ArchiveDB::new_temp();
let h = jdb.insert(b"foo");
jdb.commit_batch(0, &b"0".sha3(), None).unwrap();
assert!(jdb.contains(&h));
jdb.remove(&h);
jdb.remove(&h);
// commit_batch would call journal_under(),
// and we don't allow multiple owned removals.
Copy link
Contributor

@rphmeier rphmeier Jun 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

semantics of journaldb are a little weird as it never deletes the key from the backing store, so it actually wouldn't panic if the two removals were done on opposite sides of a journal_under operation...but as this test it will panic if you remove twice in a single batch.

Copy link
Contributor Author

@guanqun guanqun Jun 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I deliberately remove twice in a single batch and so mark this test as should_panic. This basically tests the assert logic, if you think it's un-necessary, I can revert this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't hurt to have the test case -- it will let us know if that behavior changes.

jdb.commit_batch(1, &b"1".sha3(), None).unwrap();
}

#[test]
Expand Down