more validator tests

This commit is contained in:
Grant Wuerker 2018-12-02 19:21:17 -06:00
parent 7dd16215f4
commit f64aa9e192
2 changed files with 20 additions and 1 deletions

View File

@ -273,7 +273,7 @@ mod tests {
let mut s = SszStream::new(); let mut s = SszStream::new();
s.append(&block); s.append(&block);
let ssz = s.drain(); let ssz = s.drain();
bs.put_serialized_block(&hashes[i].to_vec(), &ssz).unwrap(); db.put(DB_COLUMN, &hashes[i].to_vec(), &ssz).unwrap();
} }
let tuple = bs.block_at_slot(&hashes[4], 5).unwrap().unwrap(); let tuple = bs.block_at_slot(&hashes[4], 5).unwrap().unwrap();

View File

@ -82,6 +82,25 @@ mod tests {
use super::super::bls::Keypair; use super::super::bls::Keypair;
use super::*; use super::*;
#[test]
fn test_prefix_bytes() {
let db = Arc::new(MemoryDB::open());
let store = ValidatorStore::new(db.clone());
assert_eq!(store.prefix_bytes(&KeyPrefixes::PublicKey), b"pubkey".to_vec());
}
#[test]
fn test_get_db_key_for_index() {
let db = Arc::new(MemoryDB::open());
let store = ValidatorStore::new(db.clone());
let mut buf = BytesMut::with_capacity(6 + 8);
buf.put(b"pubkey".to_vec());
buf.put_u64_be(42);
assert_eq!(store.get_db_key_for_index(&KeyPrefixes::PublicKey, 42), buf.take().to_vec())
}
#[test] #[test]
fn test_put_public_key_by_index() { fn test_put_public_key_by_index() {
let db = Arc::new(MemoryDB::open()); let db = Arc::new(MemoryDB::open());