From f64aa9e19253b7f22e56fd37fc0a7a0325cb3664 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sun, 2 Dec 2018 19:21:17 -0600 Subject: [PATCH] more validator tests --- .../db/src/stores/beacon_block_store.rs | 2 +- lighthouse/db/src/stores/validator_store.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lighthouse/db/src/stores/beacon_block_store.rs b/lighthouse/db/src/stores/beacon_block_store.rs index 54c8b7f9c..84cea2d0d 100644 --- a/lighthouse/db/src/stores/beacon_block_store.rs +++ b/lighthouse/db/src/stores/beacon_block_store.rs @@ -273,7 +273,7 @@ mod tests { let mut s = SszStream::new(); s.append(&block); 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(); diff --git a/lighthouse/db/src/stores/validator_store.rs b/lighthouse/db/src/stores/validator_store.rs index 6e5c960ba..518d92608 100644 --- a/lighthouse/db/src/stores/validator_store.rs +++ b/lighthouse/db/src/stores/validator_store.rs @@ -82,6 +82,25 @@ mod tests { use super::super::bls::Keypair; 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] fn test_put_public_key_by_index() { let db = Arc::new(MemoryDB::open());